Silicon ChipThe Raspberry Pi-based PicoMite - January 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Risk aversion stifles innovation
  4. Subscriptions
  5. Feature: All About Batteries - Part 1 by Dr David Maddison
  6. Project: Two Classic LED Metronomes by Randy Keenan
  7. Review: Dick Smith Autobiography by Nicholas Vinen
  8. Feature: Solar Power with Batteries by Dr Alan R. Wilson
  9. Project: Multi-Channel Speaker Protector by Phil Prosser
  10. Product Showcase
  11. Project: The Raspberry Pi-based PicoMite by Geoff Graham & Peter Mather
  12. Feature: El Cheapo Modules: LTDZ Spectrum Analyser by Jim Rowe
  13. Vintage Radio: The Mysterious Mickey Oz by Ian Batty
  14. Serviceman's Log: Designing for unrepairability by Dave Thompson
  15. Project: Remote Control Range Extender by John Clarke
  16. PartShop
  17. Market Centre
  18. Advertising Index
  19. Notes & Errata: SMD Trainer, December 2021; Hummingbird Amplifier, December 2021; Pocket Weather Station, November 2021
  20. Outer Back Cover

This is only a preview of the January 2022 issue of Silicon Chip.

You can view 38 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • All About Batteries - Part 1 (January 2022)
  • All About Batteries - Part 1 (January 2022)
  • All About Batteries – Part 2 (February 2022)
  • All About Batteries – Part 2 (February 2022)
  • All About Batteries, part three (March 2022)
  • All About Batteries, part three (March 2022)
Items relevant to "Two Classic LED Metronomes":
  • 8-LED Classic Metronome PCB [23111211] (AUD $5.00)
  • 10-LED Classic Metronome PCB [23111212] (AUD $7.50)
  • Classic LED Metronome PCB patterns (PDF download) [23111211-2] (Free)
  • Dial labels and drilling guide for the Two Classic LED Metronomes (Panel Artwork, Free)
Articles in this series:
  • Home Solar Panel Electricity: Is It Worth It? (May 2015)
  • Home Solar Panel Electricity: Is It Worth It? (May 2015)
  • Solar Power with Batteries (January 2022)
  • Solar Power with Batteries (January 2022)
Items relevant to "Multi-Channel Speaker Protector":
  • 4-way Loudspeaker Protector PCB [01101222] (AUD $5.00)
  • 6-way Loudspeaker Protector PCB [01101221] (AUD $7.50)
  • Multi-Channel Speaker Protector PCB patterns (PDF download) [01101221-2] (Free)
Items relevant to "The Raspberry Pi-based PicoMite":
  • Firmware for the PicoMite (Software, Free)
Articles in this series:
  • The Raspberry Pi-based PicoMite (January 2022)
  • The Raspberry Pi-based PicoMite (January 2022)
  • VGA PicoMite (July 2022)
  • VGA PicoMite (July 2022)
  • The PicoMite 2 (February 2025)
  • The PicoMite 2 (February 2025)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Remote Control Range Extender":
  • Remote Control Range Extender IR-to-UHF PCB [15109212] (AUD $2.50)
  • Remote Control Range Extender UHF-to-IR PCB [15109211] (AUD $2.50)
  • PIC12F617-I/P programmed for the Remote Control Range Extender (UHF to IR part) [1510921A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC10LF322-I/OT programmed for the Remote Control Range Extender (UHF transmitter part) [1510921M.HEX] (Programmed Microcontroller, AUD $10.00)
  • Kit for the Remote Control Range Extender IR-to-UHF adaptor (Component, AUD $25.00)
  • Software for the Remote Control Range Extender (Free)
  • Remote Control Range Extender PCB patterns (PDF download) [15109211-2] (Free)
  • Lid panel label artwork and box drilling diagrams for the Remote Control Range Extender (Panel Artwork, Free)

Purchase a printed copy of this issue for $11.50.

The Pic Mite A BASIC compatible interpreter running on the Raspberry Pi Pico Words and MMBasic by Geoff Graham, Firmware by Peter Mather The PicoMite is a BASIC interpreter running on a Pi Pico which supports over a dozen display panels, including OLED and e-Ink panels. Connecting one is easy, as shown here. The PicoMite has extensive support for displaying graphs, images and graphical objects, plus more. T he Raspberry Pi Pico is a microcontroller module with plenty of memory, I/O and a USB connection. Even better, it is cheap as chips and readily available. The only problem is that you need to be an expert programmer to get it to do anything. That changes with the PicoMite, a version of our popular MMBasic interpreter running on the Raspberry Pi Pico. This lets you program it in the easy-to-learn BASIC language with full access to all of the Pico’s advanced features. And this costs nothing; the PicoMite firmware is entirely free for you to download and use. We have previously described the Raspberry Pi Pico (December 2021; siliconchip.com.au/Article/15125), covering the hardware and programming requirements for the Pico using the C or Micropython programming languages. However, programming in 64 Silicon Chip C is beyond most casual experimenters. Micropython is easier, but it is still a new language for most people and takes time to learn. MMBasic should be familiar to most regular readers of Silicon Chip. It is an implementation of the BASIC programming language, which is largely compatible with Microsoft BASIC. It has been used for over a decade (!) on our Maximite series of computers (since March 2011) and Micromite controllers (since May 2014). The BASIC language was initially designed to teach programming and therefore is easy to learn and use. You can get it to do something with just one line, and the programming environment is particularly easy. A single keypress will set your program running and, if it fails with an error, you will get a plain text error message. A second keypress lets you Australia's electronics magazine jump back into the editor with the cursor positioned on the line that caused the error. MMBasic also makes it easy to use the hardware features of the Raspberry Pi Pico. They are accessed using straightforward high-level commands that avoid the complexities of dealing with the RP2040 chip and its hundreds of programming registers (the data sheet for the RP2040 alone runs to over 600 pages). For example, this is all that you need to send the word “hello” out of a serial port: SETPIN GP13, GP16, COM1 OPEN “COM1:” AS #1 PRINT #1, “hello” The first line allocates the I/O pins as the serial port, the second initialises the port and the third sends the text. Easy. siliconchip.com.au MMBasic features A major feature of the PicoMite is that it uses a full implementation of the BASIC language, not some cut-down version. You have three data types (double precision floating point, 64-bit integers and strings), long variable names, arrays with multiple dimensions and user-defined subroutines and functions. The list opposite gives an idea of its other features. MMBasic is largely compatible with Microsoft BASIC, so many programs downloaded from the Internet will run with little change. MMBasic also includes a built-in full-screen editor which lets you edit large programs directly on the Pico­ Mite. The edit/run/edit cycle is very fast, with a single keypress to jump between editing and running the program, then another to go back to editing again. MMBasic supports the full Raspberry Pi Pico set of hardware features, many of which are mentioned in the features list. MMBasic also adds features not native to the Raspberry Pi Pico, including support for SD cards and over a dozen LCD panel types, including touch input and advanced graphics. These capabilities are all covered in detail in the PicoMite User Manual, downloadable from the Silicon Chip website at siliconchip.com.au/ Shop/6/6060, or the author’s website (http://geoffg.net/picomite.html). That’s an extensive document, so the remainder of this article will cover the highlights and most important aspects of the PicoMite. The firmware is structured to work on any module using the RP2040 processor with at least 2MB of flash memory. As described in our article on the Pico, the RP2040 processor is used on many boards, including the Arduino Nano RP2040 Connect, the Adafruit Feather RP2040 and other variants from companies like Sparkfun and Pimoroni. So you can load and use the Pico­ Mite firmware on these just as well. We have published several MMBasic programming tutorials, including a two-part series on Getting Started with MMBasic in February, March, May & June 2017 (siliconchip.com.au/ Series/311) and Advanced Programming with MMBasic in the November & December 2016 issues (siliconchip. com.au/Series/307). siliconchip.com.au Full-featured, Microsoft BASIC compatible interpreter running on the Raspberry Pi Pico. Will work on any RP2040-based module with at least 2MB of flash. Runs from 1.8-5.5V at 11-43mA, depending on the CPU clock speed. Variables can be floating-point numbers, 64-bit integers or strings with support for long variable names, arrays with multiple dimensions, extensive string handling and user-defined subroutines and functions. A focus on ease-of-use with a beginner-friendly programming language, informative error messages and a rapid development cycle. Full support for all 26 Raspberry Pi Pico input/output pins and features. All pins can be digital inputs or outputs, along with up to three analog inputs, two bidirectional serial ports to over 1Mbaud, two SPI master ports to over 30MHz, two I2C master ports, 16 pulse-width modulated (PWM) outputs and 1-Wire I/O pins. Up to ten programs can be saved on the module, each up to 80KB; chaining allows for programs up to 800KB. RAM for variables, arrays and buffers is configurable and can be up to 80KB. Any program can be set to automatically run on power-up or reset. Configurable clock speed (48 to 250MHz). Internal temperature sensing of the processor. Supports colour displays up to 3.5in (diagonal), allowing the BASIC program to display text and draw lines, circles, boxes, etc in 65,535 colours. Resistive touch controllers are also supported. SD cards up to 32GB formatted in FAT16 or FAT32 are fully supported. This includes opening files for reading, writing or random access and loading and saving programs. It can play audio files (WAV format) on PWM outputs. Built-in support for commonly used devices including infrared remote controls, ultrasonic distance sensors, temperature sensors, humidity sensors, text display modules, battery-backed clock, numeric keypads and more. Programming and control via USB with no special software required; any computer running a VT100 terminal emulator will work. Programs can be easily transferred from a computer (Windows, Mac or Linux) via SD card, by using the XModem protocol or by streaming the program over the USB console. The built-in full-screen editor includes advanced features such as colour-coded syntax, search and copy, cut and paste. Australia's electronics magazine January 2022  65 up; the PicoMite will disconnect and then reconnect as a USB flash drive on your computer, ready for the firmware upload. The console The Raspberry Pi Pico is a popular, low-cost microcontroller module with plenty of memory, speed and I/Os. With our PicoMite firmware, you can program it in the easy-to-learn BASIC language with full access to all of the Raspberry Pi Pico’s advanced features. Micromite compatibility For readers familiar with our Micromite series of microcontrollers, the PicoMite is fully compatible with just a few differences to accommodate the unique hardware aspects of the Raspberry Pi Pico. This compatibility is so complete that you can take a BASIC program such as that used on our Micromite Air Quality Monitor (February 2020; siliconchip.com.au/Article/12337) and run it on the Raspberry Pi Pico with few or no changes (see screen grab overleaf). The PicoMite essentially implements all the features of the Micromite Plus except for display panels with a parallel interface, the library function and attached keyboards. Features inherited from the Micromite Plus include embedded C code, support for serial LCD panels, embedded fonts, advanced graphical (GUI) controls and an SD card interface with full FAT32 filesystem support. The PicoMite has fewer I/O pins than the Micromite Plus but it runs faster (up to 250MHz) and can accommodate larger programs. Probably its best feature is that it is a complete module with a USB connector, power supply and breadboard-friendly interface pins—all for a ridiculously low price (as little as $6!). Loading the firmware The RP2040 processor has a small amount of fixed read-only memory reserved for loading the firmware (called the bootloader), making it easy to load and test new firmware without special software. The following process will work with any modern computer (Windows, macOS or Linux). 66 Silicon Chip First, download the PicoMite firmware from one of the sites linked above. This is a zipped archive and the firmware file inside it has an extension of “.uf2”. Hold down the white button marked BOOTSEL on the top of the Pico and plug its USB interface into your computer while still holding down the button. Your computer should make a sound indicating a new USB device has been discovered, and the Pico will appear as a USB flash drive on your computer. Finally, drag and drop the firmware file onto the ‘drive’ created by the Pico, and your computer will upload it to the Pico. When the copy is complete, the Pico will automatically restart running MMBasic and reconnect to your computer, this time as a virtual serial port over USB. The green LED on the top of the Pico board will start slowly flashing to indicate that the PicoMite firmware is now running. The only purpose of the drive created by the Pico is to load firmware; any other type of file copied to it will be ignored. The firmware file will vanish when the copy completes, so this drive cannot be used as a memory stick. The handy thing about this process is that you can use it to install whatever firmware you like – you can easily upgrade (or downgrade) the PicoMite firmware or install something completely different (like Micropython) then later revert to the PicoMite firmware if you so wish. To make it easier to upgrade the PicoMite firmware, you can issue the command UPDATE FIRMWARE at the MMBasic command prompt. This will be as if you had pressed the BOOTSEL button while powering Australia's electronics magazine When the Raspberry Pi Pico reconnects to your computer following the firmware installation, it will act as an asynchronous serial port over USB. This is the MMBasic console; using this, you can configure MMBasic, load/run/edit programs etc. This will be familiar to anyone who has worked with the Micromite and it works the same. The serial port uses the CDC protocol and the drivers for this are standard in Windows 10 and will load automatically. For Windows 7 or 8.1, you will need a tool like Zadig (https://zadig. akeo.ie/) to install a generic driver for a “usbser” device. For macOS and Linux, see the notes in the PicoMite User Manual (but generally, it will ‘just work’ with a recent version of either OS). To use the console, you need to install a terminal emulator which will send your keystrokes to the PicoMite and display anything sent back by it. The recommended emulator for Windows is Tera Term (http://tera-term. en.lo4d.com/) which is free to download and use. The terminal emulator will need to know the number of the virtual serial port generated when the PicoMite is connected to your computer. With Windows, you can find that using Device Manager. This port number is entered in Tera Term by going to Setup → Serial Port... The other settings, including the baud rate, can be left at their defaults. Note that setting the baud rate to 1200 is another way of forcing the Pico into its update firmware mode, so avoid using that rate. With everything set up, pressing the Enter key in your terminal emulator should cause the PicoMite to echo back the greater than symbol (>), which is the MMBasic command prompt. To verify that you are indeed connected to a miniature BASIC computer, you can try a few commands: PRINT MM.VER Displays the version number of the firmware. MEMORY Displays the amount of free memory. siliconchip.com.au PRINT PI Displays an approximation of pi (π). Test program The standard test that people use when experimenting with a new microcontroller is to get it to flash one LED on and off. For this, we can use the green LED on the top of the Pico’s PCB. When MMBasic is running, this will slowly flash on/off, but for our test program we will take control of it and cause it to flash much more rapidly. The easiest way to enter a short BASIC program to do that is with the PicoMite’s built-in editor. This works the same as most of the editors that you will have used in the past. For example, any text typed in will be inserted at the cursor’s location, the arrow keys will move the cursor around, the delete key will delete the character at the cursor and the backspace key will delete the character before the cursor. The MMBasic editor has many other functions (search, replace, copy, paste etc) and these are detailed in the PicoMite User Manual. Type in the command EDIT at the command prompt to start the editor, then type in the following program: SETPIN GP25, DOUT DO PIN(GP25) = 1 PAUSE 100 PIN(GP25) = 0 PAUSE 300 LOOP When you have finished, press the F2 key on your keyboard (or CTRL+W). This will save your program, exit the editor and start the program running. You should be rewarded with the LED on the Pico rapidly flashing. If something goes wrong, you will get an error message. In that case, rerun the editor with the EDIT command and it will place the cursor on the line that caused the error, ready for you to correct it. The program starts by defining the I/O pin driving the LED (GP25) as an output, which places it under our program’s control. Then the program enters a loop where the pin is set high (which illuminates the LED) followed by a short pause of 100ms, then low followed by a 300ms pause. This repeats continuously. siliconchip.com.au You can break out of this program by pressing CTRL+C, which will return you to the command prompt where you can (if you wish) restart the editor and modify the program—for example, altering the delays to change the flash rate. Saving the program On the PicoMite, the BASIC program is held in RAM. This is necessary for good performance; flash memory is on a separate chip to the RP2040 processor and is accessed via a relatively slow serial interface, while the RAM is inside the RP2040 and therefore quick to access. The PicoMite firmware also loads critical sections of the MMBasic interpreter into RAM. This way, even though most of the PicoMite firmware is held in flash memory, BASIC programs run just as fast on the Pico­Mite as on other microcontrollers with internal flash memory. RAM is volatile, and its contents are lost if the power is interrupted. So the PicoMite will automatically save a copy in a reserved area of flash memory and restore that on power-up – or when the processor is restarted. The result is that you are not aware of the volatile nature of RAM. You can save multiple programs in the PicoMite’s flash memory using the command “FLASH SAVE n”, where n is a number between 1 and 10 which indicates the saved program’s location in flash memory. This means that you can save up to 10 independent programs to flash. For example, to save your program in location 1, you would use this command: FLASH SAVE 1 And you can run it anytime using this command: FLASH RUN 1 If you want this program to start running automatically every time power is applied, issue the command: OPTION AUTORUN 1 Similar commands allow you to list the flash locations, erase locations, overwrite locations etc. If you have attached an SD card to the PicoMite (details below), you can also save, load and run programs from the SD card. Be aware that any programs saved to the flash memory can be corrupted when upgrading the firmware, so they should be backed up before upgrading. This is because programs saved to flash have had keywords converted to tokens, and the upgraded firmware may use different tokens. If you forget and find your saved programs corrupted, you can downgrade to the previous version, back up your programs and then upgrade again. PicoMite inputs & outputs The I/O pin layout of the Pico­Mite is shown in Fig.1. There are 26 usable I/O pins. All can act as digital inputs or outputs, while three can be used as analog inputs (to measure voltage). There are also seven ground pins, one 3.3V output for external circuitry Fig.1: the I/O pins on the Raspberry Pi Pico and their capabilities under MMBasic. The full details are in the PicoMite User Manual, but here are some notes. VBUS is the 5V supply from the USB port, VSYS is the 5V input to the SMPS, 3V3EN enables the 3.3V regulator (low = off), RUN is the active-low reset pin, ADC VREF is the reference for voltage measurement and AGND is analog ground. Australia's electronics magazine January 2022  67 and some other pins, which we will cover later. The pins can be referenced by their pin number on the Pico board (4, 5, 6 etc) or their logical reference (GP2, GP3 etc). These are shown in green in Fig.1. For example, within MMBasic, PIN(17) and PIN(GP13) refer to the same I/O pin. To define how a pin works, you use the command “SETPIN pin, function”. Here, ‘pin’ is the I/O pin reference (eg, GP13) and ‘function’ is how you wish the pin to act. Common functions are DIN (digital input), DOUT (digital output), AIN (analog input), FIN (measure frequency) and so on. The PicoMite User Manual describes these in detail. As an example, the following will configure GP7 to measure frequency: SETPIN GP7, FIN As the PicoMite firmware has been designed to run on other boards that also use the RP2040 processor, the four I/O pins that are hidden on the Raspberry Pi Pico (GP23, GP24, GP25 and GP29) are usable in MMBasic as they may be exposed on other modules. The pin allocations for functions such as SPI, I2C and serial are somewhat configurable. For example, the receive pin for the second serial port (COM2:) can be GP5, GP9 or GP21 and the transmit pin can be GP4, GP8 or GP20. These pins are marked in cyan in Fig.1, as COM2 RX and COM2 TX. These pin allocations work equally well but must be configured via the SETPIN command before opening the serial port. The Pico has two serial ports, two SPI ports, two I2C ports and 16 PWM-capable outputs. Within MMBasic, they are all accessed in the same way; first, allocate the I/O pins using Fig.1 as your guide, then open the channel or device, then use the function. Powering the PicoMite The Raspberry Pi Pico has a particularly flexible power system which gives the user several options for powering the module. The power supply is shown in Fig.2 and consists of the main USB input, where the 5V power from this source is fed via a schottky diode to a switch-mode power supply (SMPS) that is capable of both buck (step-down) and boost (step-up) operation. Its 3.3V output is used to power the rest of the board and is made available on an edge pin (3V3) for powering external circuitry. The SMPS has an input range from 1.8V to 5.5V, which lends a great deal of flexibility to the Pico. It means that it can be powered via USB or a USB charger, a single Li-ion cell or a couple of AA cells, to name a few options. In general, there are three ways to supply power. The first is simply a USB source such as a laptop plugged into the USB socket. An alternative power source might be required for embedded applications, and this can be supplied via a schottky diode to the pin marked VSYS (pin 39). The schottky diode means that either or both the USB and external power source can be present without interfering with each other. This is handy if you want to plug a laptop into the Pico’s USB socket to debug your code while the module is in-circuit. The third method is to short the 3VEN pin (pin 37) to ground and supply an external source of 3.3V to the module via the 3V3 pin (pin 36). Grounding 3VEN will shut down the SMPS regulator and disconnect its output so that the 3V3 pin can be used as a 3.3V power input. The switching regulator generates a lot of electrical noise, so using a linear regulator to supply 3.3V to the board will make it much easier to use the analog inputs and produce noise-free audio signals using PWM. The power consumption of the PicoMite is modest. At its default 125MHz CPU clock, it draws about 21mA. This does not include any power drawn from the I/O pins or the 3V3 pin. The RP2040 processor’s clock can be varied from 48MHz to 250MHz under control of MMBasic (using the “OPTION CPUSPEED” command), and the power drawn varies accordingly, from 11mA to 43mA. Three AA alkaline cells can power the PicoMite running at 48MHz for weeks of continuous operation. Note that the specified top clock speed for the Raspberry Pi Pico is 133MHz; anything above that is regarded as overclocking. We tested several modules and most worked at 250MHz, so that can be considered a viable option. Special device support The PicoMite inherits support for several special devices from the Micromite. This includes an infrared remote control decoder supporting Sony and NEC remote controls, allowing BASIC programs to act on signals from universal remotes. Other natively supported devices include temperature sensors, humidity sensors, ultrasonic distance sensors, numeric keypads, and two-line LCD modules. All of these are easy to use. For example, the DISTANCE() function will trigger an ultrasonic distance sensor, wait for the echo and return the distance to the target in centimetres for your BASIC program to act on. As another example, if you want to measure temperature, just attach a DS18B20 sensor and use the TEMPR function to get the temperature in °C with a resolution of 0.1°C. You do not need to load libraries or write many lines of code; these functions are built in, and they just work. SD card support The PicoMite has built-in support for SD cards up to 32GB, formatted as FAT16 or FAT32. This includes full read/write for both programs and data files, navigating through subdirectories and support for long filenames. The files created by the PicoMite can be read and written on computers running Windows, Linux or macOS. Fig.2: the Raspberry Pi Pico has a flexible power system. The input voltage from either the USB or VBUS inputs is connected through a schottky diode to the buck-boost switch mode power supply, which produces 3.3V. This accommodates input voltages from 1.8V to 5.5V, allowing the PicoMite to run from a wide range of power sources, including single Li-ion cells and 2-3 alkaline cells. 68 Silicon Chip Australia's electronics magazine siliconchip.com.au Fig.3: the PicoMite has full support for (micro)SD cards. This diagram shows one way of connecting an SD card to the PicoMite and matches the example configuration commands listed in the text. MMBasic can open files for reading, writing or random access and load or save programs with cards up to 32GB formatted with FAT16 or FAT32. Communication with SD cards is via the SPI protocol, also used by many LCD panels and touch controllers. These all use what is called the System SPI port on the PicoMite, and the I/O pins used by this port need to be specified before any of these devices can be used. This is done using the following command: OPTION SYSTEM SPI CLK, TX, RX Here, CLK, TX and RX are the pins to use for these functions (as determined from Fig.1). For example, the following will dedicate the second SPI channel (called SPI2) to the System SPI function and define the I/O pins to use: OPTION SYSTEM SPI GP10, GP11, GP12 This option will be saved in flash memory and will be automatically reapplied on power-up, so it only needs to be entered once. Additionally, other SPI devices such as display panels will also use this port, so it does not need to be redefined for them. When allocated to the System SPI function, that port will not be available to the BASIC program (ie, it will be dedicated to the firmware). One thing to watch out for is that this command and other similar OPTION commands will cause the PicoMite to restart and that will disconnect your USB console connection, so you will need to re-establish it after entering the OPTION command. With the System SPI port defined, you can tell MMBasic that an SD card is connected and what pin to use for the Chip Select signal (CS). For example, if you used GP22 for Chip Select, the command would be: OPTION SDCARD GP22 As before, this option will be saved and automatically reapplied on powerup. It will also cause the PicoMite to restart. Fig.3 shows how the SD card socket should be wired up. With that done and the SD card interface configured in MMBasic, you can pop a card into the socket and try the “FILES” command, which should list the files and directories on the card. PWM and audio output With 16 PWM outputs, the Pico­ Mite has so many that you could (for example) dedicate some to controlling indicator LEDs. Your program can then create some cool effects by ramping the brightness up and down rather than simply switching the LEDs off and on. An RGB LED driven by three Connecting an SD card is simple and MMBasic provides full access to the files and directories on the card. BASIC programs can open or create files for reading, writing or random access, navigate the directory structure and create or delete directories. The files created by MMBasic can be accessed by computers running Windows, Linux or macOS. This does not match Fig.3 exactly, but only because a different GND pin has been used. siliconchip.com.au Australia's electronics magazine January 2022  69 PWM outputs would let you create almost any colour. One important use for PWM outputs is to generate program-controlled voltages, which can control analog devices such as motor speed controllers. For this, you just need to add a simple low-pass filter (details in the user manual) on the output to remove the carrier frequency. Another use is to play stereo WAV audio files from an SD card via a lowpass filter. These sound effects can be almost anything: chimes, voice instructions, a warning siren or simply background music. Playing the audio does not interrupt the BASIC program as MMBasic will play it in the background, so your program can continue doing its job (eg, controlling some process) regardless of the duration of the audio output. The audio output can also generate precise sinewaves for a simple “beep” or, because the frequency is very accurate, test the response of loudspeakers and other audio components. Display panels The PicoMite includes support for many display panels using various controller chips. These are mostly LCDs, but it also supports OLED and e-Ink based panels, ranging from a tiny 84 x 48 pixels to a more substantial 480 x 320 pixels. All of these use either the SPI or I2C interfaces. Panels using a parallel interface (as on the Micromite Plus) are not supported as there are not enough I/O pins on the Raspberry Pi Pico to practically implement that type of interface. Two popular series of LCD screens are based on the ILI9341 and ILI9488 controllers. The ILI9341 version comes in various sizes from 2.2in to 2.8in diagonal with 320 x 240 pixels. The ILI9488-based panels are generally 3.5in diagonally and have 480 x 320 pixels. Both use the System SPI bus, which needs to be configured as described above. Both LCD panels are set up similarly: OPTION LCDPANEL CTRL, OR, DC, RST, CS Where CTRL is the name of the controller chip, OR is the orientation (portrait, landscape etc), DC is the pin to use for the data/control signal, RST is the pin used for the reset signal and CS is the chip select pin. For example, to set up a panel with the ILI9341 controller in landscape orientation, wired as in Fig.4, the command would be: OPTION LCDPANEL ILI9341, L, GP26, GP27, GP28 That’s assuming you already have System SPI on GP18, GP19 & GP20 to suit the wiring shown in Fig.4. With the display panel configured, you can test it by running the command GUI TEST LCDPANEL and you should be greeted with multiple overlapping circles popping up all over the LCD screen (as shown in the lead photo). To terminate the test, press any key. Two of the supported displays use an I2C interface. To connect these, the System I2C interface must be configured similarly to the System SPI interface. The command is: Fig.4: here’s one way to wire up a touchscreen to the PicoMite. If you connect an SD card at the same time, you need to use the same SPI RX, TX and CLK connections for both. While this shows an ILI9341-based 320x240 display, the connections required for the ILI9488-based 480x320 touchscreens are virtually identical. 70 Silicon Chip Australia's electronics magazine OPTION SYSTEM I2C SDA, SCL Currently, the only other device that uses the System I2C interface is the real-time clock. Many LCD panels incorporate a resistive touch interface. This controller also uses the SPI protocol and should be connected as per the System SPI interface (like in Fig.4). Configuring the touch interface is straightforward, but it needs to be done after configuring the display panel. The command is: OPTION TOUCH CS, IRQ CS is the Chip Select output pin and IRQ is the interrupt input pin. For the circuit shown in Fig.4, this would be: OPTION TOUCH GP22, GP21 After the PicoMite has restarted, you need to calibrate the touch system with the GUI CALIBRATE command. This will progressively draw a target on all four corners of the screen for you to touch and the firmware will use that to accurately identify the pixel coordinates of any touch. Graphics support Connecting an LCD screen is quite common in the microcontroller world. What sets MMBasic apart is its extensive support for displaying graphs, images and graphical objects on the screen. This, along with the touch input, means that a user of your program can control your gadget using a colourful LCD screen with intuitive on-screen objects such as switches, keypads, dials and lights. The basic drawing commands allow you to set any pixel to any colour, draw lines, circles and boxes and draw text anywhere on the screen in any colour. The PicoMite includes seven differently-sized fonts, and you can embed more fonts in the BASIC program to provide precisely the look you want. If an SD card is fitted, the program can load images from the card and display these on the LCD panel. You can use this to show a logo or load a textured graphical background. The PicoMite has also inherited the advanced GUI controls from the Maximite Plus. These include radio buttons, checkboxes, on-screen dials, numeric input fields and much more. All of these require just one command in the BASIC program to define their siliconchip.com.au One feature (of many) that sets the PicoMite apart is its extensive support for graphs, images and graphical objects. Along with the touch input, this means that users can control your gadget using a colourful LCD screen with intuitive on-screen objects such as switches, keypads, dials and lights. position and characteristics (colour, size etc). From then on, MMBasic will manage the control for you. That includes making a button look like it is depressed when touched, checking a check box, drawing a graph etc. All that the BASIC program needs to do is check the status of a control (ticked, depressed etc) and take the appropriate action. The most advanced GUI control is the Text Input Box. When touched by the user, MMBasic will pop up a full on-screen QWERTY keyboard for text input. This allows the user to enter any text required by the program. While a full keyboard sounds as if it would be impracticable on a small display panel, it is actually quite useable, even on the 2.8in LCD screens. More information The PicoMite is fully compatible with our Micromite series of microcontrollers, with just a few differences to accommodate the unique features of the Raspberry Pi Pico. This screenshot shows the PicoMite running our Micromite Air Quality Monitor from February 2020, originally designed for the Micromite LCD BackPack. The PicoMite is supported by the PicoMite User Manual, which can be downloaded from the S ilicon Chip website at siliconchip.com.au/ Shop/6/6060, or the author’s website (http://geoffg.net/picomite.html). This manual runs to over 160 pages and covers the details of using the Pico­ Mite and writing programs, including a tutorial on programming in the BASIC language. There is also an active user community on The Back Shed Forum (thebackshed.com/forum/ViewForum. php?FID=16), where many PicoMite users and experts in BASIC programming hang out. They are a friendly bunch and will be happy to help out if you are stuck on a complicated problem. The PicoMite firmware is completely free, and you can get the Raspberry Pi Pico for as little as $6, so the cost of playing with this powerful little fellow is tiny. Why not give it a go? You might just want to have fun making a LED flash, but it could evolve into your next burglar alarm or reticSC ulation controller. While it has fewer I/O pins, you can also turn other RP2040based boards like this Tiny2040 into a PicoMite with the same firmware. siliconchip.com.au When the user touches a text box on the screen, a keyboard like this pops up, allowing them to enter a name or other text string. Australia's electronics magazine January 2022  71