Silicon ChipProgrammable Frequency Divider - February 2025 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Staying on Windows 10
  4. Feature: Open-Source Software by Dr David Maddison, VK3DSM
  5. Feature: Using electronic modules - Mini UPS Module by Jim Rowe
  6. Subscriptions
  7. Project: High-Bandwidth Differential Probe by Andrew Levido
  8. Feature: Antenna Analysis, Part 1 by Roderick Wall, VK3YC
  9. Project: Wireless flashing LEDs by Tim Blythman
  10. Project: Transistor tester by Tim Blythman
  11. Feature: The PicoMite 2 by Geoff Graham & Peter Mather
  12. Project: IR Remote Control Keyfob by Tim Blythman
  13. PartShop
  14. Feature: Precision Electronics, Part 4 by Andrew Levido
  15. Project: Programmable Frequency Divider by Nicholas Vinen
  16. Serviceman's Log: Another busman’s holiday by Dave Thompson
  17. PartShop
  18. Vintage Radio: TRF-One AM radio by Dr Hugo Holden
  19. PartShop
  20. Market Centre
  21. Advertising Index
  22. Notes & Errata: Maxwell’s Equations, November 2024; Watering System Controller, August 2023
  23. Outer Back Cover

This is only a preview of the February 2025 issue of Silicon Chip.

You can view 43 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "High-Bandwidth Differential Probe":
  • High-Bandwidth Differential Probe PCB [9015-D or 9051-D] (AUD $5.00)
  • High-Bandwidth Differential Probe PCB pattern (PDF download) [9015-D] (Free)
  • High-Bandwidth Differential Probe panel artwork and drilling details (Free)
Articles in this series:
  • Antenna Analysis, Part 1 (February 2025)
  • Antenna Analysis, Part 1 (February 2025)
  • Antenna Analysis, Part 2 (March 2025)
  • Antenna Analysis, Part 2 (March 2025)
  • Antenna Analysis, Part 3 (April 2025)
  • Antenna Analysis, Part 3 (April 2025)
Items relevant to "Wireless flashing LEDs":
  • Software for JMP021 - Wireless LEDs (Free)
Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "Transistor tester":
  • Software for JMP020 - Transistor Tester (Free)
Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "The PicoMite 2":
  • PicoMite 2 firmware (Software, Free)
Articles in this series:
  • The Raspberry Pi-based PicoMite (January 2022)
  • The Raspberry Pi-based PicoMite (January 2022)
  • VGA PicoMite (July 2022)
  • VGA PicoMite (July 2022)
  • The PicoMite 2 (February 2025)
  • The PicoMite 2 (February 2025)
Items relevant to "IR Remote Control Keyfob":
  • RFID Programmable IR Fob Remote PCB [15109231] (AUD $2.50)
  • PIC16F15224-I/SL programmed for the RFID Programmable IR Fob Remote [1510923A.HEX] (Programmed Microcontroller, AUD $10.00)
  • RFID Programmable IR Fob Remote complete kit (Component, AUD $25.00)
  • IR$ Remote Control Keyfob firmware [1510923A.HEX] (Software, Free)
  • RFID Programmable IR Fob Remote PCB pattern (PDF download) [15109231] (Free)
  • Sticker artwork for the RFID Programmable IR Fob Remote PCB (Panel Artwork, Free)
Articles in this series:
  • Precision Electronics, Part 1 (November 2024)
  • Precision Electronics, Part 1 (November 2024)
  • Precision Electronics, Part 2 (December 2024)
  • Precision Electronics, Part 2 (December 2024)
  • Precision Electronics, Part 3 (January 2025)
  • Precision Electronics, part one (January 2025)
  • Precision Electronics, part one (January 2025)
  • Precision Electronics, Part 3 (January 2025)
  • Precision Electronics, part two (February 2025)
  • Precision Electronics, Part 4 (February 2025)
  • Precision Electronics, Part 4 (February 2025)
  • Precision Electronics, part two (February 2025)
  • Precision Electronics, part three (March 2025)
  • Precision Electronics, part three (March 2025)
  • Precision Electronics, Part 5 (March 2025)
  • Precision Electronics, Part 5 (March 2025)
  • Precision Electronics, Part 6 (April 2025)
  • Precision Electronics, Part 6 (April 2025)
  • Precision Electronics, part four (April 2025)
  • Precision Electronics, part four (April 2025)
  • Precision Electronics, part five (May 2025)
  • Precision Electronics, Part 7: ADCs (May 2025)
  • Precision Electronics, part five (May 2025)
  • Precision Electronics, Part 7: ADCs (May 2025)
  • Precision Electronics, part six (June 2025)
  • Precision Electronics, part six (June 2025)
