Sunday, November 24, 2024

Arms On Additional: OCXO Clock

Observe: This publish was initially printed on the writer’s Github repository for this undertaking.

As described within the accompanying Arms On article, this undertaking is a digital clock that makes use of a excessive stability 10 Megahertz oscillator as its timing reference. The oscillator is an oven controller crystal oscillator, or OCXO, a know-how that has seen important enhancements lately, drawing a lot much less energy at a a lot cheaper price.

The fundamental platform right here is an OCXO mixed with an Arduino Nano. The Nano provides much more processing energy than is important for performing a easy hours-minutes-seconds sort clock however is reasonable and easy to make use of. Nevertheless, the uncooked 10 MHz clock sign from the OCXO can’t be used to drive the Nano immediately. The Nano makes use of a 16 MHz ceramic resonator for its system clock and it’s not simple to vary the frequency of this, to say 10 MHz, with out important modification to the Nano’s firmware as a result of the 16 MHZ clock sign is used to derive the timing sign for the USB connection wanted to load packages onto the microcontroller. A bodily swap to change between 16 MHz and 10 MHz after this system was loaded was an choice, however not very sensible.

As a substitute, the method was to make use of interrupts. As with all microprocessors, the Nano helps interrupts, which, when triggered, can pause the presently operating program code operating, transfer the CPU’s registers to a reminiscence location, perform an interrupt service routine after which return the controller to regular operation by restoring the registers. Interrupts can usually be triggered by a clock-driven timer or an enter on a devoted exterior pin. The Nano consists of three interrupt timers, and Timer0 and Timer1 can be pushed by an exterior clock supply by way of the T0 and T1 pins. The timers work by being loaded with a binary quantity, which is then decremented each time a pulse is detected at their corresponding pin. When the timer reaches zero, an interrupt is triggered. Altering the quantity loaded into the timer alters the interval between interrupts. Timer0 is 8-bits the place as Timer1 is 16 bit.

Nevertheless, it was nonetheless not attainable to drive the timers immediately with the ten MHz sign from the OCXO. When used with an exterior clock on T0 or T1, the sign on the pin is sampled relative to the 16 MHz system clock. Utilizing a most Nyquist sampling issue of two.5, a practical most exterior enter frequency of 6.4 MHz outcomes—any increased and incoming pulses on the pin can be missed. Including a 4-bit binary counter after the OCXO’s output leads to one pulse being emitted by the counter for each 16 pulses it receives, because the counter counts from 0000 to 1111. With the OCXO working at 10 MHZ, the counter’s output sign frequency is then 625 kHz. Consquently, having the timer depend down from 62500 will end in an interrupt each tenth of a second. Seconds, minutes, and hours are then up to date appropriately.

Elements

I selected an Arduino Nano because the clock’s microcontroller as a result of it provide the identical capabilities as bigger Arduino controllers however is in a extra compact type issue and could be very low cost. Specifically, it consists of the same old SPI and I2C interfaces which make it simple to interface to trendy shows with their built-in drivers. The OCXO is a Raltron Electronics OX4120A-D3-5-10.000-3.3. Any appropriate OCXO could possibly be used, even one with a distinction frequency by altering the divider ratio. It additionally is available in a normal 14-pin dual-in-package (DIP) package deal configuration, though solely 4 pins are literally used. The OCXO is a 3.3-volt half, so a LD1117V33C linear low-drop-out (LDO) voltage regulator derives this voltage from the 5-volt system voltage that’s offered by the USB-C connection used to energy the clock. A second, similar, regulator offers 3.3V to the show. The regulator sort isn’t essential, different LDO or switching varieties could possibly be used. The 4-bit counter is 74HC191. Though the counter is powered by the 5V system voltage, its enter is appropriate with the OCXO’s 3.3V logic degree so a voltage shifter isn’t mandatory.

The show is made up of six Adafruit CharliePlex FeatherWings. Every CharliePlex consists of 7×15 pixel array of LEDs which could be pushed individually in a graphical mode or utilizing fonts constructed into the Adafruit_IS31FL3731 library. They’re communicated with through an I2C connection. The tackle of every CharliePlex could be set to one among two values: by default 0x74 however you could be modified to 0x77 by bridging a hyperlink with solder. To drive a number of shows I used a breakout board with the TCA9548A I2C expander chip, which lets me join a number of CharliePlex’s and tackle every on a separate I2C bus, avoiding tackle collisions.

A single rotary encoder with a momentary press swap is used because the consumer interface. This offers the clock a contemporary minimalist really feel. Separate press switches might after all be used with solely minimal adjustments to the {hardware} and/or software program.

All the parts used on this undertaking have through-hole packaging for simple development. A invoice of supplies with Digikey product reference numbers can be found in my Github repository.

