Silicon ChipModern PIC Programming Adaptor - September 2024 SILICON CHIP
  1. Contents
  2. Publisher's Letter: Hello from the other side of the planet
  3. Feature: Techno Talk - I don’t want to be a Norbert... by Max the Magnificent
  4. Feature: The Fox Report by Barry Fox
  5. Feature: Net Work by Alan Winstanley
  6. Subscriptions
  7. Project: Build Your Own Calibrated Microphones by Phil Prosser
  8. Feature: Using Electronic Modules – 1.3-inch monochrome OLED by Jim Rowe
  9. Project: Modern PIC Programming Adaptor by Nicholas Vinen
  10. Feature: Circuit Surgery by Ian Bell
  11. Back Issues
  12. Feature: Audio Out by Jake Rothman
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Project: Salad Bowl Speakers by Phil Prosser
  15. Feature: Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley
  16. Back Issues
  17. PartShop
  18. Market Centre
  19. Advertising Index
  20. Back Issues

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

You can view 0 of the 80 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)
Constructional Project This small, low-cost adaptor lets you program most newer PIC microcontrollers out-ofcircuit. It works in conjunction with a PICkit or SNAP in-circuit programmer and provides five different modes to suit a range of chips from eight to 40 pins. It can even be used with SMD chips in SOIC, SSOP or TSSOP packages. Nicholas Vinen’s PIC Programming Adaptor T his new programming adaptor board is compact, easy to build and suits a large range of PICs released in the last 5-10 years, including many that we use in our projects. As we sell programmed PICs (and other microcontrollers) to build the projects described in our magazine, we have a box full of programming sockets, adaptors and other rigs to suit the many different types of chips. Lately, I realised that most of the time, we were using just a few of those adaptors because we have transitioned to mainly using recent PICs (released in the last 5 years or so). However, we still have to switch between several rigs because recent PICs still use a few different pinouts. For example, many of the latest 8-bit PICs use one configuration, while PIC24s, dsPICs and PIC32s use another. Some larger (eg, 40-pin) 8-bit PICs use further configurations. We previously published a fairly comprehensive PIC & AVR programming adaptor in the May & June 2013 issues. While we still use that board quite often, it was geared towards the chips that were available back then, and things have changed substantially. Features & Specifications > Adapts an in-circuit programmer like the Microchip PICkit or Snap to a ZIF socket > Can deliver 3.3V or 5V to the target; target power can also come from the programmer (if supported) > Programs DIP chips directly or SMD SOIC/SSOP/TSSOP via low-cost adaptors > PTC protection for the device being programmed (eg, in case it’s inserted in the socket incorrectly) > Supports most newer 8-bit PICs and most 16-bit and 32-bit PICs (including PIC24, dsPIC, PIC32MM and PIC32MX) with 8-40 pins > Tested PICs include 16F15213/4, 16F15323, 16F18146, 16F18857, 16F18877, 16(L)F1455, 16F1459, 16F1709, dsPIC33FJ256GP802, PIC24FJ256GA702, PIC32MX170F256B and PIC32MX270F256B > Many more chips are supported than listed above > LEDs indicate source power present, target power present, voltage range and programming activity > Simple to use with just five switches and silkscreened instructions > Includes ‘mouse clicker’ option to automatically trigger programming when the target is powered 30 Because it had to support so many different pinouts, it had certain compromises this newer design doesn’t have to deal with. Uses and function You may not need this board if you always design or build boards with in-circuit serial programming (ICSP) headers. However, there are times when it is convenient to program a chip out of circuit; for example, if your board is so compact that there’s no space for an ICSP header, or you want to swap chips out in the field. Or, like in our case, you want to supply someone with a pre-programmed chip. You can build individual programming jigs for each type of chip – which is what we did – but it can be annoying. You end up with many that you must dig through to find the right one each time. With this board, you just flick a few switches and it’s ready to program various chips. Fig.1 shows the five different pin configurations it offers. Each is colourcoded; the labels with that colour in the background indicate the function assigned to that socket pin in that mode. There are two settings for mode A and one for modes B, C and D. The two A modes suit almost all modern 8-bit PICs, which are inserted with the pin 1 end at the bottom of the ZIF socket. These all use the same pins for VDD, GND and MCLR and mostly use the Practical Electronics | September | 2024 New PIC Programming Adaptor same pins for programming (PGD = data and PGC = clock). The exception is devices with more than eight pins, like the PIC16(L)F1455 and PIC16(L)F1459, which can use the same programming pins as the other devices – shown in red in Fig.1 – but only for low-voltage programming (LVP). Sometimes, low-voltage programming is disabled. In that case, you must use mode A2, via the mauve labelled pins. Also, LVP could be disabled once you program them, so you might need to use the alternative mode for reprogramming. Not all chips support programming on those pins (especially 8-pin devices, which don’t extend that far!), so we can’t always use the alternative pins. Hence we use a dedicated switch to select between the two A modes. A separate four-throw switch selects between the A, B, C and D modes. In B, C and D modes, pin 1 is placed at the top of the ZIF socket. Mode B is for a few of the larger (40-pin) 8-bit PICs that use a different pinout than provided in mode A for backwards compatibility with certain older chips like the PIC16F877 (you can use mode B to program those older chips too). One example of a newer chip that needs mode B is the PIC16F18877 that we’ve used in a couple of projects, such as the USB Cable Tester (November & December 2022). Somewhat annoyingly, the 28-pin version of that chip, the PIC16F18857, cannot be programmed in mode B because its supply pins are in different locations (again, likely for backwards compatibility). So mode C leaves PGD, PGC and MCLR in the same places as mode B but changes VDD and GND to suit those chips. Finally, mode D suits a very common pinout used by many 28-pin devices, including much of the 16-bit PIC24 range, the 16-bit dsPIC range and the 32-bit PIC32MX range. We’ve opted to use pins 4 and 5 as PGD and PGC, respectively; many of these chips support multiple different (usually three) sets of programming pins, but this pair (#1) is the most consistently supported. The only other slightly unusual thing about mode D is that, in addition to connecting PGD, PGC, MCLR, VDD and GND to various pins, a highvalue, low-ESR capacitor also needs Practical Electronics | September | 2024 to be connected between pin 32 (pin 20 on the 28-pin chip) and GND. This board connects a 47μF ceramic capacitor through a low-resistance Mosfet to provide that function. One advantage of this circuit compared to the 2013 Programming Adaptor is that because modern PICs mostly use one of just a few pinouts, we only need four modes, making the switching considerably simpler. That means shorter paths between the ICSP socket and the ZIF socket pins and fewer components connected to those pins. As a result, programming is more reliable and programming speeds are higher. The older Adaptor sometimes requires you to reduce the programming speed to “slow” for it to work, but this new Adaptor generally works at “normal” and even “fast” programming speeds. Circuit details The full circuit is shown in Fig.2. It looks complicated but isn’t hard to understand if you break it into chunks. All of the switching for MCLR (which also sometimes carries VPP, the high programming voltage), PGD (data) and PGC (clock) is done by fourpole, four-throw slide switch S1. S1a switches MCLR from the ICSP header (CON1) to the appropriate pin on SK1 for each mode, with mode A at the top and mode D at the bottom. Similarly, S1b switches PGD (data) and S1c switches PGC (clock) to the pins of SK1. Thus, the only components in the path of these programming signals are CON1, SK1, S1 and some short PCB tracks, minimising signal degradation. One exception is that the PGC/PGD signals also pass through switch S2 in mode A, providing the two sub-modes, but the tracks connecting it to SK1 are very short. The fourth pole of S1, S1d, handles all the power pin switching (plus VCAP). It does this by grounding one of the four remaining switch pins. For pins that need VDD applied in this mode, that switch terminal connects to the gate(s) of P-channel Mosfet(s) with a shared gate pullup resistor. So when that terminal is grounded, the gates are pulled to ground, giving them a negative gatesource voltage and switching them on. In other modes, the resistor pulls up the gate(s), and they switch off, no longer driving those pins. For pins that need GND applied in a specific mode, the grounded pole is connected to the gate of one of the six inverters within IC1, a 74HC04 hex CMOS inverter (with a pull-up resistor, if one is not already present). The inverter’s output goes high when that pole is selected (pulling its input low), and that high level drives the gate(s) of one or more N-channel Mosfet(s), pulling the appropriate ZIF socket pins to GND. The only variations from this scheme are when multiple modes need to drive the same pin. In this case, diode logic is used to send the right voltages to the Mosfet gates. For example, dual diode D2 is configured so that input pin 9 of IC1d goes low in mode C or D. That causes IC1d’s output pin 8 to go high, switching on Q3, which pulls SK1’s pin 8 low. There are 100nF capacitors throughout the circuit connected between socket power pins via the switching Mosfets. That is, they connect between the source pins of the Fig.1: this shows how the five programming pins are mapped from the serial programmer to the ZIF socket in each mode; pin 1 is at bottom right for modes A1 & A2 and upper left for the others. Some pins have the same function in multiple modes, where the background colour is split between two or three modes. The only pins with different roles in different modes are 32, 39 & 40. 31 Constructional Project Fig.2: routing of the MCLR, PGC and PGD signals from serial programmer header CON1 to ZIF socket SK1 is straightforward, via 4P4T slide switch S1 and DPDT slide switch S2. Connecting GND, VDD and the 47uF capacitor to the appropriate pins of SK1 is a bit more complicated. Switch pole S1d and hex inverter IC1 plus some diode logic control Mosfets Q1-Q11 to apply the correct voltages to the right pins. The VDD indicator circuit is at lower right. P-channel (VDD switching) and Nchannel (GND switching) Mosfet pairs. That is so they do not affect any SK1 pins when those Mosfets are off. Pins 39 & 40 These are the only two pins that need to be switched between programming (PGD/PGC) and power pins. They are only used as power pins in mode D, for the PIC24/dsPIC/PIC32MX series of chips, where they are the AVDD and AVSS pins. These pins draw almost no current during programming and a maximum of a few milliamps if the chip is running code that uses the ADC peripheral. Mosfets have capacitance when off; the AO3400 and AO3401 Mosfets we’re using to switch power to the 32 other pins have rated output (drain) capacitances of 75pF (15V/1MHz) and 115pF (115pF/1MHz) respectively. The figures at 0-5V would be even higher and could easily be high enough to interfere with programming. Therefore, we are using much smaller Mosfets to switch power to these pins. Q10 (2N7002K) is an N-channel Mosfet with an output capacitance of 13pF at 25V/1MHz, while Q11 (BSS84) is a P-channel Mosfet with an output capacitance of 10pF under the same conditions. That’s a lot better, but it still could possibly interfere with programming, so 22W isolating resistors have been added to reduce the effect on programming signals at those pins when the Mosfets are off. That value was chosen to balance minimising the voltage difference between AVDD/AVSS and VDD/VSS while also providing reasonable isolation. Pin 32 (VCAP) The VCAP pin needs to be connected via a capacitor to ground in mode D. That’s achieved simply by permanently connecting a 47μF capacitor to that pin but switching its other end to ground via N-channel Mosfet Q5. This Mosfet is only on in mode D. When off, the Mosfet’s ~100pF output capacitance is in series with the 47μF capacitor, making it effectively a 100pF capacitor. LED5 and its 4.7kW series resistor across the VCAP capacitor are there to discharge it should it become charged Practical Electronics | September | 2024 New PIC Programming Adaptor tor is switched into mode D and Q9 switches off, the 47μF capacitor rapidly discharges to around 1.8V via LED5 (in around one second). LED5 will briefly light to let you know this is happening. Once it extinguishes, it is safe to insert a chip that’s programmed in mode D. Target power switching The target device (PIC) can be powered from a PICkit plugged into CON1. However, there are many cases where it’s more convenient to supply power externally, and if you’re using a Snap programmer, it can’t deliver power. Therefore, switch S4 applies power to the target device via PTC1, which goes high-resistance if the target draws too much current. That’s only likely if you have the wrong chip in the socket, the wrong mode selected, or the target is orientated incorrectly. In these cases, PTC1 might prevent it from being damaged. PIC16LF, PIC24, dsPIC and PIC32MX devices all need a 3.3V supply, while PIC16F devices can usually run from 3.3V or 5V. Some older chips require 5V for programming, although most modern PICs can be programmed at 3.3V. Therefore, switch S3 can generally be left at its 3.3V setting, although you can supply 5V to the target if you wish. Both the 3.3V and 5V sources come from a Raspberry Pi Pico, MOD1, which would typically be powered from a USB charger or a computer (presumably, the same one doing the programming). LED1 indicates when power is available from the Pico. The Pico also provides the mouse clicker function – more on that later. If you don’t need that function, it’s still a reasonable way to provide power to the board, but you can leave it off and fit USB connector CON2, regulator REG1 and its input and output capacitors. REG1 is a low-dropout regulator providing a 3.3V rail from the USB 5V supply. Programming indication above about 1.8V. That’s because pin 32 is also VDD in modes B and C, so if you have the power on and switch between modes C and D, there will be a brief overlap between the application of VDD to pin 32 and Q5 switching on, so the 47μF capacitor will charge to VDD. Practical Electronics | September | 2024 This capacitor could hold that VDD voltage for a long time. When a target device is later inserted in SK1 that uses pin 32 as VCAP, that capacitor’s charge would be dumped into that pin, which is only intended to handle up to about 1.8V. To prevent that, as soon as the Adap- LED2 lights when there is an AC waveform at the PGD pin of CON1. This signal is coupled via a 100pF capacitor and biased to 0V with a 1MW resistor to minimise any effect on the actual programming. Whenever PGD goes low, the 100pF capacitor discharges through diode D4. When it goes high, input pin 13 of inverter 33 Constructional Project if VDD is above 5.5V; however, the USB supply should never be high enough to allow that, nor should the VDD output of a PICkit. Also note that if you change the colour of LED3 to anything other than red, yellow or amber, it might not light up for lower VDD voltages (1.8-2.2V and possibly higher, depending on its colour). Mouser clicker The underside of the PIC Programming Adaptor shown at actual size with and without the Raspberry Pi Pico. These photos are just prototypes, in the final version D1-D5 are BAT54A diodes, while D6 is the sole BAV99 as shown in Fig.2. IC1f goes high, so its output goes low, lighting LED2, which draws around 1-2mA. Because PGD toggles very fast, LED2 should appear to light solid when PGD is toggling, albeit at reduced brightness. You might notice that the prototype was built with LED1 as green and LED2 as blue, while everything else shows it the other way around. That’s because a blue LED typically has a forward voltage of at least 3V, so it seemed to make more sense in hindsight for LED1 to be blue, as it’s powered from 5V, while LED2 could be powered from 3.3V or less. In practice, the blue LED2 on our prototype lights up just fine with VDD at 3.3V, and we don’t intend to program chips at voltages below that. Ultimately, it’s up to you how you arrange the colours. LED3 and LED4 are provided so that you know when power is applied to the target and that it is in the expected voltage range. Dual comparator IC2 provides this function. A ~0.6V reference voltage is developed at pins 3 and 5 of IC2 by half of diode D6, which is forward-biased by a 5.1kW resistor from the VDD rail. 34 A 22kW/5.6kW/4.7kW divider across the VDD rail applies two fractional voltages to pins 2 and 6 of the same chip. These are roughly 16% and 33% of the VDD voltage. Therefore, the output of comparator IC2a goes low when VDD exceeds 0.6V ÷ 33% = 1.8V, and the output of IC2b goes low when it exceeds 0.6V ÷ 16% = 3.75V. Note that the ~0.6V reference from D6 varies slightly with VDD; hence, the percentages and voltages above are not exact. LED3 comes on with a supply voltage just below 1.8V (dimly, since that’s barely above the LED’s forward voltage), while LED4 comes on a little over 3.8V, which is higher than the 3.6V indicated. Still, in most cases, VDD will either be below 3.6V or above 4.5V. If VDD > 3.8V and output pin 7 of IC2b is low, LED4 is forward-biased and lights with around 6mA ([5V – 2V] ÷ 470W). At the same time, diode D5 is forward-biased and pulls the anode of LED3 low, so LED3 cannot also light. If VDD < 3.8V and LED4 is off, LED3 will light if output pin 1 of IC2a is low. That is the case when VDD is between 1.75V and 3.8V. The 470W resistor limits its current to a few milliamps. Note that LED4 will not extinguish The mouse clicker using the Raspberry Pi Pico was previously described in a “Mouser Clicker” project, reproduced in a panel at the end of this article. When connected to the computer, the Pico appears as a mouse and triggers a click whenever its GP1 pin (pin 2) is pulled externally high. This will be the case when VDD is switched on as long as slide switch S5 is in the correct position. You position the mouse cursor over the “Program” button on your software, then, with the programming rig already set up, you put the chip in the ZIF socket and switch target power on. The Pico will click the Program button, and the chip will be programmed. You can then switch the target power off, remove the chip and insert another one, ready for programming. The whole process can take just a few seconds per chip. The Pico will do nothing with S5 off as there is nothing to pull its pin 2 high; an internal pull-down current keeps that pin low. Construction The Programming Adaptor is built on a 65.5 × 66mm PCB coded 24105231. We had ours made with a blue solder mask because we thought it’d look nice, especially as many people would use it as a bare board. There are components on both sides; Figs.3 & 4 show where they are mounted. The top side mostly has the connectors and switches, with almost all the Mosfets on the underside. The Pico mounts on the underside too. We have purposefully avoided putting any components under it, but there are solder joins for SK1, S3 and S4 under it, so it needs to be mounted on headers for spacing. We’ll get to that a bit later. The first parts to fit are the SMDs, as they are pretty flat. Because most of them are on the underside, it’s best to start there. All SMD components on the underside are either 3.2 × 1.6mm Practical Electronics | September | 2024 New PIC Programming Adaptor (imperial 1206) passives (including the PTC) or three-pin SOT-23 package Mosfets or diodes. Start with the SOT-23 package devices, ensuring you don’t mix up the six or seven types. Their orientations should be evident but watch that you don’t accidentally try to solder them upside-down, with their leads sticking up in the air, ‘dead bug’ style. You don’t need to fit REG1 if you will use the Pico (which we recommend). For parts like Q2, where its central pin is very close to a through-hole pad, avoid getting solder on that nearby pad. If you do, and it goes into the hole, you might have difficulty soldering the ZIF socket later. If you get some in there, clean it up as best you can with flux paste and some solder wick or a solder sucker. For each 3-pin device, tack one lead, check the positioning, then solder the other two. Adding a tiny bit of flux paste on the three pads from a syringe before locating the part will make the solder flow much more easily. Verify that all three solder joints are shiny and have adhered to both the pin and the pad; if they are not shiny, add a touch of flux paste to the joint and touch your iron to it to reflow it. With all the SOT-23 devices in place, move on to the resistors, capacitors and PTC thermistor that mount on the underside, none of which are polarised. The two capacitors right next to REG1 do not need to be fitted if you are not using REG1. The resistors will be printed with codes like 102 or 1001 for 1kW, 1005 We designed this as a compact board so it doesn’t take up much space on your workbench, even with a PICkit or similar hanging off the side. That requires the controls to be closely spaced together, but we find them all to be accessible enough during use. This version of the PCB lacks SMD LED5, which was added later. or 106 for 10MW etc. Use a magnifier to read them, if necessary. The capacitors will not be labelled, so take them out of their packages one lot at a time and solder them in place so you don’t get them mixed up. Now is a good time to clean flux residue off the board; we really like Chemtools’ Kleanium Deflux-It G2 Flux Remover, but you can use some alcohol or acetone instead if that’s all you have on hand. Inspect the solder joints under magnification to verify they’re all good. The only remaining components to fit on the underside are either the Pico or USB socket, depending on which you’re using, but leave them off for now and flip the board over. Solder the two SMD ICs, ensuring their pin 1 indicators (dots, chamfered edges etc) are at upper left, as shown in Fig.3. These are in SOIC packages with relatively widely spaced pins. After tacking one and checking the placement and orientation, you can either solder the remainder individually or apply some flux paste along the edge and drag solder the pins. Then mount Q5 (the only SOT-23 package device on the top side), then the resistors and capacitors, using the same technique as before. None of the passives are polarised. Note that the 47μF capacitor may be the same size as the others or a little larger. Larger pads are provided that suit a range of components from 2.0 × 1.2mm (imperial 0805) up to 3.2 × 2.8mm (imperial 1210). Figs.3 & 4: fit the components on the relatively compact PCB as shown here. We recommend doing it in two stages, with the first stage mostly involving fitting the SMDs, starting on the underside, plus a few of the through-hole parts. Watch the orientations of the ICs and LEDs. Practical Electronics | September | 2024 35 Constructional Project With all the SMDs in place, clean any flux residue off the top of the board, as you did for the underside, and inspect the solder joints. Next, install the five LEDs. The four 3mm through-hole types are all orientated the same way, with the shorter (cathode) leads and flat lens edges towards the nearest edge of the PCB. We pushed them down flat onto the PCB before soldering the leads to keep them neat, but you could stand them off a little if you want to. The SMD LED, LED5, is soldered similarly to the resistors and capacitors. It should have a small green dot or perhaps a T on the underside indicating the cathode, which faces towards the bottom edge of the board. If you aren’t sure, set a DMM on diode test mode and probe the two ends of the LED. When it lights up, you have the red probe on the anode and black on the cathode. The three remaining components Step 1: check continuity Mode A1 – CON1 pin 1 to SK1 pin 24 – CON1 pin 4 to SK1 pin 19 – CON1 pin 5 to SK1 pin 18 Mode A2 – CON1 pin 1 to SK1 pin 24 – CON1 pin 4 to SK1 pin 16 – CON1 pin 5 to SK1 pin 15 Mode B – CON1 pin 1 to SK1 pin 1 – CON1 pin 4 to SK1 pin 40 – CON1 pin 5 to SK1 pin 39 Mode C – CON1 pin 1 to SK1 pin 1 – CON1 pin 4 to SK1 pin 40 – CON1 pin 5 to SK1 pin 39 Mode D – CON1 pin 1 to SK1 pin 1 – CON1 pin 4 to SK1 pin 4 – CON1 pin 5 to SK1 pin 5 Step 2: check voltages Mode A1 / A2 – SK1 pins 21 (red) & 20 (black) Mode B – SK1 pins 11 (red) & 12 (black) – SK1 pins 32 (red) & 31 (black) Mode C – SK1 pins 32 (red) & 8 (black) – SK1 pins 32 (red) & 31 (black) Mode D – SK1 pins 40 (red) & 39 (black) – SK1 pins 13 (red) & 8 (black) – SK1 pins 13 (red) & 31 (black) 36 to solder at this stage are switches S1 and S2 and header CON1. Before soldering the pins, ensure the switches are fully flat on the PCB. As S1 has many fairly small pins, it’s a good idea to dab a little flux paste on each before soldering them to ensure they flow properly. Any bad joints here will cause problems later. S2’s solder lugs go into generously-­ sized slots on the PCB. The solder should flow in and quickly join them to the PCB; if in doubt, add more. We suggest using a right-angle header for CON1, with the pins sticking out over the edge of the PCB, to keep the serial programmer out of the way in use (see our photos). Still, you could use a vertical header if you want to. Testing We now have enough components mounted on the board that we can do most of the testing before fitting the ZIF socket or Pico. You can still fix problems after that, but it will be harder, so let’s test it now. Fit four tapped spacers to the corners of the board using short machine screws so it will sit flat on your desk. We used two male/female jumper wires to connect to pins 2 & 3 of CON1 for applying power to the board from a bench supply. We suggest you do similar. Be careful with the polarity; the middle pin (pin 3) is GND, while pin 2, closer to the top, is VDD. If possible, start at 0V and slowly wind it up while monitoring the current draw. It should not exceed 30mA; if it does, switch it off and check for faults. Once VDD exceeds about 1.8V, you should see LED3 starting to light. It will be pretty dim, though. LED1 will remain off as we are feeding power directly into VDD and not the 5V rail. LEDs 2 & 4 should also stay off at this stage. Wind up the voltage to about 3.8V, and you should find that LED3 switches off and LED4 switches on. Continue increasing VDD to 5.5V, at which point LED4 should be pretty bright and the circuit should be drawing around 20mA. That confirms that IC2 is functioning correctly. If something different happens, check the soldering on IC2 and its surrounding components. Check that IC2 has been installed the right way around and that the surrounding component values and types are correct. Also check the orientations of the LEDs. Assuming that’s fine, wind the supply back to 3.3V. We are now ready to check all the routings for programming chips in the five different modes. To help you do this, we’ve added ZIF socket pin numbers to the top of the PCB since building the prototype. While you could work out the connections based on Figs.1 & 2, to make things easier, here are all the connections you need to probe. We’ll start with MCLR, PGD and PGC. Set a DMM to continuity test/buzzer mode (or low ohms if your meter doesn’t have such a mode) and then check that all the pin pairs in the Step 1 box are connected in each mode, set using S1 & S2. If any of these lack continuity or have a resistance reading above 1W, that suggests a bad solder joint on CON1, S1 or S2, so check those. They are the only components making those connections. The only other problem could be a faulty PCB, but that’s very unlikely. Still, if you’ve ruled the other parts out, you will have to trace the tracks and check them. Next, we check that GND and VDD are fed to the correct pins in each mode. Set your DMM to measure volts (eg, 20V range or similar) and then probe the pairs of pins in the Step 2 box in each mode. In each case, you should get a steady 3.3V (or whatever the exact voltage you are applying to the circuit is). If any of those are wrong, look for soldering or component placement problems with IC1 and the components like Mosfets, diodes & resistors associated with the problematic pin(s). Finally, measure the capacitance between pins 32 and 31 with it still set to mode D. You should get a reading close to 47uF. If you don’t have a suitable meter, check the voltage between pins 32 and 31. It will likely be around 1.8V, slowly dropping as the capacitor discharges through your meter. If it’s near 0, switch to mode C and back to mode D (LED5 should light briefly), then check again. If you measure more than 2V between pins 32 and 31, something is wrong with the protection circuitry involving LED5, so check its orientation and soldering, and the soldering of its 4.7kW series resistor. Finishing it Remove the spacers from the corners of the board and solder switches Practical Electronics | September | 2024 New PIC Programming Adaptor S3, S4 and S5 in place, making sure they are pushed all the way down and neatly aligned and vertical (solder one pin, check, then solder the rest). That leaves SK1 and the Pico (or USB socket CON2 if you aren’t using the Pico). If not using the Pico, solder CON2 now, checking that its small pins are correctly aligned with their pads before soldering the four through-hole mounting tabs. Then solder the signal pins, being careful not to bridge them (use flux paste and wick to fix it if you do) as they are very close together. Mounting the Pico is a little tricky since one of its rows of pins is opposite the ZIF socket. The ZIF socket has only about half a millimetre of clearance between its plastic body and the top of the PCB, and we’ve used throughhole headers for simplicity. Luckily, it isn’t all that hard to work with this arrangement. Our solution is as follows, although we’ll mention another possibility later. We started by inserting two low-­ profile 20-pin female headers into the rows of Pico pins on the underside of the board. Then we inserted two 20-pin regular male headers with the short sides into those sockets and placed the Pico on top, with the longer pins going through its pads. The Pico’s USB socket faces away from the main board (see the photos). We then pushed the two sockets fully onto the PCB and made sure they were perpendicular to it before soldering all their pins. After that, we soldered the headers to the pads on top of the Pico. Note that you could solder the headers in the usual manner – with the short pins on the Pico side – but then the headers will not fully insert into the low-profile sockets. A neater option would be to use lowprofile headers on the Pico, allowing you to use slightly shorter (eg, 12mm) spacers as feet for the board. The trick now is to use a pair of sharp sidecutters to snip all the header socket solder joints as close to the PCB as possible that will be under the ZIF socket. Don’t cut the whole solder joint off but try to keep each one to a maximum of around 1mm above the top of the board. You can then insert the ZIF socket into its pads (straightening its pins if necessary). It won’t quite push down all the way, but all its pins should go through the PCB and stick out the other side by about 1mm, which is enough to solder them comfortably. You might Practical Electronics | September | 2024 Parts List – PIC Programming Adaptor 1 double-sided PCB coded 24105231, 65.5 × 66mm 1 6-pin header, straight or right-angle (recommended), 2.54mm pitch (CON1) 1 Raspberry Pi Pico (MOD1) (optional; alternative power supply parts are listed below) 1 40-pin universal ZIF socket (SK1) 1 4P4T vertical PCB-mount slide switch (S1) [SS-44D02-G10] 1 DPDT sub-miniature vertical solder tag slide switch (S2) [Jaycar SS0852, Altronics S2010] 3 SPDT micro vertical slide switches (S3-S5) [Jaycar SS0834] 4 M3-tapped 15mm hex spacers (can be 12mm if low-profile headers are soldered to Pico) 4 M3 × 6mm panhead machine screws 2 20-pin low-profile female headers, 2.54mm pitch (for MOD1) 2 20-pin headers, 2.54mm pitch (for MOD1; ideally low profile but regular headers will work) Semiconductors 1 74HC04 hex CMOS inverter, SOIC-14 (IC1) 1 LM393 dual single-supply comparator, SOIC-8 (IC2) 5 AO3400 logic-level, low Rds(on) N-channel Mosfets, SOT-23 (Q1-Q5) 4 AO3401 logic-level, low Rds(on) P-channel Mosfets, SOT-23 (Q6-Q9) 1 2N7002K logic-level N-channel Mosfet, SOT-23 (Q10) 1 BSS84 logic-level P-channel Mosfet, SOT-23 (Q11) 4 3mm LEDs with diffused lenses; blue, green, red & yellow (LED1-LED4) 1 SMD high-brightness red LED, M3216/1206/SMA package (LED5) 5 BAT54A dual common-anode schottky diodes, SOT-23 (D1-D5) 1 BAV99 dual series signal diode, SOT-23 (D6) 1 100mA PTC thermistor (PTC1) [eg, 1206L050YR] Capacitors (all SMD X7R ceramic, M1206 or M0805 size unless noted) 1 47μF 6.3V X5R or X7R, M3226/1210, M3216/1206 or M2012/0805 size 7 100nF 1 100pF Resistors (all SMD 1%, M3216/1206 or M2012/0805 size unless noted) 2 100kW 1 22kW 1 5.6kW 1 10MW 5% 1 1MW 2 4.7kW 1 1kW 3 470W 2 22W 6 5.1kW Parts for optional USB power supply 1 SMD micro-USB socket (CON2) 1 MCP1700T-3302E/TT 3.3V low-dropout linear regulator, SOT-23 (REG1) 1 10μF 6.3V X5R or X7R ceramic capacitor, M3216 or M2012 size 1 100nF 50V X7R ceramic capacitor, M3216 or M2012 size Optional SMD adaptor recommendations Narrow SOIC (0.15”), 8-16 pins [AliExpress; pemag.au/link/ablr] Wide SOIC (0.3”), 20-28 pins [AliExpress; pemag.au/link/abls] MSOP-8 [AliExpress; pemag.au/link/ablt] SSOP-28 [AliExpress; pemag.au/link/ablu] TSSOP-28 [AliExpress; pemag.au/link/ablv] (unsuitable for SSOP, despite what the description says!) want to put ~1mm shims under it at both ends so it’s sitting evenly, although we evened it up by eye. Optionally, add a little flux paste onto the ZIF socket pads before soldering all 40 pins. That will ensure the solder flows smoothly and wicks into the throughholes around the pins, giving a solid mechanical and electrical bond. The other option we considered, which is a bit simpler, was first fitting SK1 pushed all the way down, then soldering headers to the Pico in the usual way. It is then possible to insert those headers into the PCB pads until they touch the underside of the ZIF socket, making sure it is parallel to the main PCB, then solder them from the side. However, that will make the Pico captive. We purposely avoided putting any components under the Pico, so that is not unreasonable, but half the ZIF socket solder joints will be inaccessible. So you’ll want to ensure they are all good before doing that. 37 Constructional Project The PIC Programming Adaptor can be used with a variety of SMD-to-DIP adaptors, allowing you to program SMD chips. For example, the adaptors shown above plug directly into the 40-pin ZIF socket. The adaptor on the right is actually for an ATmega328; we’ll have more on programming SMD chips in next month’s issue. Only pins 2, 36, 38 & 39 of the Pico need to be soldered. All the GNDs are connected on the board, but one (eg, pin 38) is sufficient. So you could solder just those pins, allowing you to desolder it later if necessary. Finally, reattach the spacers to the corners of the board to act as feet. Final testing You can now plug the board into your computer via a USB cable and check that LED1 lights. Switch on S4, and either LED3 or LED4 should light, depending on the position of S3. Switching S3 should alternate between LED3 on/LED4 off and LED4 on/LED3 off. You can now test program a chip. Switch it off, select the appropriate mode and put the chip in the ZIF socket. Plug your serial programmer into CON1 and ensure S3 is set to the appropriate voltage (3.3V is safe). Set S5 off, then switch on target power with S4. Check that your programming software can connect to, program and verify the chip. If you are using the Pico, program it (if you haven’t already) by downloading the firmware package (see the link at the end of the item opposite) and copying the .uf2 file onto the virtual drive that appears when the Pico is first plugged into your comluter. With the Pico programmed, switch off the target power and set S5 on to test the mouse clicker. Put your computer’s mouse over something that will let you know if it’s clicked, then switch S4 on. Your computer should act like the mouse was clicked. Using it It’s pretty straightforward, but we have a few hints. Firstly, you might SC6774: a complete kit is available from the Silicon Chip online shop. It includes the Pi Pico, but does not include the optional USB power supply parts. 38 want to stick a rubber foot to the underside of your serial programmer or place something about 12mm thick under it, so it doesn’t try to pull the board over. While you can change the mode with the target power on, doing that with it off is safer. Don’t change the mode with the target power on if there’s a chip in the ZIF socket. In general, it’s best to fully set up the programming rig before inserting a device to program. All the chips we tested can be programmed at 3.3V, so you can generally leave S3 on that setting. That way, you won’t accidentally apply 5V to a chip with a maximum 3.6V rating. Some older chips that are compatible with this board need 5V for programming; if doing that, we suggest changing back to 3.3V immediately afterwards to be safe. If you change to mode D with the power on, ensure LED5 is not illuminated before inserting a device in the ZIF socket. You might notice LED5 glowing very dimly with target powered enabled in mode D; that is normal. If programming several chips using Microchip MPLAB IPE, after you’ve used the Connect button to let the programmer identify the first chip, hover the mouse cursor over the “Program” button, then switch on the target power. It should trigger programming almost immediately. When that finishes, switch off the target power, remove the chip, insert the next one, and switch the target power back on. Repeat as needed. If you have a PICkit, you can let it power the target chips. In that case, you will need to Disconnect/Reconnect each time so that you aren’t pulling a chip out of the ZIF socket while it’s powered. When powering the target from the PICkit, leave S4 off. Programming SMD chips You can also use this Adaptor to program compatible chips with up to 28 pins in packages like SOIC, MSOP, SSOP and TSSOP. To do that, you need the appropriate SMD-to-DIP adaptor (also known as “test sockets”). They are not overly expensive, but you may need a few different types. Some we recommend are in the parts list; here are more details: 1. A 28-pin TSSOP adaptor will let you program any TSSOP chip we have come across, from 8 pins to 28 pins, although the common pin counts for TSSOP chips are 14, 20, 24 or 28 pins. 2. Similarly, a 28-pin SSOP adaptor will let you program any SSOP chip. While TSSOP and SSOP are very similar, they are not the same width, so you can’t program an SSOP chip in a TSSOP socket and probably can’t do the reverse. 3. Some 8-pin PICs are available in the even smaller MSOP package. For those, you will need an MSOP-­specific socket. 4. SOIC/SOP chips come with 8 to 28 pins and, unfortunately, in different widths. Most chips below 16 pins are 0.15” (3.8mm) wide, while most chips from 20 to 28 pins are 0.3” (7.6mm) wide. 20-pin chips can come in either width. The sockets in the parts list suit these two widths, but be aware that 0.2” (5.1mm) wide SOIC/SOP chips also exist. Coming up Programming other SMD chips out of circuit, like SOT-23-5/6, TQFP32/44/48/64/100 and others is possible, but it is less commonly required than the DIP and SOIC chips this Adaptor can handle. Still, we need to do it as we sell those chips programmed, and some readers may want to do that as well. We have designed suitable rigs, and they are not easy to find commercially (or at reasonable prices). So we will have an article next month explaining how to program various types of micros (PICs, AVRs and others) in those packages. PE Practical Electronics | September | 2024 Circuit Notebook - Mouse Clicker Automatic mouse clicker This ‘circuit idea’ was originally presented in the “Circuit Notebook” section of Silicon Chip magazine. We are reproducing it here to aid in understanding how the PIC Programming Adaptor sends ‘mouse click’ events to the host computer when it detects that the target microcontroller power supply becomes active. When programming lots of microcontrollers, we go through the same process many times. We insert the chip in the socket, apply power, switch to the computer, click the Program button, verify it was successful, then go back to the programming board, switch off the power and remove the chip. We thought it’d save a lot of time if we didn’t have to switch between the programming board and the computer; ideally, the computer would click the ‘program’ button for us as soon as power was supplied to the chip. This very simple circuit can do that. It takes advantage of the Raspberry Pi Pico’s ability to emulate a mouse. It isn’t just for programming micros; any time you need to click a button on a computer in response to an external stimulus, this circuit could do it. We used the Arduino IDE to produce a program for the Pico that ‘clicks’ the left mouse button when triggered. The trigger is simply an I/O pin configured as an input with an internal pull-up or pull-down. The click is triggered when the pin is pulled low or high (depending on the configuration) and stays that way for 300ms. The Pico waits for the state to reset before getting ready to trigger again. In our case, we use the fact that power is switched to the chip to be Practical Electronics | September | 2024 programmed as the trigger. The 300ms delay also ensures that the micro’s power stabilises before starting the programming process. The resistor circuit is sufficient if the computer powers the programming rig. You may not need to connect pin 3 if the Pi Pico and programmer are powered from the same computer, as the grounds will be common. The resistor ensures that a voltage mismatch does not cause damage. In this case, use the “POWER_ CLICK_2_RESISTOR.uf2” firmware file. The GP1 pin (pin 2) is set as an input with an internal pull-down. The positive and negative wires are connected to the target chip’s power pins for sensing. The Pico’s USB socket is connected via a USB lead to the computer that needs to be ‘clicked’. This method activates when around 1.5-2V is present on the positive wire. We also tested a version using a 4N25 opto-coupler for more robust isolation. Here, we’ve configured GP1 as an input with an internal pull-up. When sufficient current flows through the 4N25’s LED via the 1kW current-­limiting resistor, its output transistor turns on, pulling GP1 low. This arrangement triggers at similar voltage levels and should have no trouble dealing with inputs up to 15V. This circuit requires the “POWER_ CLICK_2_OPTO.uf2” firmware file. We don’t recommend using any of these circuits for anything above 15V, and certainly not with mains power. If you don’t need power sensing and just want to trigger a mouse click with a pushbutton or similar switch input, the third switch circuit will also work with the “POWER_CLICK_2_OPTO. uf2” firmware. In this case, the pushbutton pulls the GP1 pin to ground, similarly to the opto-coupler. We’ve included the Arduino code with our downloads for this design. If you are familiar with the Arduino IDE, you can use it to modify and upload the code to the Pico. If you don’t have the IDE or want to use the firmware as is, then hold the BOOTSEL button on the Pico while plugging it into the computer. A virtual flash drive (named ‘RPI-RP2’) should appear, and you can upload the firmware by simply copying the appropriate UF2 file to it. If you are using the OPTO version, you can test it by shorting pins 2 and 3 (GP1 and GND) on the Pico, remembering to account for the delay. This should have the same effect as clicking your mouse. Besides the programming rig mentioned above, another possible use for this circuit is a 21st-century update on the Map Reader from Silicon Chip, March 1989 (siliconchip.au/ Article/7516). It used a cheap pocket calculator to count pulses from a photointerrupter attached to a wheel to measure distances on a map. With our Clicker circuit and the Calculator application in Windows, we could get the same effect by entering “1+” in the calculator and then positioning the mouse pointer over the “=” button. Each click then increments the count. You can download the firmware for the automatic mouse clicker from https://pemag.au/Shop/6/116 PE Tim Blythman, Silicon Chip. 39