Items relevant to "Programmable Frequency Divider":
  • Programmable Frequency Divider/Counter PCB [04108241] (AUD $5.00)
  • PIC16F1455-I/SL programmed for the Programmable Frequency Divider [0410824A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Programmable Frequency Divider kit (Component, AUD $60.00)
  • Software for the Programmable Frequency Divider (04108241A.HEX) (Free)
  • Programmable Frequency Divider/Counter PCB pattern (PDF download) [04108241] (Free)
Items relevant to "TRF-One AM radio":
  • TRF-One PCB pattern (PDF download) (Free)

Purchase a printed copy of this issue for $13.00.

Programmable Frequency M DIVIDER COUNTER This small PCB doesn’t cost a lot to build but provides several useful features. It can reduce the frequency of an incoming signal or pulse train by a factor of between 3 and 21,327,000 that’s easily configured over a USB serial port. It can also provide basic frequency measurements. By Nicholas Vinen ● Input frequency range: 300Hz to 77MHz (typical) ● Over 85,000 possible division ratios: — 3–21,327 (with short output pulses) — 30–213,270 in steps of 10 (50% duty cycle output) — 213,300–2,132,700 in steps of 100 (50% duty cycle output) — 2,133,000–21,327,000 in steps of 1000 (50% duty cycle output) ● Configuration: via USB serial interface; default power-up ratio can be selected ● Can measure the input signal frequency to ±0.25% (prototype was within ±0.02% <at> 20MHz) ● Output duty cycle: 10%/50% (if division ratio is multiple of 10; otherwise < 34%) ● Input signal level: 20mV to 3.2V RMS (100mV+ or more at low frequencies) ● Output jitter: estimated at 0.1ns ● Propagation delay: approximately 110ns ● Input/output impedances: 50Ω or 75Ω ● High noise immunity with 23.5mV hysteresis ● Outputs are in phase with inputs ● No output signal toggling in the absence of an input signal ● Power supply: 5-12V DC <at> 20mA ● Power connectors: USB Type-C, 2.1mm/2.5mm ID barrel socket 80 Silicon Chip Australia's electronics magazine y Compact Frequency Divider design, published in the May 2024 issue, was a purposefully simple design (siliconchip.au/ Article/16244). However, the hardware used was capable of doing a lot more than just dividing a signal frequency by a fixed ratio. I could have added jumpers to allow the ratio to be changed, but at least 19 jumpers would be required and figuring out how to set them would be very complicated. I instead decided to add a low-cost microcontroller with a USB interface that would allow you to type any desired division ratio. It could quickly reconfigure the divider chips to achieve the desired ratio. The cost and size of the extra parts are minimal, so the result is still quite compact and affordable. It can easily be configured with a wide range of possible division ratios; the USB cable used to configure it can also power it. For maximum flexibility, you can also save the ratio you set into flash memory and then power it from just about any low-voltage DC source away from a computer. I also realised it was pretty easy to add an onboard frequency counter that would be reasonably accurate, so I did that as well. You just type ‘m’ (for “measure”) and press Enter and within a second or so, it measures and reports the input frequency. So it’s a fairly useful little device that’s small and not too expensive to build. The signal chain is very similar to the May 2024 design mentioned earlier, with four digital logic ICs doing most of the work. There are three 74HC4017s, each dividing their inputs by a factor of 10, plus a 74HC4059 programmable divider chip. Cascading those four stages gives many possible division ratios. Like that earlier design, a highspeed push/pull comparator is used to boost and square up the input signal, while a hex buffer IC provides the drive strength for 50W or 75W termination. Besides the new parts to control the division ratio (a microcontroller and three more digital logic chips), the remainder of the circuit is a linear power supply with reverse polarity protection and a power indicator LED. The unusual 74HC4059 While updating this design, I pondered why the way the 74HC4059 siliconchip.com.au divider works is so strange, and I think I have the answer. The 4059 was designed in a time before microcontrollers. If you wanted to build a digitally controlled, PLLbased (phase-locked loop) radio tuner, you would need to have some sort of ‘register’ chip or chips to store the currently selected frequency. There would be a way to increase or decrease the value stored in that register (using buttons, or a knob, or something like that) and its output would be a binary number that would be fed to the PLL to control the tuning. You would also need a frequency divider as part of that PLL. A PLL essentially works by using negative feedback via a divider to multiply a frequency. So it appears that the 4059 was designed to be that part of the circuit, with its 16-bit digital inputs fed from the register. That explains why it has a programmable prescaler that effectively multiplies the 16-bit (‘J’) value by a figure of 2, 4, 5, 8 or 10. That is the way that you would select the size of the steps caused by each increment or decrement of the J-value. For our purposes, we can use a fixed prescaler value of 8 since we don’t need configurable steps; that value gives us the widest possible range of division ratio (3 to 21,327) and the microcontroller can figure out what values to feed to the 16 J inputs to achieve the desired ratio. To make the circuit more flexible, rather than just controlling the configuration of the 74HC4059, I have also added the ability to bypass one, two, or all three of the 74HC4017 divideby-ten stages. That is done using a single 74HC4052 dual 1-to-4 analog multiplexer chip, as described in more detail later. So we can divide by a factor of 1, 10, 100 or 1000 in addition to the configurable ratio of the ‘4059. Ideally, we want the final divide-by-10 stage in the circuit for two reasons. One is that the output pulses from the 74HC4059 are very narrow (only the length of the period of its input signal) and that last divide-by-10 stage acts as a clock stretcher. The other is that it also gives us the 10% or 50% duty cycle choice. So while ratios that are not multiples of 10 can be set (up to 21,327), the output pulses will have a duty cycle of 1/r, where r is the ratio. For example, a ratio of 321 will result in output siliconchip.com.au Converting a division ratio into an appropriate configuration As mentioned in the text, we only use a prescaler mode of 8 for the 74HC4059 chip because it gives the largest possible range of division ratios and has no disadvantages in this configuration. As the prescaler can be preset, that doesn’t restrict us to division ratios that are multiples of eight. Given a desired ratio, first we check if it is within the possible range of 3-21,327,000. If it is below 3, we make it 3, and if it is above 21,327,000, we clamp it to that value. We then check whether we need one, two, or three divide-by-ten stages based on the value. If the ratio is a multiple of ten and at least 30, we force it to have at least one divide-by-ten stage so we can get a 50% duty cycle output. We can then divide the desired ratio by either 1, 10, 100 or 1000 to determine the division factor necessary for the 74HC4059, which will be a value between 3 and 21,327. The final step is to figure out the 16-bit J value that produces that ratio and load it into the shift registers. J1-J3 are the prescaler preset value, between 0 and 7, calculated simply as the desired ratio modulus eight (ie, what is the remainder after dividing the ratio by 8). We then divide the ratio by eight and, if the result is 1000 or more, bit J4 must be 1. If J4 = 1, we subtract 1000 from the remainder. We can then determine the value for bits J13-J16 by dividing the remainder by 100 again. We take the remainder from that and divide it by 10 to get the J9-J12 value, then the remainder is the value for J5-J8. There’s just one remaining trick, which is that when we do the divisions by 100 and 10, we might get a value of more than 15, which is not possible to fit into four bits. In that case, we simply use the value of 15 but add the excess back to the remainder so that it flows into the later calculations. That’s necessary because of the odd ‘extended range’ trick needed to use the full set of possible division values of the 74HC4059. It’s a result of it being a BCD device but having 4-bit registers that can be programmed to any value between 0 and 15, not just 0 to 9 like a regular BCD device. pulses with a duty cycle of 1/321 or 0.31%. That’s fine for feeding to most frequency counters, using as a trigger pulse for an oscilloscope and so on. But there may be applications that such short pulses are not suited to. Since we have a microcontroller in the circuit, we can feed the output of the divider to it and have it count the pulses over a fixed time to give us an onboard frequency counter capability. The micro has no crystal but it synchronises its clock to the USB host, which likely does, so it should be reasonably accurate. So that you can use this device without it being tied to a computer, once the ratio is set, it can be stored in internal flash memory. In that case, it will be automatically restored each time it is powered up after that until it’s changed again. So you can plug it into a computer, set the ratio, unplug it and take it somewhere else to use it. It just needs a 5-12V DC supply to operate away from a computer. Circuit details The full circuit of the new Australia's electronics magazine Programmable Frequency Divider is shown in Fig.1. If you compare it to the one from May 2024, you will see that the power supply and circuitry around IC6, the comparator that acts as an input signal amplifier, is identical. The one difference in the power supply is that I didn’t have room to easily fit a 2-pin header as an alternative to the barrel socket (CON5) on this PCB. The arrangement of IC1-IC5 is also essentially the same, except that IC3’s configuration inputs are now driven by microcontroller IC10 and two 74HC595 serial-to-parallel shift registers (IC8 & IC9). Also, rather than a fixed signal chain of CON1 → IC6 → IC1 → IC2 → IC3 → IC4 → IC5 → CON3, we now have IC7b selecting whether IC3’s input clock comes from IC6, IC1 or IC2. The other half of that device, IC7a, also selects whether the output signal fed to IC5d/ e/f comes from the output of IC3 or IC4. IC7 itself is controlled by microcontroller IC10 via its S0 & S1 inputs. With S0 & S1 both low, Ya0 and Yb0 are selected, so all three 74HC4017s are bypassed and only the 74HC4059 February 2025  81 provides frequency division. This is for division ratios from 3 to 21,327 but not multiples of 10 (except for 10 and 20) because, as explained earlier, we ideally want IC4 to be involved so the 10% and 50% duty cycle outputs have the expected duty cycles. For the ratios 3-29 or 31-21,327 that are not multiples of 10, IC4 must remain out of the circuit. JP1 must be in the 50% position but the output duty cycle will actually be much lower (1/r, as mentioned earlier). If you put JP1 in the 10% position, you will get an output but its frequency will be divided by 10 compared to the other position. With S0 high but S1 low, Ya1 and Yb1 are selected. IC1 and IC2 are still bypassed (ie, the signal goes straight from IC6 to IC3) but now the output comes from IC4 instead of IC3. This is for ratios from 30 to 213,270 that are 82 Silicon Chip multiples of 10. Above 21,327, only multiples of 10 are available. With S0 low and S1 high, Ya2 and Yb2 are selected. Now only IC2 is bypassed and the range of available ratios is 300 to 2,132,700. With both S0 and S1 high, the signal passes through all four divider chips and the range of available ratios is 3000 to 21,327,000. Microcontroller IC10 The firmware running on IC10 does a few things: ● USB serial communications. It receives and echoes characters typed by the user. When enter is pressed, it parses the command and, if it’s valid, changes the division ratio, saves it to flash or performs a frequency measurement via its RC5 (pin 5) digital input. ● Configuring IC3. When a new division ratio is sent to IC10, it calculates the closest possible ratio that Australia's electronics magazine is actually achievable and figures out what values of J (16 bits) and K (3 bits) are required to achieve it. It then spits out the 16 bits of J one at a time via the SPI-like bus formed by the following digital outputs: RA5 (pin 2, serial data); RA4 (pin 3, serial clock) and RC4 (pin 6, latch enable). The latch-enable function is shared with the S0 control for IC7 to save a pin, since the S0 state doesn’t matter while the ratio is being reprogrammed. ● Performing frequency measurements. Pin 5 is also the 8-bit Timer 0 clock input (T0CKI), allowing IC10 to easily measure the output pulses. 16-bit Timer 1 counts IC10’s internal 12MHz clock pulses simultaneously. The currently set division ratio (which IC10 steps through to find the best one) along with the ratio of the two counts allows it to calculate the input frequency. For more on how it does this, siliconchip.com.au Fig.1: the signal from CON1 is amplified/squared up by IC6, then is divided by 10 by IC1, and again by IC2. IC7b determines which of the original or divided signals arrives at the CP input of IC3. Its division ratio is set using serial-toparallel registers IC8 & IC9 along with signal direct from micro IC10. The output is optionally divided by 10 again by IC4 and then fed to the output buffers. see the panel at the end of the article. In-circuit serial programming header CON6 allows IC10 to be reprogrammed while on the board. This was very useful during development and you may need it if you plan to program the chip yourself. If you purchase a programmed chip from the Silicon Chip Online Shop (possibly as part of a kit), you could leave CON6 off. Input signal conditioning We skipped over this in the description above, partly because it was already covered in the May 2024 article. Here’s a quick rundown. The incoming signal is terminated by a 75W resistor (it could be 50W depending on your preference) and then AC-coupled to the non-­inverting input of high-speed comparator IC6 via a 220W resistor. This resistor limits the current in case the input signal level siliconchip.com.au is too high, in which case the voltage at the non-inverting input of IC6 is clamped to the +5V/0V rails by dual schottky diode D1. The inverting input of IC6 is held at 2.5V, ie, half of the 5V supply due to a pair of 10kW resistors across the 5V supply and a 100nF capacitor to stabilise it and keep the source impedance low. Because both inputs are DC biased to close to the same voltage, only a small signal is required at the CON1 input to cause IC6’s output to toggle and swing between +5V and 0V. Without hysteresis, this would have a tendency to oscillate, as even a bit of noise would be enough to cause that toggling. However, the 10MW resistor from IC6’s pin 6 output to its pin 3 non-inverting input means that the input signal needs to exceed 23.5mV peak-to-peak before the output level will switch. It also means there is no Australia's electronics magazine output from IC6 if CON1 is left disconnected. There will be a small voltage across the 47kW resistor due to IC6’s input bias current, which places an upper limit on the practical value of that resistor. It will form a divider with the 220W resistor but it only reduces the incoming signal level by about 0.5% so it doesn’t really affect the operation. Outputs The two outputs are each driven by three parallel stages of IC5, the MC74VHCT50A hex buffer. This is similar to a 74HC04 hex inverter except that the outputs follow the inputs rather than being inverted, so there is no phase inversion. We need three in parallel for each output in case the constructor chooses 50W termination, in which case the buffers could be driving a load as low February 2025  83 Firmware 16-PIN USB-C SOCKET 100nF 5.1kW 100nF 1 IC4 50% 74HC4017 IC7 74HC4052 1 100nF 100nF 1 1 100nF 1 JP1 1 IC8 74HC595 IC5 ‘74HCT50A 10% IC7 74HC4052 75W AMS1117 REG1 1 100nF 75W 100nF A LED1 IC8 74HC595 IC10 PIC16F1455 5.1kW CON4 1 1 100nF IC2 74HC4017 D1 IC3 74HC4059 CON5 220W 10MW IC9 74HC595 CON6 1 USB-prog. Freq. Div. IC1 74HC4017 100nF 10kW 75W 10kW CON1 In 1 47kW IC6 1nF 100nF The firmware is based on a CDC USB/serial implementation that IC5 ‘74HCT50A 10% IC9 74HC595 100nF If a USB-C cable is connected via CON4, it powers the circuit directly. 5.1kW pull-down resistors are provided on the A5 and B5 pins to ask the host to supply 5V. If a plug is inserted in barrel socket CON5, USB power is disconnected from the circuit to avoid it feeding back into the computer. With 5-12V applied to CON5 (ideally at least 6V), power is fed to low-dropout 5V regulator REG1, which supplies the rest of the circuit. Regardless of the source of 5V, LED1 lights up. Mosfet Q1 is provided in case a power supply is connected to CON5 with reversed polarity. With the correct polarity, Q1’s gate is pulled positive via one or both of the 10kW resistors. Q1 is switched on and it connects the barrel socket ground to circuit ground (its body diode conducts before it switches on fully). Alternatively, if CON5 has the wrong polarity, Q1’s gate is pulled negative, holding it off, and its body diode is reverse-biased, so no current can flow between circuit ground and CON5’s outer barrel contact. Thus, no damage can occur. Zener diode ZD1 protects Q1’s gate from high applied voltages; it is safe up to -30V, at which point Q1’s channel could begin to break down. IC3 74HC4059 Power supply IC4 50% 74HC4017 related power supply components on the underside. That makes assembly a bit easier overall. As before, top and bottom ground planes have been used with plenty of vias, and signal tracks have been kept short to avoid too much distortion of high-frequency signals. The device is built on a double-­ sided PCB coded 04108241 that measures 84 × 35.5mm. Fig.2 shows the components on the top side, while Fig.3 shows those on the underside. We suggest fitting all the SMD parts to one side of the board, followed by the other, then the through-hole parts. It’s best to start with the top, as more parts are on that side. The passives are all M3216/1206 size at 3.2 × 1.6mm and all the ICs are SOIC/SOP types with a relatively large 1.27mm lead spacing. The only slightly tricky party is the USB socket, as it has a row of fairly closely spaced pins. It has two mounting pins that go into through-holes, so insert it first and push it down fully, then tack-solder one of the small end pins. Check that all the pins are lined up over their pads; if not, remelt that solder and gently nudge it one way or the other until they are all lined up. Then spread a thin layer of good-quality flux paste over all the pins, clean the soldering iron tip, add some fresh solder and drag it over the row of pins. You Construction may need to add more solder if you JP1 USB-prog. 100nF Assembly of the device is 1similar run out partway. 0kW Freq. Div. 75W 0kW 5W to the May 2024 version, except 1that If a few joints get too 7much solCON1 In 1 47kW there are a few extra chips onboard. der, resulting in a bridge to adjacent IC6 1nFsimilar, D1 pins, The layout of the PCB is also remove the bridges 1using a bit 1 1 1 1 100nF 100nF CON6 2IC6 20W 1and 0MW 75W CON2 although last time, comparator flux paste and an 100nFapplication 1 1more 1 0 0 n F 0 0 n F 100nF 1 1 A IC10 Lsliding ED1 its associated components were on the of clean solder wick, it away CON5 PIC16F1455 1 10from 0nF K underside and most of the other5.1parts the pins when it starts to draw kW CON3 were on the top. up the solder. 1 1kW 16-PIN 5.1kW USB-C This time, IC6 has been moved off the flux residue CON4 Sto 04108241 using a 10Clean 0nF OCKET the top, keeping all the signal com- solvent TOP OF Band OARuse D a magnifier and good ponents in a row from left to right, light to check that the solder joints with just the regulator and a few on all the pins look good and there IC2 74HC4017 provides the serial console used to configure the device. Added to that is code to set up the inputs and outputs and program the dividers in response to commands sent from a computer via USB. It also incorporates a frequency measurement routine that lets the board act as a basic frequency counter from 300Hz up to about 70MHz. The software code is converted to a HEX file using Microchip’s XC8 compiler. There is a free version of that compiler that lacks size optimisation (-Os). There is also a free 60-day trial of the Pro version that includes that feature. Because the PIC16F1455 only has 8k words of flash, we had to use the -Os option to fit all the features we wanted. Since we supply a compiled HEX file, you don’t need the compiler. You can either purchase a pre-programmed PIC or load the HEX file yourself. But if you want to modify the code with the full feature set, you will need the Pro version of the compiler. Another option is to remove the line “#define XC8_PRO” near the top of the file “main.c”. That will remove the L, H and P commands (see below) but the code will then compile with the free version of XC8 v2.5.0 (using -O2 optimisation) and still fit in the available flash. Those commands are not critical to the device’s operation. IC1 74HC4017 as 100W. In that case, the output current requirement at 5V is 50mA, right at the limit of two stages <at> 25mA each. The output load will be higher at higher frequencies due to the characteristic impedance of the output cable, approaching 150W (50W source + 50W cable + 50W termination). Still, at low frequencies, we have to assume that the cable impedance is close to 0W. CON2 K 1kW CON3 1m F 100nF 10kW 10kW 100nF ZD1 04108241 TOP OF BOARD 100nF Q1 UNDERSIDE OF BOARD Figs.2 & 3: most of the components are SMDs (on the large side) and virtually all mount on the top of the PCB. Those on the underside are basically just the power supply. You could use vertical SMA connectors if you wanted to; CON2 is not strictly required, as CON3 is the main output. CON2 usually provides a squared-up version of the input signal. 84 Silicon Chip Australia's electronics magazine AMS1117 REG1 1mF 100nF siliconchip.com.au are no more bridges. If so, solder the mounting posts into their holes to give it mechanical strengths. Now move onto the ICs, soldering them similarly. But first, a word of warning. I was very proud of how neatly I soldered the ICs onto the board, until I realised that I had put them all in with pin 1 at upper left – that’s not how the board is designed! Many of the ICs have their pin 1 towards the bottom of the board, so I had to use a hot air station to remove and then resolder them. Don’t make that mistake! In each case, place the IC, check its orientation (!), tack-solder one pin, check the alignment of all the pins and adjust if necessary. Then add flux paste, solder the remaining pins and remove any bridges. Once all the ICs are in place, clean off the flux residue, as it’s much easier to do it in stages. Chemtools’ Kleanium Deflux-It G2 Flux Remover is our preferred solvent but pure alcohol will also work. With all the ICs in place, solder diode D1 next, then all the passives on the top side of the board, referring to Fig.2. There is just one 1nF capacitor on the top of the board, next to CON1; all the other capacitors on this side are 100nF types. The resistors will be printed with codes indicating their values; see the parts list if you are unsure about that. Next, use a DMM on diode test mode to carefully probe the ends of the SMD LED until it lights up. The red probe will be on the anode (A) and black on the cathode (K), so use that information and Fig.2 to orientate it correctly before soldering it in place. Give the PCB another clean to remove flux residue, then flip it over. Parts List – Programmable Frequency Divider 1 double-sided PCB coded 04108241, 84 × 35.5mm 3 right-angle or vertical through-hole SMA connectors (CON1-CON3) 1 SMD USB Type-C power plus USB 2.0 data socket (CON4) [GCT USB4105] 1 PCB-mount DC barrel socket (CON5; optional) 1 5-pin header, 2.54mm pitch (CON6; optional, programming IC10 in-circuit) 1 3-pin header, 2.54mm pitch (JP1) 1 jumper shunt (JP1) 1 6-pin stackable header (only needed for programming IC10 in-circuit) Semiconductors 3 (CD)74HC4017(M96) CMOS Johnson decade counters, SOIC-16 (IC1, IC2, IC4) 1 (CD)74HC4059 high-speed CMOS programmable divide-by-N counter, SOIC-24 (IC3) 1 MC74VHCT50A hex CMOS non-inverting buffer, SOIC-14 (IC5) 1 TLV3501AID rail-to-rail high-speed comparator, SOIC-8 (IC6) 1 74HC4052 dual CMOS 4-to-1 analog multiplexer, SOIC-16 (IC7) 2 74HC595 8-bit serial-to-parallel shift registers, SOIC-16 (IC8, IC9) 1 PIC16F1455-I/SL 8-bit microcontroller programmed with 0410824A.HEX, SOIC-14 (IC10) 1 AMS1117-5.0 or compatible 5V 1A low-dropout regulator, SOT-223 (REG1) 1 AO3400 30V 5.8A N-channel logic-level Mosfet or equivalent, SOT-23 (code XORB) (Q1) 1 SMD LED, SMA/M3216/1206 size, any colour (LED1) 1 BZX84C5V6 5.6V 1% tolerance zener diode, SOT-23 (code YX) (ZD1) 1 BAT54S dual series schottky diode, SOT-23 (code KL4 or L44) (D1) Capacitors (all SMD M3216/1206 size 50V X7R unless noted) 1 1μF 13 100nF 1 1nF Resistors (all SMD M3216/1206 size 1%) Complete Kit (SC6959, $60): 1 10MW (code 106 or 1005) includes all components 1 47kW (code 473 or 4702) listed in the parts list except 4 10kW (code 103 or 1002) the programming header. 2 5.1kW (code 512 or 5101) 1 1kW (code 102 or 1001) 1 220W (code 220 or 220R) 3 49.9W (code 49R9) or 75W (code 75R or 75R0) (to suit impedances) Underside parts Solder REG1 as shown in Fig.3, then ZD1 and Q1, being careful not to get them mixed up as they will look similar (if you do, check the markings and compare them to the codes in the parts list). There is one 1μF capacitor on this side; the rest are 100nF. Both resistors are 10kW types. Clean off the flux residue on the underside, then finally move on to the through-hole parts. Those are CON1CON3, CON5 and JP1. You may also want to fit pin header CON6 if you need to program IC10 in-circuit. Note that you could leave SMA connector CON2 off if you don’t need or want You can get away with just fitting the USB socket to power the Programmable Frequency Divider. If you choose to do so, make sure to fit a wire link as shown in Fig.2. siliconchip.com.au Australia's electronics magazine February 2025  85 the extra output that usually provides a buffered, squared-up version of the input signal (or with its frequency divided by 10 or 100 for higher programmed division ratios). If you only want to power it using the USB socket and you will leave CON5 off, you need to solder a wire link as shown in red on Fig.2 or there will be no ground connection for the USB socket. If fitting CON5, do not fit that wire link. The underside of the PCB is primarily occupied by the power supply components. Testing Assuming IC10 is already programmed, the easiest way to test the board is to connect it to your computer using a USB-C cable. If your computer detects a new USB serial port and LED1 lights, things are looking good. If not, unplug it quickly and check for faults like bad solder joins, especially on the USB socket and IC10. If the board isn’t behaving, common problems to look for are solder bridges, pins where the solder hasn’t adhered to the PCB pad below, or incorrectly orientated ICs (we did warn you!). If the serial port does appear, use a program like Tera Term pro to connect to it (the baud rate is unimportant). Type “s” and press Enter/Return and you should get a similar status report: J=292 K=4 P=10 ratio=1000 Scope 2: the CON2 (green) and CON3 ‘50% duty cycle’ (yellow) outputs for a 15.5MHz 100mV sinewave input and with a 155:1 division ratio. Because it isn’t a multiple of 10, the output pulses from CON3 are not 50% duty cycle but instead are short (1/155 or 0.65% duty). Despite that, the ‘scope has no trouble measuring the frequency. The default division ratio is 1000 but you can change it with the ‘r’ and ‘w’ commands. If you have an oscilloscope with a built-in waveform generator (or separate signal generator), or a signal generator and frequency counter, hook them up to CON1 & CON3 and verify that the output frequency from CON3 is 1/1000th that of the input at CON1. If there’s no output signal, carefully check all the parts on the board for correctness and good soldering. If there’s an output but the frequency is wrong, that suggests a problem with the soldering of either IC3, IC8, IC9 or possibly IC7/IC10. If the ratio is correct, hook it up to a computer via USB and try changing the ratio to values like 3, 30, 30,000 and 300,000 by typing “r”, then the ratio, then pressing enter. The new ratio should be applied immediately. Scope 1 shows both outputs for a 20MHz input and 1000:1 division ratio. You can see that the 50% duty cycle output is nice and square and very accurate, while the CON2 output Australia's electronics magazine siliconchip.com.au Scope 1: the CON2 (green) and CON3 50% duty cycle (yellow) outputs for a 20MHz 100mV sinewave input and with the default 1000:1 division ratio. 86 Silicon Chip has frequency matching the input signal. Scope 2 shows the ‘50% duty cycle’ output for a 15.5MHz input and division ratio of 155:1. Each positive pulse is the length of one input cycle. So in this mode, the higher the division ratio, the lower the duty cycle. Usage You can get help on the available commands by typing “h” and then pressing enter (see below). Besides the ratio-setting command “r” mentioned immediately above, the most useful commands are “w” <Enter> (which saves the current ratio as the default at power-up) and “m” <Enter> which measures and then displays the input frequency. Low-frequency measurements may take a second or so. Listed just below are 16 measurements we made in a row of a 20MHz source: – 19996544 – 19999168 – 19999472 – 19997136 – 19999040 – 19997824 – 20005056 – 20001968 – 19998656 – 19998048 – 19997424 – 19999568 – 20001184 – 19998960 – 19996192 – 19999360 You will see that they vary a little above and below the exact frequency but they are surprisingly close given that the board has no crystal and the measurement method is fairly basic. The mean of those measurements is 19,999,100Hz (-0.011%), while the standard deviation is 2137 (0.015%). The “p” command lets you set the J, K & prescaler (1/10/100/1000) values directly but you generally shouldn’t need to use that. There are some combinations that you can set with that but not the “r” command but we don’t think they are that useful; we just included it for completeness. More details on these (and other) comSC mands follows. Typing ‘h’ (or ‘H’ or ‘?’) and pressing ◀ Enter should display a help message only that’s an abbreviation of this list. We have also added a short description for each command. siliconchip.com.au How IC10 measures the input signal frequency accurately To measure the input frequency, we use the programmable divider to divide it by a factor r, then measure the ratio of the result (Fout) to the 48MHz USB-­ derived clock (Fusb). We do that by counting the number of Fout pulses and Fusb pulses over an identical period. The actual period is not relevant, except that it determines the precision of the measurement. Let’s say the pulse counts are Pout and Pusb. We can then calculate the input frequency as Fin = Pout x r ÷ Pusb. However, as the PIC16F1455 is a low-end device with relatively little flash and RAM, we don’t have space for floating-­ point calculations, so it’s a bit trickier than just performing a multiplication and division. 8-bit Timer 0 counts pulses from the divider, while 16-bit Timer 1 counts the 48MHz USB clock pulses. Timer 0 is initiated at 255 and Timer 1 is initialised at 0 but is inactive. When the first pulse comes from the divider, Timer 0 rolls over to zero and triggers an interrupt that enables Timer 1. Both timers then count until Timer 0 rolls over again, at which point they are both paused. There is a slight delay between the positive edge of the divider output being received and Timer 1 starting/stopping, but the code is designed for the delay to be the same in both cases, so it cancels out. The number of times Timer 1 rolls over while the timer is active are counted, effectively extending Timer 1 from 16 bits to 24 bits, required to get an accurate result. The resulting 24-bit value is the number of 48MHz clock pulses that occurred between the 1st and 257th pulse from the divider. We can then calculate the division ratio times 48 million (the number of USB clock pulses per second), divide it by the number of actual USB clock pulses counted, then multiply by 256. Just before starting the counting, the division ratio is set to 80 as that is the highest multiple of ten that avoids a 32-bit integer overflow in these calculations. If we find the 24-bit Timer 1 counter overflows during this measurement (after about 350ms), that means the frequency is below 58.6kHz. In that case, we drop the divider ratio to 3 and restart the measurement. That allows us to measure down to 2.2kHz. If it still overflows, we change the number of Timer 0 clock pulses to measure over to one and try again. That would theoretically let us measure down to 9Hz, although measurements get pretty inaccurate below 300Hz due to hardware limitations. We perform 16 measurements and average them to get a more stable reading, although the number of measurements is reduced to four or one if the frequency is determined to be on the low side (eg, close to one second per measurement). Otherwise, making that many measurements would take too long. L load ratio from flash memory this is automatically done at power-up, but if you have changed the ratio and wish to reset to the default, you can run this command M measure frequency it’s most accurate over the range of about 1kHz to 50MHz but will work from 300Hz up to the upper limit, which is typically around 77-80MHz at room temperature P Jx Ky Pz set J/K/P to x/y/z valid ranges for values are: J[0-65535] K[0-7] P[1,10,100,1000] the J and K numbers are fed directly to IC3, while the P (pre/ postscaler) value determines the configuration of the 74HC4052 and thus which 74HC4017s (if any) are bypassed Rx set ratio to x valid range for values is: R[3-21327000] if the exact ratio given is not available, the closest possible ratio is used. Remember that ratios that are not multiples of 10, or ratios of 10 or 20, will give shorter output pulses and the 10% duty cycle output ratio will not be correct S show status this reports the J, K, P values and ratio. These are also reported after changing or loading the ratio W write ratio to flash memory the current ratio is stored and will be used at power-up in the future (the initial default is 1000). High-endurance flash is used, so it should not wear out after even 100,000 writes Australia's electronics magazine February 2025  87