Silicon ChipReciprocal Frequency Counter - July 2023 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: We will continue to offer printed and online magazines
  4. Feature: Charging Electric Vehicles by Dr David Maddison
  5. Feature: VL6180X Rangefinding Module by Jim Rowe
  6. Project: Dynamic NFC/RFID Tag by Tim Blythman
  7. Feature: Electronics Magazines in Aus. by Jim Rowe
  8. Project: Reciprocal Frequency Counter by Charles Kosina
  9. Project: Pi Pico Thermal Camera by Kenneth Horton
  10. Project: Railway Carriage Uncoupler by Les Kerr
  11. Subscriptions
  12. Vintage Radio: Replacing Vibrators, Pt2 by Dr Hugo Holden
  13. PartShop
  14. Serviceman's Log: Can’t stop servicing, even on holiday! by Dave Thompson
  15. Market Centre
  16. Advertising Index
  17. Notes & Errata: Loudspeaker Testing Jig, June 2023; Vintage Radio, Astor APN, May 2023
  18. Outer Back Cover

This is only a preview of the July 2023 issue of Silicon Chip.

You can view 38 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.

Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Dynamic NFC/RFID Tag":
  • Large Dynamic RFID Tag PCB [06101232] (AUD $4.00)
  • Small Dynamic RFID tag PCB [06101231] (AUD $1.50)
  • Small Dynamic RFID Tag kit (Component, AUD $5.00)
  • Credit card size Dynamic RFID Tag kit (Component, AUD $7.50)
  • Dynamic NFC/RFID Tag programming software (Free)
  • Dynamic NFC/RFID Tag PCB patterns [06101231/2] (Free)
Articles in this series:
  • History of Silicon Chip, Part 1 (August 2022)
  • History of Silicon Chip, Part 1 (August 2022)
  • History of Silicon Chip, Part 2 (September 2022)
  • History of Silicon Chip, Part 2 (September 2022)
  • Electronics Magazines in Aus. (July 2023)
  • Electronics Magazines in Aus. (July 2023)
Items relevant to "Reciprocal Frequency Counter":
  • Reciprocal Frequency Counter main PCB (CSE230101C) (AUD $5.00)
  • 0.96in cyan OLED with SSD1306 controller (Component, AUD $10.00)
  • Short-form kit for the Reciprocal Frequency Counter (Component, AUD $60.00)
  • Reciprocal Frequency Counter front panel PCB (CSE230102) (AUD $5.00)
  • Reciprocal Frequency Counter firmware (Software, Free)
  • Reciprocal Frequency Counter main PCB pattern (PDF download) [CSE230101C] (Free)
  • Reciprocal Frequency Counter front panel artwork (PDF download) (Free)
Items relevant to "Pi Pico Thermal Camera":
  • Raspberry Pi Thermal Camera PCB [04105231] (AUD $5.00)
  • Raspberry Pi-based Thermal Camera software & 3D printer files (Free)
  • Pi Pico Thermal Camera PCB pattern (PDF download) [04105231] (Free)
