Silicon ChipKickStart - August 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: Ol’ Timer II by Tim Blythman
  11. Project: Low-cost, Wideband Digital RF Power Meter by Jim Rowe
  12. Project: Switchmode Replacement for 78xx regulators by Tim Blythman
  13. Feature: KickStart by Mike Tooley
  14. Feature: Microphone Preamplifier (for Vocoder) – Part 4 by Jake Rothman
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: Circuit Surgery by Jake Rothman
  17. Feature: Max’s Cool Beans by Max the Magnificent
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the August 2021 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)
KickStart b y M ik e To o l ey Part 4: Introducing the Arduino Pro Mini Our occasional KickStart series aims to show readers how to use readily available low-cost components and devices to solve a wide range of common problems in the shortest possible time. Each of the examples and projects can be completed in no more than a couple of hours using T he Arduino has undoubtedly become immensely popular with PE readers because it can provide a highly effective solution to a wide range of problems at minimal cost. To cater for differing requirements, several versions of the Arduino have become available, making it possible to integrate the microcontroller into systems of virtually any size. What’s on the board? The most popular Arduino version is undoubtedly the Uno, but for smaller applications, particularly where there is no need for a resident USB interface, this can be overkill. The Arduino Pro Mini puts this right by providing an off-the-shelf parts. As well as briefly explaining the underlying principles and technology used, the series will provide you with a variety of representative solutions and examples along with just enough information to be able to adapt and extend them for their own use. This fourth instalment shows you how to make use of the diminutive Arduino Pro Mini and, in keeping with the KickStart philosophy, we’ve provided sufficient information for you to be able to start making use of this tiny microcontroller in your own projects. attractive alternative in a tiny postagestamp-sized package. Like its big brother (see Fig.4.1), the Pro Mini contains virtually everything that you need to implement a complete microcontroller system. The only additional items are a power source and a means of connecting a programming device via a serial interface and a USB cable. The Pro Mini will operate quite happily from nothing more than a 3.7V or 9V battery, making it ideal for use in stand-alone applications where there’s no mains supply available. Alternatively, the Uno can derive its power from an external DC source of between 5V and 12V, or via an external USB adapter and a powered USB port. The Pro Mini provides a total of 14 digital input/output lines, together with six analogue inputs. Where necessary, signals on six of the 14 digital I/O lines can make use of pulse-width modulation (PWM) to effectively generate analogue outputs. The Pro Mini’s technical specification is shown in Table 4.1. ATmega328P processor The Pro Mini is based on the same ATmega328P processor as the Arduino Uno, and this ensures there is a high degree of software and hardware compatibility. The processor has 32kB of Flash memory used for storing program code (of which 2kB bytes is reserved for bootloader code). The Pro Mini’s chip Fig.4.1. Members of the Arduino family include (let to right) the Uno, Nano and the diminutive Pro Mini. 40 Practical Electronics | August | 2021 Table 4.1 Technical specifications for the Arduino Pro Mini conditioning the PWM outputs can be used to generate quasiFeature Specification Notes analogue output voltages. The processor also incorporates a sixThis is the same processor that is channel, 10-bit analogue-to-digital Processor ATmega328P currently fitted to the Arduino Uno converter (ADC) and incorporates a variety of communications ports The 3.3V has an 8MHz clock, while Clock speed 8MHz or 16MHz including a programmable serial the 5V version operates at 16MHz USART, an SPI serial interface Flash memory 32kB 2kB bytes used for the bootloader and a byte-oriented 2-wire serial I 2 C-compatible interface. As a Static RAM (SRAM) 2kB Early versions had 1kB bonus, the chip also incorporates EEPROM 1kB Early versions had 512 bytes a programmable watchdog timer. The ATmega328 has a total 3.3V or 5V depending Supply voltage (Vcc) of 23 input/output (I/O) lines. on version Before we expand on what these 3.35V to 12V for the Please note the RAW power input can do, it is important to be aware Raw input voltage (pre-regulated) 3.3V version; 7V to needs 50mV headroom for the 3.3V that ATmega328 I/O lines can be 12V for the 5V version version (and 2V for the 5V version). software configured for different functions. As an example, the Six digital I/O pins can be used for port line labelled PB3 (ie, Port Digital I/O pins 14 PWM with 8-bit resolution B, bit 3) provides Master data output and Slave data input Analogue input pins 6 when the chip is configured for Maximum output current (per pin) 40mA 150mA maximum total output current use with the Serial Peripheral Interface (SPI) bus. Alternatively, Absolute maximum current 200mA it can be configured to provide an External interrupts 2 Inputs from external hardware external output for the PWM timer Operating temperature range −40°C to +105°C function or as an external interrupt source. This may sound a little Dimensions 18 × 33mm complicated at first, but it does Weight Less than 2g make a significant contribution to the chip’s wide applicability and immense versatility. pre-scaler and compare mode, and one also has 2kB of static random-access 16-bit timer/counter with a separate memory (SRAM) and 1kB of electrically pre-scaler. The chip incorporates erasable programmable read-only Pro Mini Port B six pulse-width modulated (PWM) memory (EEPROM). Port B is an 8-bit bi-directional I/O channels available from a subset of The ATmega328 incorporates two port with internal pull-up resistors digital I/O pins. With appropriate signal 8-bit timer/counters with separate (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high-sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tristated when a reset condition becomes active, even if the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as input to the inverting oscillator amplifier or input to the internal clock operating circuit. In the same manner, PB7 can be used as output from the inverting oscillator amplifier. If the internally calibrated RC oscillator is used as the chip’s clock source, PB6 and PB7 are used as inputs for the second asynchronous timer/counter. Pro Mini Port C Fig.4.2. Pro Mini board layout showing main components and connectors. Practical Electronics | August | 2021 Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The PC0 to PC5 output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated 41 when a reset condition becomes active, even if the clock is not running. PC6 can be fuse programmed for use as an I/O pin or to function as a RESET pin. In the latter case, a low level held briefly on this pin generates a reset. Pro Mini Port D Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high-sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Using the Pro Mini I/O The I/O features and capability are very similar to those offered from a standard Arduino Uno, but there are some notable differences in relation to the pinout configuration and headers, as shown in Fig.4.2. Each of the 14 digital pins (see Fig.4.2) on the Pro Mini can be configured as a digital input or output by using the appropriate C functions: pinMode() digitalWrite() digitalRead() The digital I/O lines operate at standard TTL-compatible levels and each of the I/O pins can source or sink a maximum current of 40mA. Internal pull-up resistors of around 20 to 50kΩ can be selected where necessary. Note that the internal pull-up facility is disabled by default. As previously mentioned, it is important to be aware that many of the Pro Mini’s digital I/O lines also have specialised functions. provide quasi-analogue outputs using the analogWrite() function. Serial SPI communication using pins 10, 11, 12 and 13 These four pins support SPI serial communication by providing SS, MOSI, MISO and SCK signals respectively. User LED pin 13 As well as the red LED power indicator, a separate user LED is available at pin 13. When the pin is taken HIGH, the LED will be on and when LOW the LED will be off. The user LED provides a handy way of visually testing simple I/O code routines without the need to connect an external indicator. Analogue I/O In addition to the 14 digital I/O lines, the Uno has six analogue inputs, each of which provide 10 bits of resolution (ie, 210 = 1024 different values over a range extending from 0V to +Vcc). I2C communication using pins 27 and 28 Analogue I/O port lines 4 and 5 (pins 27 and 28 respectively) can be used to provide access to the SDA and SCL signals respectively, which facilitate the two-wire interface (TWI or I2C). Note that these two signals are available on off-grid pads located away from the three main headers (see Fig.4.2). Pro Mini Pinout The Pro Mini’s pinout connections are shown in Fig.4.2. For clarity we have colour coded the signal lines into different groups, as follows: PRO MINI PADS (grey) These correspond to the silk screen markings on the upper (component) side of the Pro Mini’s PCB ARDUINO UNO (light green) These are the corresponding pin identifications for the standard version of the Arduino Uno. ATmega328 (blue) T hes e ar e the processor’s port designations SPI (lilac) These connections are for use with SPI (Serial Peripheral Interface) devices I2C (pink) These connections are used with ‘twowire’ I2C interface devices POWER SUPPLIES (red) These connections provide access to the internal and external supply rails as well as common 0V/Ground RESET (yellow) This is connected to the Pro Mini’s reset line USER LED (green) This digital I/O line can be used to provide a simple ‘user LED’ indication. It is worth noting that versions of the Pro Mini may have slightly different layouts and pin markings. This is particularly applicable to the location and marking of the four off-grid pads. The version shown in Fig.4.2 is, however, currently the most common. Connecting to the Pro Mini As with other members of the Arduino family, the Pro Mini’s processor is supplied with bootloader code that will let you upload new code to it without the use of an external hardware programmer. This makes the process of developing and downloading code very Serial I/O pins TXO and RXI These two pins can be used for serial communication. The same pins are also made available on the six-pin header to which an FTDI serial-to-USB interface can be attached in order to facilitate downloading and debugging of code. Interrupt pins 2 and 3 These two pins are available for use with external interrupts. They can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. The attachInterrupt() function can be used to configure the interrupt feature. Pulse width modulation (PWM) using pins 3, 5, 6, 9, 10, and 11 These six lines can be used to provide outputs that are pulse-width modulated (PWM). This feature can be used to 42 Fig.4.3. Two different serial FTDI interface boards for use with the Arduino Pro Mini. Practical Electronics | August | 2021 simple and all you will require is the services of a serial USB interface that will connect to the Pro Mini’s FTDI header (see Fig.4.2). Note, however, that different version of the Pro Mini may have a different FTDI header orientation (see Fig.4.3) and so, if you intend to mate the two directly with headers it is important to check before connecting the interface. The process of establishing a connection via an FTDI serial adapter to a programming device such as a PC is as follows: 1. Connect the FTDI serial interface to the Pro Mini via the six-way header, ensuring that the connections are correctly made. 2. Connect the FTDI serial interface via a USB cable to the host PC. 3. Check that you have the correct virtual COM port (VCP) drivers installed for the FTDI interface. These may install automatically, or you may Listing 4.1 Code for the Pro Mini Frost Alert. /* PE KickStart Frost Alert (Listing 4.1) */ // Assign LEDs to digital I/O lines int redLED = 5; // Red LED connected to DIO5 int amberLED = 6; // Amber LED connected to DIO6 int greenLED = 7; // Green LED connect to DIO7 // Assign analogue input const int analogPin = 0; // Input to analog A0 // Set threshold levels int freezing = 102; // At 0 deg.C appx. (change as required) int warning = 110; // At 4 deg.C appx. (change as required) // Setting up void setup() { // Initialize digital I/O pins outputs pinMode(redLED, OUTPUT); pinMode(amberLED, OUTPUT); pinMode(greenLED, OUTPUT); } // Loop forever void loop() { int input = analogRead(analogPin);// Read the input Serial.println(input); if (input > warning) { green(); } else if (input > freezing) { amber(); } else red(); } // LED indications void red() { digitalWrite(redLED, HIGH); digitalWrite(amberLED, LOW); digitalWrite(greenLED, LOW); } void green() { digitalWrite(redLED, LOW); digitalWrite(amberLED, LOW); digitalWrite(greenLED, HIGH); } void amber() { digitalWrite(redLED, LOW); digitalWrite(amberLED, HIGH); delay(1000); digitalWrite(amberLED, LOW); // Flash the amber LED delay(1000); digitalWrite(greenLED, LOW); } Practical Electronics | August | 2021 need to download them from the chip manufacturer (see Going Further below) if the virtual COM port is not recognised by your PC (the support documentation on the FTDI provides an Installation Guide, but we recommend that you opt to download the ‘Setup’ zipped file to a folder of your choice before extracting the files and running the executable to complete the installation. 4. Open the Arduino IDE on the host PC and select ‘Tools’ and then ‘Board’. Scroll down the list of boards and select ‘Arduino Pro Mini’ from the Boards List Manager (do not just select ‘Arduino Mini’ – this will not work!) 5. Return to the IDE main menu and select ‘Tools’ and ‘Port’ and then select your newly enabled virtual COM port. If this does not appear in the list then repeat steps 2 and 3. 6. You should now have a working connection to the Pro Mini, so return to the IDE and select ‘File’, ‘Examples’ ‘01.Basics’ and ‘Blink’ from the list of sample files. The file should then appear in the IDE’s editing window together with a tab which indicates the default filename under which it will be stored and made available for future editing. 7. Now select ‘Sketch’ and ‘Upload’ to send the code to the Pro Mini. This will take a short time, after which a ‘Done uploading’ message will appear, informing you that the transfer has been made. The Pro Mini will then restart, and your efforts will be rewarded by a flashing ‘user LED’ connected to digital I/O line 13. You are now ready to create your own program code for downloading to the Pro Mini! A sample application To show you just how easy the Pro Mini is to use and incorporate in your own designs, here is a simple example in the form of a Frost Alert. This handy device will warn you when the temperature has fallen to a low value where frost and ice are likely to be present. The device can be built using a Pro Mini and just seven other components, three resistors, three LEDs and one TMP36 temperature sensor and it can be put together in less than ten minutes! The complete circuit of the Frost Alert is shown in Fig.4.4. The TMP36 temperature sensor is one of a family of three accurate, low-cost temperature sensors that provide analogue output voltages in response to temperature. The TMP36 is recommended for use over the temperature range −40°C to +125°C and it offers an accuracy better than ±2°C and typically ±1°C at +25°C. The output voltage is linearly proportional to the temperature measured in degrees Celsius, as illustrated by Fig.4.5. 43 Fig.4.6. Semiconductor pin connections for the TMP36 temperature sensor. Fig.4.4. Circuit of the Pro Mini Frost Alert. Fig.4.5. Characteristics of the TMP36 temperature sensor. The TMP36 is intended for singlesupply operation from 2.7V to 5.5V and is thus eminently suitable for operation from the Arduino’s +3.3V or +5V supply. To avoid the risks associated with selfheating, the chip requires only a very small supply current (well below 50µA). In addition, a shut-down function is available to limit the residual supply current to less than 0.5µA. The TMP36 provides a nominal output voltage of 750mV output at +25°C, changing at the rate of +10mV/°C. At 0°C its output will be 500mV and, for example, at 4°C it will be 540mV. The interface to the Pro Mini’s analogue port (see Fig.4.4) is extremely simple and no other components are required apart from the temperature sensor itself. The pin connections for IC1 and D1-D3 are shown in Fig.4.6. The minimal code for the Frost Alert is shown in Listing 4.1 (this is also available for downloading from the PE website). As mentioned previously, before you can begin to enter code into the Pro Mini you will need to connect it to a PC that has a copy of the Arduino’s integrated development environment (IDE) installed on it. Table 4.2: Going Further with the Arduino Mini Pro Topic Source Notes Arduino Pro Mini The Arduino Pro Mini is available from various suppliers, including HobbyTronics, Pimoroni, SparkFun, AZ-Delivery, and Adafruit. Several of these suppliers also have some useful downloadable tutorials. When ordering, it is important to specify the 3.3V or 5V version (as required). FTDI serialto-USB interface The FTDI Basic Breakout Board serial-to-USB interface drivers can be downloaded from: www.ftdichip.com An installation guide is also available. Arduino IDE The Arduino IDE can be downloaded from: www.arduino.cc/en/software Versions are available for Windows, Linux and macOS. Arduino Uno Electronics Teach-In 8. (available from Electron Publishing – see http://bit. ly/pe-apr21-ks2-7) provides a comprehensive guide to the Arduino. This popular series introduces hardware and software and also features a range of practical projects with different levels of complexity. The PE Direct Book Service at electronpublishing. com has several other titles suitable for background reading on the Arduino family. Sensors and interfacing The author’s book, Electronic Circuits: Fundamentals and Applications (5th Ed, 2020, Routledge 9780367421984) provides a general introduction to sensors and interfacing. The book also has a useful chapter on electronic applications and the Arduino. TMP36 temperature sensor The TMP36 datasheet is available from: www.analog.com/en/products/ tmp36.html 44 Practical Electronics | August | 2021