Printed Circuit Board

The printed circuit board was designed in KiCad. The PCB design is made obtainable within the repository each as KiCad recordsdata and in Gerber format for others to have fabricated or modify below the inventive commons licence.

The ultimate board isn’t advanced and designed as a double sided board which is simple to solder. It’s could be simply damaged into two sections alongside two cutouts, both with a noticed or scoring and snapping. If damaged into part, pads are offered in order that headers could be soldered in to plug one board behind the opposite, making a extra compact type suited to a desk clock. On this type, the “high” board holds the show and rotary encoder, with all else on the again board. The rotary encoder is becoming within the centre of the board, however this might course be moved to elsewhere and hooked up through flying leads. The prototype PCB was ordered by way of JCL in China, however any PCB fabrication home would do. The underside portion of the board accommodates the Arduino, the I2C expander, the OCXO, divider chain and voltage regulators. The voltage regulators are mounted with the tabs going through outwards so heatsinks could be fitted if required. This wasn’t discovered mandatory within the prototype, but when, for instance the shows are pushed at a excessive general brightness it might be mandatory. If the boards are mounted one behind the opposite, they need to be positioned again to again, so all of the parts can be accessible from the again of the clock. This may make the clock simpler to hack later if required. M3 holes are fitted within the board for simple mounting and these line up for the higher and decrease elements of the board if they’re mounted again to again. Metallic spacers could be fitted to supply the proper clearance and mechanical stability. Two mounting holes are additionally fitted above and under the OCXO. That is to supply mechanical stability. The OCXO is a comparatively heavy part and held into the board just by 4 pins in a DIP socket. That is additionally mounted vertically, so not notably steady. A chunk of wire could be threaded by way of the 2 holes with its ends twisted collectively to carry the OCXO in place. Cable ties may be used, or a clamp if obtainable. There are two units of schematics, PCBs and gerbers recordsdata. It is because the TCA9548A modules is available in two flavours. The Adafruit one has a spacing of 0.6 inches between the rows (the “N” model) whereas some modules obtainable on eBay have a 0.7 inch spacing. Double verify which one you’re utilizing earlier than fabricating the PCBs.

Software program

The software program can be obtainable in my Github repository. The supply code depends on solely two extra libraries, the aforementioned Adafruit_IS31FL3731 and the widespread Wire library which allows serial communication, important for I2C connection to the show. Driving the shows requires individually programming every of the 105 LEDs on every CharliePlex. That is finished utilizing a set of look-up tables (LUTs) which can be outlined proper after the library consists of within the supply code. There may be one LUT per numeral. It’s apparent by taking a look at them which numeral is saved wherein LUT, and it’s easy to exchange the LUTs with a brand new set, representing a distinct font. Subsequent, setup code checks that the entire CharliePlexes are functioning accurately and can ship a debug message to any related pc over the USB serial interface if not. Subsequent Timer1 is configured to just accept pulses from an exterior clock and to depend down from 62499. That is 62499 and never 62500 to account for the time wanted to reset the counter every time it reaches zero and triggers an interrupt of this system’s fundamental loop. The first operate of the principle loop is to name the subroutine that reads the rotary encoder. The encoder subroutine tries to remove swap bounce and can be simply modifiable. The primary loop additionally updates the show, however solely when a flag bit has been set by the interrupt timer. There may be additionally a brightness variable right here which is consumer settable as is the variable for quickly growing the brightness of a digit when it’s being set. The code for the Timer1 interrupt service routine follows the principle loop. That is referred to as ten occasions a second, and takes care of incrementing the seconds, minutes, and hours as wanted. A pair of LEDs between the seconds and minutes, and one other pair of LEDs between the minutes and hours are additionally flashed right here, toggling on and off each half second. Their operate could possibly be simply modified if desired. The ultimate subroutine handles transmitting replace to the show through the TCA9548A I2C expander chip.

Accuracy

The OX4120A-D3-5-10.000-3.3 used on this undertaking is a set OCXO—its frequency cannot be adjusted. Different OCXOs enable changes to be made by making use of a management voltage to one of many pins, however I went with the less complicated oscillator its stability was believed to be excessive sufficient for this undertaking to not require adjustment. To verify the accuracy of the clock requires a good increased accuracy reference clock. The very best the writer had in his lab was a HP 53150A frequency counter with its personal OCXO reference. It was final calibrated in 2013. When measuring the OCXO reference the frequency on the counter fluctuated between 10,000,000 and 9,999,999. This means an settlement, and therefore accuracy, of higher than 1 half in 10,000,000. Being newer, it’s probably that the OCXO on this clock is best than HP counter!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles