• Thu. Feb 22nd, 2024


Fresh news and articles!

Fingers On Additional: OCXO Clock


Feb 12, 2024
Fingers On Additional: OCXO Clock

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

As described within the accompanying Fingers On article, this venture 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 expertise that has seen important enhancements lately, drawing a lot much less energy at a a lot cheaper price.

The essential platform right here is an OCXO mixed with an Arduino Nano. The Nano presents much more processing energy than is critical for performing a easy hours-minutes-seconds sort clock however is affordable and easy to make use of. Nonetheless, the uncooked 10 MHz clock sign from the OCXO can’t be used to drive the Nano instantly. The Nano makes use of a 16 MHz ceramic resonator for its system clock and it isn’t simple to alter 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 applications onto the microcontroller. A bodily change to modify between 16 MHz and 10 MHz after this system was loaded was an choice, however not very sensible.

As an alternative, the strategy was to make use of interrupts. As with all microprocessors, the Nano helps interrupts, which, when triggered, can pause the presently working program code working, 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 contains three interrupt timers, and Timer0 and Timer1 will also be pushed by an exterior clock supply via 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.

Nonetheless, it was nonetheless not potential to drive the timers instantly 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 larger and incoming pulses on the pin will likely 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 rely down from 62500 will lead to an interrupt each tenth of a second. Seconds, minutes, and hours are then up to date appropriately.


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 contains the same old SPI and I2C interfaces which make it simple to interface to fashionable 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, equivalent, regulator offers 3.3V to the show. The regulator sort is just not crucial, various 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 stage so a voltage shifter is just not obligatory.

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 in all 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 change 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.

The entire elements used on this venture 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 accessible within the repository each as KiCad information and in Gerber format for others to have fabricated or modify below the inventive commons licence.

The ultimate board is just not complicated and designed as a double sided board which is straightforward 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 connected through flying leads. The prototype PCB was ordered via JCL in China, however any PCB fabrication home would do. The underside portion of the board incorporates the Arduino, the I2C expander, the OCXO, divider chain and voltage regulators. The voltage regulators are mounted with the tabs dealing with outwards so heatsinks could be fitted if required. This wasn’t discovered obligatory within the prototype, but when, for instance the shows are pushed at a excessive general brightness it could be obligatory. If the boards are mounted one behind the opposite, they need to be positioned again to again, so all of the elements will likely be accessible from the again of the clock. This can 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 offer the right clearance and mechanical stability. Two mounting holes are additionally fitted above and beneath the OCXO. That is to offer mechanical stability. The OCXO is a comparatively heavy element 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 via the 2 holes with its ends twisted collectively to carry the OCXO in place. Cable ties is also used, or a clamp if accessible. There are two units of schematics, PCBs and gerbers information. It’s 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 accessible 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 also be accessible in my Github repository. The supply code depends on solely two further libraries, the aforementioned Adafruit_IS31FL3731 and the frequent Wire library which permits 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 are outlined proper after the library contains within the supply code. There may be one LUT per numeral. It’s apparent by them which numeral is saved by which LUT, and it’s easy to interchange the LUTs with a brand new set, representing a distinct font. Subsequent, setup code checks that all the CharliePlexes are functioning appropriately and can ship a debug message to any linked laptop over the USB serial interface if not. Subsequent Timer1 is configured to just accept pulses from an exterior clock and to rely 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 predominant loop. The first operate of the principle loop is to name the subroutine that reads the rotary encoder. The encoder subroutine tries to eradicate change bounce and can also be simply modifiable. The principle 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 known as ten instances 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.


The OX4120A-D3-5-10.000-3.3 used on this venture is a hard and fast OCXO—its frequency can’t be adjusted. Different OCXOs permit changes to be made by making use of a management voltage to one of many pins, however I went with the easier oscillator its stability was believed to be excessive sufficient for this venture to not require adjustment. To verify the accuracy of the clock requires a good larger 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 seemingly that the OCXO on this clock is healthier than HP counter!

Leave a Reply

Your email address will not be published. Required fields are marked *