Silicon ChipReciprocal Frequency Counter - July 2024 SILICON CHIP
  1. Contents
  2. Subscriptions
  3. Back Issues
  4. Publisher's Letter: We’ve come a long way
  5. Feature: Techno Talk by Max the Magnificent
  6. Feature: The Fox Report by Barry Fox
  7. Feature: Net Work by Alan Winstanley
  8. Project: Pi Pico-based Thermal Camera by Kenneth Horton
  9. Project: Dynamic NFC Tag by Tim Blythman
  10. Project: Reciprocal Frequency Counter by Charles Kosina
  11. Feature: Circuit Surgery by Ian Bell
  12. Feature: Audio Out by Jake Rothman
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Feature: Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley
  15. PartShop
  16. Market Centre
  17. Back Issues

This is only a preview of the July 2024 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Articles in this series:
  • The Fox Report (July 2024)
  • The Fox Report (September 2024)
  • The Fox Report (October 2024)
  • The Fox Report (November 2024)
  • The Fox Report (December 2024)
  • The Fox Report (January 2025)
  • The Fox Report (February 2025)
  • The Fox Report (March 2025)
  • The Fox Report (April 2025)
  • The Fox Report (May 2025)
Articles in this series:
  • Win a Microchip Explorer 8 Development Kit (April 2024)
  • Net Work (May 2024)
  • Net Work (June 2024)
  • Net Work (July 2024)
  • Net Work (August 2024)
  • Net Work (September 2024)
  • Net Work (October 2024)
  • Net Work (November 2024)
  • Net Work (December 2024)
  • Net Work (January 2025)
  • Net Work (February 2025)
  • Net Work (March 2025)
  • Net Work (April 2025)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
Articles in this series:
  • Audio Out (January 2024)
  • Audio Out (February 2024)
  • AUDIO OUT (April 2024)
  • Audio Out (May 2024)
  • Audio Out (June 2024)
  • Audio Out (July 2024)
  • Audio Out (August 2024)
  • Audio Out (September 2024)
  • Audio Out (October 2024)
  • Audio Out (March 2025)
  • Audio Out (April 2025)
  • Audio Out (May 2025)
  • Audio Out (June 2025)
Articles in this series:
  • Max’s Cool Beans (April 2024)
  • Max’s Cool Beans (May 2024)
  • Max’s Cool Beans (June 2024)
  • Max’s Cool Beans (July 2024)
  • Max’s Cool Beans (August 2024)
  • Max’s Cool Beans (September 2024)
  • Max’s Cool Beans (October 2024)
  • Max’s Cool Beans (November 2024)
  • Max’s Cool Beans (December 2024)