Items relevant to "Railway Carriage Uncoupler":
  • Model Railway Uncoupler PCB [09105231] (AUD $2.50)
  • PIC12F617-I/P programmed for the Model Railway Uncoupler [0910523A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Model Railway Uncoupler firmware [0910523A.HEX] (Software, Free)
  • Model Railway Uncoupler PCB pattern (PDF download) [09105231] (Free)
Items relevant to "Replacing Vibrators, Pt2":
  • Oscillator-Based Vibrator Mosfet replacement PCB [18106231] (AUD $2.50)
  • Oscillator-based Mosfet Vibrator Replacement PCB pattern (PDF download) [18106231] (Free)
Articles in this series:
  • Servicing Vibrators, Pt1 (June 2023)
  • Servicing Vibrators, Pt1 (June 2023)
  • Replacing Vibrators, Pt2 (July 2023)
  • Replacing Vibrators, Pt2 (July 2023)
  • Replacing Vibrators, Pt3 (August 2023)
  • Replacing Vibrators, Pt3 (August 2023)

Purchase a printed copy of this issue for $11.50.

Project by Charles Kosina This design measures low-frequency signals accurately and quickly. A traditional frequency counter must sample over a long period to get an accurate result. This one instead measures the average period and calculates the inverse, so it only needs to monitor a few pulses to get a precise reading. It’s useful up to about 10MHz. Reciprocal Frequency Counter bought a frequency counter Iaccuracy over 30 years ago, but its is very poor by today’s stan- the frequency is 10,000,000 ÷ 199,900 = 50.025Hz. That’s a great improvement in resdards, being out by as much as 50Hz olution, but highly dependent on the at 10MHz. I replaced its not-very-­ accuracy of the hardware in measuraccurate clock module with a 10MHz ing precisely one cycle. Also, as the TCXO, and I can now rely on it to be signal frequency increases, the resowithin 1Hz at 10MHz. By adjusting lution and accuracy decrease. the TCXO frequency to match that One good thing about this scheme of my GPS-disciplined 10MHz fre- is that the exact measurement time is quency standard, I can be assured of not critical, as the frequency calculasuch accuracy. tion is ratiometric. This means that we But what happens when I want to should get reasonably accurate results measure low frequencies? For exam- as long as we have a clock source with ple, a 50Hz signal. With a gate time of an accurate frequency and synchronise one second, it will most likely show a the measurement period to the rising reading of 50, even if it is not exactly edges of the input signal pulse train. that. It might flip to 49 or 51, but the What do we need to measure with resolution is only 1Hz. such precision? Mains frequency was To improve that, we could have a the first thing I tried. I connected the gate time of 10 seconds and a reso- output of a 6V AC mains transformer lution of 0.1Hz. For a 10mHz resolu- to an RC network to reduce the volttion, a 100-second gate time would be age and filter out noise. required, which is quite ridiculous. The frequency did vary slightly A better way to measure low fre- from reading to reading, and the largquencies is to measure the period. est variation was about 30mHz. This is With the same example of 50Hz, using within the required Australian Energy a 10MHz clock, it would accumulate Market Operator (AEMO) specification 200,000 pulses in one 20ms period. If of 49.85-50.15Hz. The frequency varithe number of pulses measured were ation is caused by constantly changing actually 199,900, that would mean that load conditions on the network. Also, musical instruments need to be tuned to very precise frequencies. In the equal-tempered scale, C4 (middle C) should be 261.63Hz. Concert pitch A4 must be 440.00Hz. All other notes require the same precision, to two decimal places, and a trained ear can pick the slightest differences in pitch. Such frequencies could be measured accurately and quickly using a microphone amplifier and this device. Functional description ► Operating frequency range: 10mHz-10MHz (maximum ~13.5MHz) ► Input sensitivity: 100mV peak-to-peak (~35mV RMS for a sinewave) ► Accuracy: typical error <0.001Hz up to 9.999MHz after calibration ► Sampling time: 0.1s, 1s or 5s ► Reference oscillator: temperature-compensated crystal oscillator (TCXO) ► Power: three AA cells for about 24 hours of battery life Refer to the timing diagram, Fig.1, which is not to scale. The input signal is fed into the clock input of a D-type flip flop (74HC74). While the D input (GATE TIME) remains low, the Q output remains low, and the counters are inhibited. We start the counting period by applying a logic one (high level) to the D input. On the next rising edge of the input signal, the Q output (COUNTEN) will go high after the short propagation delay. Two NAND gates are turned on as a result. The reference clock (REF COUNT) is then applied to 32-bit counter IC5, and the input signal, INPUT COUNT, is applied to the other 32-bit counter, IC8. After one second, the D input of the 74HC74 is taken low. The Q output remains high until the next positive edge of the input signal, when it will go low. This stops the accumulation of counts in both the 32-bit counters. Importantly, we have an exact input count as the period is synchronised with the rising edges of the input signal. Australia's electronics magazine siliconchip.com.au Features and Specifications 52 Silicon Chip Fig.1: when counting starts and stops is synchronised to the input signal. GATE TIME indicates roughly when counting should occur. However, the synchronised COUNTEN signal actually starts and stops counting (of INPUT COUNT and REF COUNT). The two count values are then divided to get a ratio and thus determine the actual input signal period. The reference counter is not synchronised the same way, so the count could be out by one. With a 10MHz reference oscillator, this results in an error of one part in 107. But, with a 30MHz reference, it reduces to 0.33 parts in 107, which is insignificant. We now have three parameters. The reference clock is a TCXO and so it is very accurate. IC5 will contain a number accumulated over the (approximate) one-second period, and this is the Reference Count, which will be near the Reference Oscillator frequency. The other counter, IC8, has the Input Count. The frequency is then calculated from the equation: f = Input Count × Ref Oscillator ÷ Reference Count prevent overload. The output of the second op amp (IC7b) is squared up by a 74HC14 schmitt trigger inverter (IC3a). Its output feeds into the clock input of 74HC74 flip-flop IC2a that produces the COUNTEN flag at its Q1 output, as well as a 74HC10 NAND gate (IC1c) producing the COUNT signal. I am using two 74HC10 three-input NAND gates with two of their inputs tied together instead of the two-input 74HC00 purely because of what I had in stock. I only need two of these gates, so using a 74HC00 with four gates wouldn’t be more helpful. The COUNT signal goes to both clock inputs of a 74LV8154 32-bit counter, IC8. A second such counter, IC5, is driven by the TCXO output, also gated by the COUNTEN signal, thanks to NAND gate IC1a, as described earlier. The microcontroller can clear both counters using the CCLR signal before initiating a count. That same signal also resets flip-flop IC2a, de-asserting the COUNTEN signal. Once counting is finished, the microcontroller can read the values from both 32-bit counters using an 8-bit data bus (CNTR07), selecting one byte from one 32-bit counter at a time (for a total of eight). Which byte is read out depends on the states of the SIG COUNT and 30MHZ_COUNT lines, which select one counter, and the SEL0/SEL1 bits, which select which byte of that counter is on the 8-bit bus, controlled by both halves of the 74HC139 dual 2-to-4 line decoder, IC4. The processor used is an Arduino Nano microcontroller module with an onboard ATmega328 microcontroller. These are available from multiple sources and are cheaper than buying the separate individual components, plus it removes some of the hard work in assembly. The display is the same 0.96-inch monochrome graphical OLED I have used in several previous designs. The Nano updates its display over a Circuit description Fig.2 shows the full circuit of the Counter. The input signal from CON2, a BNC or SMA connector, is amplified by the Analog Devices ADA4891-2 dual op amp, IC7. With the values shown, the gain is about 32, but that could be increased by changing a couple of resistors. A minimum input signal of 50-100mV peak to peak is needed. I chose that op amp as it has a high input impedance, a gain bandwidth (GBW) of 220MHz and a respectable slew rate of 170V/µs. It is also readily available from multiple suppliers at a modest price. The gain is applied in two stages of about five times each, to keep the overall bandwidth high. Inverse parallel diodes D2 & D3 limit the input level to the first op amp & siliconchip.com.au The Counter is batterypowered, making it convenient to use. Australia's electronics magazine July 2023  53 54 Silicon Chip Australia's electronics magazine siliconchip.com.au two-wire I2C serial interface with two 4.7kW pull-up resistors as required by the I2C standard. Switch S2 provides three sample time options: 0.1s, 1s or 5s. One second is adequate for most measurements. The five-second option may give marginally better resolution and accuracy. The 0.1 second gives a fast approximate reading. The microcontroller reads the position of centre-off switch S2 using its analog-to-digital converter to measure the voltage at pin 11 (ADC7). The switch either presents 0V, half-supply (2.5V) or close to full supply (5V). The power supply for basically all the chips in the design is a regulated 5V from boost regulator REG6. It produces this 5V from the 3-4.5V generated by three series AA cells, and its input is switched on/off by switch S1. CON3 and three more of the inverters in IC3 provide a serial debug interface. Unless you plan to modify the code, it isn't that useful, so CON3 and D4 can usually be left off the board. Software calculations The formula above certainly is simple, with just one multiplication and one division, but the numbers involved are large. We need to multiply before dividing so that we don’t lose accuracy, meaning we need to calculate an intermediate value that can be as high as 3,000,000,000,000 (three trillion; with a 10MHz input and 30MHz oscillator). That is way beyond 32-bit integer arithmetic. I use the BASCOM compiler, which can perform double-­ precision floating-point calculations using 64 bits. That’s enough to store numbers that large without any accuracy loss. For an 8-bit processor running at 16MHz, the above calculation takes 0.4ms, which is quite impressive for such an inexpensive chip. The oscillator Fig.2: the entire Frequency Counter circuit. Signal conditioning is at upper left; the counters are left of centre, the power supply is at lower left and the microcontroller and display are on the right. The micro decides when to start and stop counting and when to reset the counters. It is responsible for reading the counter values, computing the frequency and displaying it on the OLED screen. siliconchip.com.au Australia's electronics magazine TCXOs are readily available from AliExpress for about $16. I tried four different frequencies: 10MHz, 25MHz, 30MHz and 40MHz. The only change needed in the BASCOM source code was the substitution of one number. The higher frequencies give the advantage of slightly better resolution and accuracy. 40MHz is the maximum that can be used with the 74LV8154 counters, but it appears to be pushing the limit, as the accuracy seemed to July 2023  55 Table 1 – readings from high-precision source without calibration Division ratio Input signal Table 2 – high-frequency measurements Measurement Error 610.352Hz 1mHz 1MHz 999,999.990Hz ÷8192 1,220.703125Hz 1220.703Hz <1mHz 2MHz 1,999,999.870Hz 130mHz ÷4096 2,441.40625Hz 2441.406Hz <1mHz 5MHz 4,999,999.670Hz 330mHz ÷1024 9,765.625Hz ÷16384 610.3515625Hz Input frequency Measurement Error 10mHz 9765.625Hz <1mHz 8MHz 7,999,999.530Hz 470mHz ÷512 19,531.25Hz 19,531.249Hz 1mHz 10MHz 9,999,999.330Hz 670mHz ÷256 39,062.5Hz 39,062.500Hz <1mHz ÷128 78,125.0Hz 78,124.998Hz 2mHz ÷64 156,250.0Hz 156,249.995Hz 2mHz ÷32 312,500.0Hz 312,499.990Hz 10mHz ÷16 625,000.0Hz 624,999.980Hz 20mHz drop off. So 30MHz is the best option. It would be nice to have the frequency readout in one row of large digits. But in keeping with the style of my previous designs, I have used the same small OLED to show four lines of eight characters per line. That is not enough to display the frequency on one line, so it is split into two lines. The top line shows “FREQ” while the second line display up to 9,999,999 (Hz). The third line shows the remainder in mHz, from 0 to 999, while the final line displays the battery voltage. Accuracy The primary factor that affects accuracy is how close the TCXO is to its stated frequency. The second factor is the precision of the mathematical calculations, but with the use of 64-bit floating point arithmetic, any errors are minimal. SC6742 kit ($60 + postage) This kit includes everything in the parts list except the case, TCXO and AA cells. I used my 10MHz GPS-disciplined oscillator as an input to a 14-bit counter (74HC4060) and fed ten different divided frequencies into the Reciprocal Frequency Counter. Table 1 shows the results with the 30MHz TCXO straight out of the box with no adjustment. I then tuned the 25MHz TCXO to within less than 1Hz, and the errors were 1mHz or less for all of the frequencies shown in Table 1. The TCXOs I bought from Ali­ Express suppliers have been very close to the stated frequency, but it is possible to adjust them by peeling the label off the TCXO, which gives access to a trim capacitor. However, this is not for the faint-hearted, as it is an extremely fine adjustment, and unless you have the equipment and patience, I don’t recommend it. You need a dual-trace oscilloscope with one channel connected and locked to a GPS-disciplined 10MHz oscillator and the other to the TCXO output. The latter will drift left or right, and the trimmer should be adjusted for minimum drift. If it takes five seconds to drift one cycle, that’s an error of 0.2Hz (1Hz ÷ 5). Frequency limits The maximum frequency of this counter is partially limited by the op amp used in the input amplifier. The ADA4891 has a gain bandwidth (GBW) of 220MHz and a slew rate of 170V/µs (it was also chosen for its high input impedance and GBW). This limits the maximum usable frequency to about 15MHz; however, readings above 10MHz tend to become rather erratic. I used my calibrated AD9851 signal generator to check frequencies above 1MHz; the results are shown in Table 2. Fig.3: most parts are SMDs that mount on the top side of the board, but there are a handful of through-hole parts plus a few components on the back, notably the TCXO and Arduino Nano module. L1 can be either a through-hole type on the front or a 4 × 4mm SMD inductor on the back. Watch the polarity of all the ICs, the regulator and the diodes. 56 Silicon Chip Australia's electronics magazine siliconchip.com.au The higher error rates above 1MHz seem to be due to the TCXO being slightly off its nominal 30MHz frequency. The lower end of the frequency limit is determined by the input components (10μF/1MW) which gives a -3dB point of 16mHz. Therefore, the practical lower limit is about 10mHz. Measuring a 0.1Hz signal would take around 10-20 seconds, but that is the nature of low-frequency signals. Construction The assembled PCB is designed to fit into the Altronics H0324 plastic enclosure with a clear lid, so we don't need to cut a hole for the display. Before mounting any components on the PCB, use it as a template to drill holes into the clear lid. The PCB just fits in the front detent. Attach it with sticky tape and drill the four corner mounting holes with a 3mm drill. Use a 1.5-2.0mm drill for the two switch centre holes. Remove the PCB, drill out the switch holes to 6mm and countersink the mounting holes for M3 countersunk head screws (in this case, 6mm long). The triple AA battery holder should be attached to holes in the bottom of the enclosure using self-tapping countersunk head screws of around 3mm in diameter (4G in the old scheme). Next, move on to building up the PCB, which is coded CSE230101C and measures 76 × 63.5mm. During construction, refer to the PCB overlay diagram, Fig.3. Most of the components on it are surface-mount devices (SMDs). The two 32-bit counters, IC5 and IC8, come in relatively fine-pitch 20-pin TSSOP packages, so solder them first. The first and most important job is to identify pin 1 and ensure it is positioned correctly; you don’t want to finish soldering an IC to realise it’s around the wrong way! There should be a dot, or similar marking, in the pin 1 corner but you might need a magnifier to see it. Working one at a time, carefully position the chip on the pads and solder opposite corners without worrying about shorting pins. You need to ensure the pins are accurately aligned over the pads on both sides, though, so tack one corner first and only solder the other once the alignment looks good under a magnifier. Next, spread flux down both sides siliconchip.com.au Parts List – Reciprocal Frequency Counter 1 125 × 85 × 55mm IP65 sealed ABS enclosure [Altronics H0324] 1 3 × AA battery holder (BAT1) 3 AA cells 1 double-sided PCB coded CSE230101C, 76 × 63.5mm 1 double-sided PCB coded CSE230102, 1mm thick with black solder mask, 76.5 × 63.5mm (front panel) 1 Arduino Nano module (MOD1) 2 15-pin headers (for MOD1) 2 15-pin low-profile female header strips (to plug MOD1 into) 1 0.96-inch 128×64 pixel I2C OLED screen module (MOD2) [SC6176] 1 10μH axial RF inductor OR 4 × 4mm SMD inductor (L1) [eg, NRS4018T100MDGJ] 1 SPDT miniature solder-lug on/on (latching) toggle switch (S1) 1 SPDT miniature solder-lug on/off/on (latching centre-off) toggle switch (S2) 1 2-pin polarised header and matching plug (CON1) 1 SMA edge connector socket (CON2) 1 3-pin polarised header (CON3 for debugging; optional) 1 4-pin female header (for MOD2) 4 M3 × 6mm panhead machine screws 4 M3 × 6mm countersunk head machine screws 4 M3-tapped 12mm spacers 4 M3 flat washers 2 8mm-long untapped spacers (minimum 2mm inner diameter) 2 M2 × 16mm machine screws and nuts 2 3mm/4G x 6mm countersunk head self-tapping screws (for battery holder) Semiconductors 1 74HC10 triple 3-input NAND gate, SOIC-14 (IC1) 1 74HC74 dual D-type flip-flop, SOIC-14 (IC2) 1 74HC14 hex schmitt trigger inverter, SOIC-14 (IC3) 1 74HC139 dual 2-to-4 line decoder, SOIC-16 (IC4) 2 SN74LV8154PW 32-bit counters, TSSOP-20 (IC5, IC8) 1 ADA4891-2ARZ dual high-bandwidth op amp, SOIC-8 (IC7) 1 MCP1661T-E/OT or MP1542DK-LF boost regulator, SOT-23-5 (REG6) 1 4-pin through-hole 30MHz TCXO, 20×13mm (OSC1) [eg, www.aliexpress.com/item/32789207591.html] 1 MBR0540 40V 500mA schottky diode, SOD-123 (D1) 3 MMDL770T1G 75V 200mA signal diodes, SOD-323 (D2-D4) Capacitors (all SMD M2012/0805 size) 7 10μF 16V X7R 7 100nF 50V X7R Resistors (all SMD M2012/0805 size, 1%) 4 1MW 1 390kW 2 220kW 1 150kW 2 22kW 3 12kW 4 4.7kW 1 1kW and slowly drag the soldering iron tip along the pins. You might finish up with a blob of solder on the last couple of pins, so use a bit of extra flux paste and some solder braid (wick) to remove it. Use a loupe or similar to check that all the pins have been soldered properly and that there are no shorts between them. If there are, break out the flux and wick again. It helps to clean off the flux residue using an appropriate solvent and then do a final inspection before moving on because the residue can hide mistakes. With those nicely soldered, use a similar technique to solder the remaining SMD ICs, which have larger lead Australia's electronics magazine pitches, so they should be easier. Don’t get IC1, IC2 & IC3 mixed up; they all come in 14-pin SOIC/SOP packages. Regulator REG6 has three pins on one side and two on the other, so its correct orientation should be obvious. Start by tacking one of the two pins on one side as they have better separation. Use a similar technique as for the ICs, noting that a single pass with solder wick should clear any bridges from the three-pin side. Move onto the four diodes, noting that the different types come in different style packages, all rectangular prisms but with D2-D4 being smaller (there are various compatible types). In July 2023  57 each case, ensure the cathode stripe is facing towards the nearest “K” marking on the PCB (cathode is “Kathode” in German). After that, solder the SMD passives (capacitors & resistors) similarly. The resistors will be marked with codes indicating their values, while the capacitors will likely be unmarked, so don’t mix them up once they are out of their packages. Still, the 10µF caps will probably be thicker than the 100nF types. Moving onto inductor L1, there are two options. A moulded 10µH axial inductor may be used on the front side of the board, but a better choice is a 4 × 4mm SMD inductor on the other side of the board. The SMD option gives slightly higher boost converter efficiency and thus marginally longer battery life. With most of the SMDs in place, mount the through-hole parts. The OLED plugs into a 4-pin socket strip and is attached by two M2 × 15mm screws and untapped spacers. Carefully slide off the plastic spreader on the pins of the OLED header to reduce its height, then cut 3mm off the pins using side cutters. The OLEDs come in two slightly different sizes, and some are slightly shorter. If necessary, attach it using the holes on either side of the connector rather than the bottom pair. The Arduino Nano mounts on the back of the board and plugs into socket strips. Don’t solder it in directly, as you then can’t get at the OLED screw holes! It’s important to use low-profile pin sockets; otherwise, there is not enough room for the battery underneath. Fit the other components on the reverse side next, ie, the connectors, TCXO and additional 100nF capacitor. The input connector is an edgemounted SMA type. Ensure the TCXO is mounted with the correct orientation, having its pointy corner (indicating pin 1) towards the top of the board. The 3-pin header is only needed if you want to use the debugging interface. While the switches have solder lugs, they are mounted on the PCB like through-hole components. Ensure they are perpendicular to the board surface and fully pushed down before soldering them. S2, the centre-off type, goes on the right side (from the front). After cleaning the board, inspect it for missing or badly-formed joins and shorts between pins. You can then move on to programming the microcontroller. Microcontroller programming While we are using an Arduino Nano module with an onboard ATmega328 chip, we are not programming it with the Arduino IDE. The software is written in BASCOM and compiled into a HEX file. You can load that HEX file with an AVR ISP programmer, if you have one, via the 6-pin header on the Nano, but there is another method that doesn’t require the programmer. If you use the six-pin header for programming, there is a conflict with the I/O pins on the board, so it is necessary to unplug the Nano and connect it via the USB cable for power before flashing the chip. No fuses need to be changed; the defaults are fine, so it's ready once you’ve uploaded the HEX file. Alternatively, plug the Nano into your computer using a USB cable. The Nano is mounted via sockets, so the screw holes under it can be accessed, although in this case they are not used. A yellow sticker covers the TCXO calibration hole. 58 Silicon Chip Australia's electronics magazine Then install and load a program like AVRDUDESS for Windows. You can use the AVRDUDE command-line program in Linux or macOS. Set the programmer to Arduino, select the Nano’s USB serial port, the baud rate to 115,200 or 57,600 (depending on your Nano) and click “Detect”. If it doesn’t find the chip, adjust the settings and try again. Once it does, go to the Flash window, open the HEX file for this project (available for download from the Silicon Chip website) and click the program button. Final assembly Plug the Nano back into the PCB, and it can then be attached to the front panel (coded CSE230102) using 12mm spacers and M3 screws. Add a washer between the spacer and the front panel to increase the distance slightly. The front panel is another PCB, 1mm thick, with a black solder mask and white printing. It is held in place by the two switch nuts. Using a PCB here saves the trouble of printing out a label and making the cutouts. Power is from three AA cells; this is stepped up to a nominal 5V by REG6, although, with the resistor values shown, it is more like 4.4V. That’s intentional, as it reduces the current drain slightly. As mentioned earlier, attach the battery holder to the case using screws, as the battery can be pretty heavy, and we don’t want it coming loose. Wire the battery up to the plug that matches CON2, being very careful that the battery’s negative output goes to the ground pin closest to the corner of the PCB. There is no reverse polarity protection on the board, so if you get this wrong, you could smoke it! Once you’re sure that’s right, plug it in, switch on S1 and check that the display comes up as expected. The circuit will continue operating even when the cells have discharged to about 0.8V each. With fresh alkaline cells, it draws 75mA. With each cell at 1.2V (3.6V total), the current drain is 100mA, increasing as the battery voltage decreases further. Rechargeable cells (eg, Eneloop) could also be used. If you’d prefer to use an external power supply, use a 5V phone charger and leave out REG6, D1, L1 and the 150kW and 390kW resistors, plus short out D1 and L1. That will apply the 5V from CON1 directly to the circuit. SC siliconchip.com.au