Silicon ChipPICn’Mix - January 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: Nutube by John Clarke miniature valve stereo preamplifier by John Clarke
  11. Project: Complete Arduino DCC Controller by Tim Blythman
  12. Project: Using Cheap Asian Electronic Modules by Jim Rowe
  13. Feature: KickStart by Mike Tooley
  14. Feature: PICn’Mix by Mike Hibbett
  15. Feature: AUDIO OUT by Jake Rothman
  16. Feature: Make it with Micromite by Phil Boyce
  17. Feature: Interference and noise by Ian Bell
  18. Feature: Max’s Cool Beans by Max the Magnificent
  19. Feature: Visual programming with XOD by Julian Edgar
  20. Advertising Index: Max’s Cool Beans by Max the Magnificent
  21. PCB Order Form

This is only a preview of the January 2021 issue of Practical Electronics.

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

Articles in this series:
  • (November 2020)
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
  • Techno Talk (June 2025)
PIC n’Mix Mike Hibbett’s column for PIC project enlightenment and related topics Part 3: PIC18F development board W e continue this month with  Flexible – the ability to select which Simplifying soldering the process of creating a development board for the PIC18F processor. In this and the following article we are going to cover the design of the board, ensuring it supports a number of different externally connected technologies: GPS location, digital compass, various display types, speech output, connectivity to a PC connection via USB, Wi-Fi communication, interfacing with Amazon Alexa, servomotor control and analogue input. The focus for this article series will be on making use of the processor, rather than diving into the finer details of internal processor peripherals – a hands-on, practical approach. In the previous article we selected the processor we will be using – the PIC18F47K42 in a 40-pin DIL package. We chose that package because it provides lots of I/O signals yet is very easy to solder (via a 40-pin socket) making it easy to replace if damaged. There is a lot of work to do before we jump in and start designing a PCB. Even before drawing the schematic, we need to be clear in our objectives for this board, writing down some requirements, and check if any of our items might clash with each other and (hopefully) find solutions to those issues. Let’s start by writing down our key requirements:  Easy to assemble – no tiny surfacemount soldered parts. We want this to be easily assembled, by any hobbyist features are fitted at any one time, without major re-work  Re-usable – easy to re-purpose to different projects  PC serial communications interface using an on-board UART-to-USB converter chip, the MCP2221A-I/P  Header connector for an ESP-01 Wi-Fi interface  Header for a Micro SD Media card module  Several three-pin headers for servomotors  Header for a colour touchscreen LCD  FET power switches for external device control  PICkit 4 header for programming/ debugging  Header pins for external devices with power and I2C or SPI buses  Two configurable op amps, for analogue input signal conditioning  32kHz crystal for very low-current operation  Plenty of analogue input and digital I/O headers  Single status LED, and a power LED  Power input from a standard DC power brick. The first requirement is driven by a desire to enable this board to be built by as many hobbyists as possible, avoiding the use of difficult-to-solder surface-mount parts. This is easy to achieve with most components, but the USB and SD Media connectors are only available in hard-to-solder formats. Thankfully, this has been recognised by a number of electronics suppliers who provide very simple and low-cost preassembled carrier boards, as shown in Fig.1 and Fig.2. We will also use a Wi-Fi module with a similar simple header interface (shown in Fig.3). These little boards enables us to avoid the difficulty of soldering ICs that are only available in surface-mount format. Another benefit of providing these as plug-in features is that they are optional – buy them only if you want to use them. On our PCB, USB connectivity to a PC is provided by a special IC, the Microchip MCP2221A-I/P. Our processor does not have USB built in, and the choice to use an external IC rather than choose a processor with a USB peripheral is deliberate – in our experience the USB software libraries provided by Microchip (and other vendors) are very complicated to use. The MCP2221A provides a simple USB-to-UART conversion, so our processor we will connect the IC to one of our serial ports, and the USB cable will look to the PC like a standard serial port. This will make software development Fig.1. USB connector board. Fig.2. SD-Media connector board. Practical Electronics | January | 2021 That’s quite a list, but many of these will be easy to implement, and simply remind us to include certain components in the schematic. Many requirements have a consequence – adding a 32kHz crystal, for example, means that two GPIO pins become unavailable. Fortunately, however, there are many GPIO pins, so that won’t be an issue for us. Fig.3. Wi-Fi interface board. 43 comes pre-loaded with software that is easy to use and communicates with our processor over one of the UART interfaces (we have two UARTs on our processor, so simultaneous Wi-Fi and USB connectivity will be possible.) Power supply design Fig.4. Plug-in option boards. on both the PC and the processor simple. Plus, the MCP2221A can run at 3.3V or 5V, so it’s very flexible. An SD Media card communicates over an SPI interface, so we will route one of the SPI buses to it. SD Media cards operate at a voltage of 3.3V maximum, so bear that in mind if you are thinking of running your board at 5V. An external adaptor to level-shift the signals will be required if you want to use an SD Media card for data storage and run the board at 5V simultaneously. This will be true for the Wi-Fi interface too. The downside of using standard components in a design like this is that the PCB will larger than the more usual Microchip development boards, which use tiny surface-mount components. This is not really a big issue – the board is for development purposes, so easy soldering and easy access to components is more important than size. Plug-in options Although this will be a general-purpose development board, we do have in mind some external devices that we would like to be able to connect to it. Fig.4 shows the current selection from our lab – An LED matrix, touch-input colour LCD screen, GPS module and a bag of over 30 different random sensors that were purchased cheaply on eBay. We will provide links for the parts used in upcoming articles, as we make use of them. Needless to say, these will just be examples, you are free to attach whatever you want to your board. Wi-Fi interface Choosing a Wi-Fi interface board presented some interesting challenges. The board has to be cheap, easy to purchase, easy to solder and easy to use. We settled on a relatively old device, the ESP-01, which is based on the ESP8266 processor. This is such a popular design that it has become available from dozens of different suppliers and is incredibly cheap – as low as £3 including delivery, if you do not mind the long delivery times from Asia. The module 44 With those thoughts behind us, it’s time to make our first key design decisions – how will we power the board, and how will we direct the processor’s 36 I/O pins to onboard and external connections? We’ll start with the power supply design. So, first, we must decide at what voltage to run the board: 3.3V or 5V? These two common operating voltages have for years been a bone of contention for us, too often we have tried to pair a 5V external device with a 3.3V processor development board (servomotors with a Raspberry Pi for example) or a 3.3V module with a 5V processor board (a GPS module with an Arduino, for example.) It’s been such an issue over the years that we have decided to design a board that can operate at either voltage, selected by a simple jumper. The key ICs in our design have been selected as ones that can operate at either voltage, so we only need a power supply design that can be switched between the two voltages – and we can do that with an LM317 regulator and a few resistors. We will use a beefy TO220-style regulator, as powering some external devices, particularly servo motors, may bring our current-consumption requirements up to around 500mA or so. Plus, we make a mental note: leave space around the regulator for heatsinking, the LM317 is a linear regulator, and will get warm at these higher currents. We could have gone with a much more efficient switching-regulator design, but that would add complexity. We will typically be powering this board from a wall socket power supply, so power supply efficiency is not a design requirement. Studying the datasheet of the LM317 we spot that is has a requirement for a minimum 3V input to output voltage differential, so to generate a 3.3V or 5V output will require an input power supply running at a minimum of 8V DC. 9V and 12V DC power supplies are common and cheap, so the regulator choice works well. We will include a power supply isolation header pin, so 3.3V or 5V can be supplied to the board directly, if desired. This will enable the testing of low-power designs, or allow the addition of a more efficient power supply should you want to use a battery. A barrel jack will be accommodated to support plugging in a standard DC power brick. There are several different standards for barrel jack connectors (different pin diameters) so we have to make a decision on which to go with – we chose the 2.5mm P I C 18 F 4 7 K 4 2 MC LR / R E3 1 4 0 R B 7 R A 0 2 39 R B 6 R A 1 3 38 R B 5 R A 2 4 37 R B 4 R A 3 5 36 R B 3 R A 4 6 35 R B 2 R A 5 7 34 R B 1 R E0 8 33 R B 0 R E1 9 32 VDD R E2 10 31 VSS VDD 11 30 R D7 VSS 12 29 R D6 R A 7 13 28 R D5 R A 6 14 27 R D4 R C 0 25 26 R C 7 R C 1 16 25 R C 6 R C 2 17 24 R C 5 R C 3 18 23 R C 4 R D0 19 22 R D3 R D1 20 21 R D2 Fig.5. PIC18F47K42 processor pin-out. version, as that seemed to be the most common size in our lab. Header pins and solder pads will also be provided for power input, as these cost nothing but add flexibility to the choice of power connection. External header pins We have left the most complex design decision until last. The processor, shown in Fig.5, has 36 I/O pins – how will we connect these? Thankfully, the pins are highly configurable; internal peripherals such as SPI, I2C and UART interfaces are all able to be programmed to appear on any pin from a selection of the 36 pins available. While this simplifies circuit design and PCB layout, it does add complexity during software design. With a general-purpose development board design, where we make all pins available, this task is very complicated – but that task can be simplified by writing up a spreadsheet for the pins, indicating where each one will go. The approach taken here is that multiple headers are provided for generic SPI and I2C devices, several servomotor headers (using the standard header layout) and specific headers for the Wi-Fi, USB and Micro SD Media boards. Two FET-controlled power output headers are provided, and then all I/O pins will go to 0.1-inch pitch header strips. Even the I/O signals that are optionally connected to other headers on the board will be routed to the generic I/O headers. Three I/O pins will not be used. PORTE.3 is shared with the master reset pin MCLR, which we will keep as a reset pin. PORTC.0 and PORTC.1 are multiplexed with the external crystal inputs, which will be taken up with our 32kHz crystal, for ultra-low power operation. To finish off, two op amps will be implemented on the board, but left unconnected, with headers to allow user choice of where they connect. Practical Electronics | January | 2021 GP I O 6 ( UA R T 2) GP I O 7 ( UA R T 2) W i- F i GP I O 4 ( UA R T 2) US B GP I O 18 ( P W M) O p am p S ervo GP I O 5 ( UA R T 2) GP I O 8 GP I O 9 O p am p GP I O 10 GP I O 11 GP I O 19 ( P W M) I 2C S ervo GP I O 29 ( I 2C 1) P ower input GP I O 30 ( I 2C 1) GP I O 12 ( S P I 1) GP I O 20 ( P W M) S ervo GP I O 13 ( S P I 1) Micro- S D Media card GP I O 12 ( S P I 1) GP I O 14 GP I O 15 I 2C A dditional power headers GP I O 29 ( I 2C 1) GP I O 30 ( I 2C 1) GP I O 1 GP I O 16 GP I O 2 GP I O 12 ( S P I 1) F ET F ET GP I O 3 S tatus LED GP I O 21 P O R T C 0 GP I O 22 P O R T C 1 32kH z crystal GP I O 12 ( S P I 1) S P I GP I O 13 ( S P I 1) GP I O 14 ( S P I 1) GP I O 13 ( S P I 1) GP I O 14 ( S P I 1) LC D MC LR GP I O 23 GP I O 24 GP I O 25 ( A DC ) GP I O 26 ( A DC ) S P I GP I O 12 ( S P I 1) P O R T B 7 GP I O 13 ( S P I 1) P O R T B 6 Deb ug GP I O 14 ( S P I 1) GP I O 27 ( A DC ) GP I O 28 ( A DC ) Fig.6. High-level schematic, focusing on the I/O signals. A standard PICkit 4 8-pin header will be included for programming and debugging. Working with the above specification, a high-level circuit design focusing on the I/O signals can be drawn, shown in Fig.6, which shows all the required signals, without specifically naming them. From this diagram we can now work through mapping processor pins to the diagram. This is a bit tedious and is best done by writing down a simple spreadsheet listing the pin numbers and their use, confirming for each pin that a chosen peripheral can be mapped to the desired pin. The resulting pin mapping is shown in Fig.7. High-level design – done! Having worked through those requirements, and followed the thought process discussed above, we have arrived at a clear high-level design. At this stage, we have no further questions to answer – the schematic can be drawn up, and a board layout created, with the risk of unexpected issues cropping up significantly reduced. Finishing touches Before getting to the PCB layout we note a few addition requirements that we want to capture. Four holes in the PCB corners will be provided for the mounting of simple feet. 3.4mm-diameter holes will be used to allow the use of cheap M3 bolts to be used, but there will be space for off-theshelf rubber feet. Space will be left around the LM317 voltage regulator to allow for a small heatsink, should your attachments require large currents. The silk screen of the PCB will provide clear pin labels for each header pin. This is an important requirement and will increase the size of the PCB slightly as space beside the header pins will be needed to allow the text to be visible. Although it will not impact the PCB design, it’s worth noting that all ICs (the processor, the USB interface IC and the op amp) will be fitting using sockets. Although this adds a few pounds to the cost, it will make the board easier to repair should accidents happen. You are of course free to ignore this advice! That’s all the hard work completed – now to the PCB design itself, which we will pick up in the next article. References Micro SD-card holder www.pololu.com/product/2597 Wi-Fi interface www.addicore.com/ESP8266-ESP01-p/130.htm USB Micro-B connector www.pololu.com/product/2586 Fig.7. I/O pin mapping. Practical Electronics | January | 2021 LED Display www.ebay.co.uk/itm/191736670249 45