Articles in this series:
  • Teach-In 2024 (April 2024)
  • Teach-In 2024 (May 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (June 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (July 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (August 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (September 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (October 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (November 2024)
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 I bought a frequency counter over 30 years ago, but its accuracy is very poor by today’s standards, being out by as much as 50Hz at 10MHz. I replaced its not-very-­ accurate clock module with a 10MHz TCXO, and I can now rely on it to be within 1Hz at 10MHz. By adjusting the TCXO frequency to match that of my GPS-disciplined 10MHz frequency standard, I can be assured of such accuracy. But what happens when I want to measure low frequencies? For example, a 50Hz signal. With a gate time of one second, it will most likely show a reading of 50, even if it is not exactly that. It might flip to 49 or 51, but the resolution is only 1Hz. To improve that, we could have a gate time of 10 seconds and a resolution of 0.1Hz. For a 10mHz resolution, a 100-second gate time would be required, which is quite ridiculous. A better way to measure low frequencies is to measure the period. With the same example of 50Hz, using a 10MHz clock, it would accumulate 200,000 pulses in one 20ms period. If the number of pulses measured were actually 199,900, that would mean that the frequency is 10,000,000 ÷ 199,900 = 50.025Hz. That’s a great improvement in resolution, but highly dependent on the accuracy of the hardware in measuring precisely one cycle. Also, as the signal frequency increases, the resolution and accuracy decrease. One good thing about this scheme is that the exact measurement time is not critical, as the frequency calculation is ratiometric. This means that we should get reasonably accurate results as long as we have a clock source with an accurate frequency and synchronise the measurement period to the rising edges of the input signal pulse train. What do we need to measure with such precision? Mains frequency was the first thing I tried. I connected the output of a 6V AC mains transformer to an RC network to reduce the voltage and filter out noise. The frequency did vary slightly from reading to reading, and the largest variation was about 30mHz. This is within the required Australian Energy Market Operator (AEMO) specification of 49.85-50.15Hz. The frequency variation is caused by constantly changing 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 Features and Specifications ► 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 30 accurately and quickly using a microphone amplifier and this device. Functional description 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. 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 Practical Electronics | July | 2024 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 Input Count. The frequency is then calculated from the equation: f = Input Count × Ref Osc ÷ Ref Count 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 and D3 limit the input level to the first op amp and 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. Practical Electronics | July | 2024 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 many 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 twowire 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 analogue-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 The Counter is batterypowered, making it convenient to use. 31 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 Reciprocal Frequency Counter 32 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. Reproduced by arrangement with SILICON CHIP magazine 2024. www.siliconchip.com.au Practical Electronics | July | 2024 The oscillator TCXOs are readily available from Ali­ Express for about £8-10. 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 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. 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). 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. Practical Electronics | July | 2024 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. 33 Table 1 – readings from high-precision source without calibration Division ratio Input signal Table 2 – high-frequency measurements Measurement Error Input frequency Measurement ÷16384 610.3515625Hz 610.352Hz 1mHz 1MHz 999,999.990Hz Error ÷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 10mHz ÷1024 9,765.625Hz 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 I used my calibrated AD9851 signal generator to check frequencies above 1MHz; the results are shown in Table 2. The higher error rates above 1MHz appeared to be due to the TCXO being slightly off from 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, measures 76 × 63.5mm, and is available from the PE PCB Service. 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 the wrong way round! 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 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 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. 34 Practical Electronics | July | 2024 SMD ICs, which have larger lead pitches, so they should be easier. Don’t get IC1, IC2 and 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 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 and 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. Practical Electronics | July | 2024 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) both from the PE PCB Service 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 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 you’ve cleaned 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. 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 35 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 and click the program button. The file is available from the July 2024 page of the PE website: 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. https://bit.ly/pe-downloads 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 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. Teach-In 8 CD-ROM Exploring the Arduino EE FR -ROM CD ELECTRONICS TEACH-IN 8 FREE CD-ROM SOFTWARE FOR THE TEACH-IN 8 SERIES FROM THE PUBLISHERS OF This CD-ROM version of the exciting and popular Teach-In 8 series has been designed for electronics enthusiasts who want to get to grips with the inexpensive, immensely popular Arduino microcontroller, as well as coding enthusiasts who want to explore hardware and interfacing. Teach-In 8 provides a one-stop source of ideas and practical information. The Arduino offers a remarkably effective platform for developing a huge variety of projects; from operating a set of Christmas tree lights to remotely controlling a robotic vehicle wirelessly or via the Internet. Teach-In 8 is based around a series of practical projects with plenty of information for customisation. The projects can be combined together in many different ways in order to build more complex systems that can be used to solve a wide variety of home automation and environmental monitoring problems. The series includes topics such as RF technology, wireless networking and remote web access. PLUS: PICs and the PICkit 3 – A beginners guide The CD-ROM also includes a bonus – an extra 12-part series based around the popular PIC microcontroller, explaining how to build PIC-based systems. £8.99 INTRODUCING THE ARDUINO • Hardware – learn about components and circuits • Programming – powerful integrated development system • Microcontrollers – understand control operations • Communications – connect to PCs and other Arduinos PLUS... PIC n’MIX PICs and the PICkit 3 - A beginners guide. The why and how to build PIC-based projects Teach In 8 Cover.indd 1 04/04/2017 12:24 PRICE £8.99 Includes P&P to UK if ordered direct from us SOFTWARE The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series. ORDER YOUR COPY TODAY! JUST CALL 01202 880299 OR VISIT www.epemag.com 36 Practical Electronics | July | 2024