Silicon ChipMake it with Micromite - July 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Publisher's Letter: The importance of repair
  6. Feature: Mixed menu by Mark Nelson
  7. Feature: The Fox Report by Barry Fox
  8. Project: Net Work by Alan Winstanley
  9. Project: Single-Chip Silicon Labs FM/AM/SW Digital Radio Receiver by Charles Kosina
  10. Project: Model Railway Level Crossing by LES KERR
  11. Project: Advanced GPS Computer by Tim Blythman
  12. Feature: Make it with Micromite by Phil Boyce
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Feature: Flowcode Graphical Programming by Martin Whitlock
  15. Back Issues: Flowcode Graphical Programming by Martin Whitlock
  16. Feature: Circuit Surgery by Ian Bell
  17. Feature: AUDIO OUT by Jake Rothman
  18. Feature: Electronic Building Blocks by Julian Edgar
  19. PCB Order Form
  20. Advertising Index

This is only a preview of the July 2022 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)
Make it with Micromite Phil Boyce – hands on with the mighty PIC-powered, BASIC microcontroller Part 37: Installing MMBASIC on a Raspberry Pi Pico T he MMBASIC programming language has been extremely popular over the last few years, appearing at the heart of many PE projects (in the form of a Micromite). This month, however, we are going to show you how to install the latest version of the MMBASIC firmware into the low-cost (and readily available) Raspberry Pi Pico. The result is a module that we refer to as the ‘PicoMite,’ and we really do believe it will become a regular building-block in many future electronic projects. Note that the PicoMite is not a replacement for the Micromite; instead, it is an alternative that is very quick to get up and running. So why are we so confident the PicoMite will be useful? To begin with, the PicoMite benefits from all the powerful features of MMBASIC for the Micromite, especially since it’s based on the Plus version of MMBASIC which has more capability than the Standard version. Also, compared to a Micromite, the Pico module comes preassembled, so the PicoMite is a true ‘plug-n-play’ module. (Remember, a Micromite is essentially a Microchip PIC32 chip installed with MMBASIC but requiring the assembly of a handful of additional components to provide the relevant supply voltages, pull-ups, and connectors.) If you are familiar with using a Micromite, then you’ll find using a PicoMite a breeze, with minimal (if any) changes required to make your program code run properly. Turning to hardware connectivity, the PicoMite provides 26 input/output pins with all the usual MMBASIC functionality: digital I/O, three analogue inputs, two serial ports, two master SPI ports, two master I2C ports, eight pairs of PWM channels, 1-wire connectivity, and an IR port. Next, Micromite code The code in this article is available for download from the PE website. 42 clock speed: the PicoMite is configurable to run from 48MHz to 250MHz, so it is certainly no slouch when it comes to running program code. Bearing in mind the PicoMite firmware is available as a free download, and a Raspberry Pi Pico module is available at a ridiculously low price, you can very quickly create an extremely powerful (yet easy-to-use) building block that costs well under £5. Another big benefit of the PicoMite is that it is compatible with many of the modules that have specifically been made for (and plug directly into) the Raspberry Pi Pico. So, for example, a 2.8-inch touchscreen module (which costs around £14 and comes with a uSD (micro-SD) card socket) can be plugged directly onto the PicoMite, and with just a couple of OPTION settings, you have the equivalent of a Micromite BackPack, but with the added bonus of uSD storage for programs and/or data files. Note that there are many alternative display modules available for the Raspberry Pi Pico that will also work with a PicoMite, and this is something that we will discuss next month. As always with MMBASIC, complex (or expensive) development tools aren’t required, nor are there any complicated compiling or downloading processes to follow. All you need to get started is a computer with a terminal program (such as TeraTerm), a Raspberry Pi Pico module, a micro-USB lead (to connect the Pico to your computer), and the MMBASIC firmware file (a .uf2 file). So, let’s see just how easy it is to create a PicoMite. MMBASIC for Pico The original MMBASIC firmware was created by Geoff Graham a decade ago to work with specific PIC32 microcontrollers. Since then, Geoff has updated his firmware with many new features and functionality. Also, Peter Mather has assisted in pushing USB connector On-board LED Bootselection button Fig.1. Location of important Raspberry Pi Pico parts used in the PicoMite firmware loading procedure. the capability of MMBASIC even further. Peter is responsible for migrating MMBASIC from the original PIC32 processors to the more modern ARM processors (one of which is used on the Pico – the Dual-core ARM Cortex M0). (I wish to express my thanks to both Geoff and Peter for their tireless work – MMBASIC is one of the most useful pieces of software ever created for the electronics hobbyist.) To begin, download the PicoMite’s MMBASIC firmware file (PicoMiteV5.07.03. uf2) from the July 2022 page of the PE website. Store the file in a known location – you will be loading it into the Pico shortly. Next, let’s identify a few parts on the Pico module that we will use during the firmware loading process. Practical Electronics | July | 2022 As soon as the .uf2 firmware file is placed into the Pico drive, a progress bar will be displayed indicating that the PicoMite firmware is being installed (see Fig.3). After just a few seconds, the Pico drive window (and progress bar) will automatically close to signify that the firmware has finished loading. If you look at the on-board LED on the Pico module, you will see that it is now slowly flashing green, confirming that the PicoMite firmware is up and running. Congratulations! – you have successfully created a PicoMite and it is now ready for use. Fig.2. The Pico module will appear as a USB Flash It is worth pointing out that the only drive when the Boot-selection button is held down purpose of the Pico drive (initiated by while connecting the Pico module to your computer. holding the boot-selection button while Note that there are two existing files on the ‘Pico connecting the module to your computer) is drive,’ as shown here. to initially install the PicoMite MMBASIC firmware (the .uf2 file). Once installed, the firmware file will not be visible in the Pico drive. Note too that any other files moved into the Pico drive will simply be ignored. To make things even easier, for any future PicoMite firmware The Raspberry Pi Pico updates, the PicoMite MMBASIC firmware includes the command: The Raspberry Pi Pico was discussed in some detail in the May UPDATE FIRMWARE which automatically brings up the Pico 2022 edition of PE. However, do not worry if you missed this drive window (on a connected computer). This means that you article since all we initially need to concern ourselves with are can house the PicoMite in an enclosure without worrying about the locations of the following parts, as shown Fig.1: how to access the physical ‘boot-selection’ button. n USB connector (a micro-USB type) Now that the PicoMite is ready for use, let’s do a few tests to n Boot-selection button (white button labelled as ‘BOOTSEL’) ensure it is indeed working correctly. In addition, we advise you n On-board LED (a green LED). to download the PicoMite User Manual from the July 2022 page of the PE website. It is an extremely useful reference, including Loading the PicoMite firmware descriptions of the features built into the PicoMite. To load the PicoMite firmware onto the Pico module, you first need to put the Pico into the ‘Bootloader mode’. To do this, simply hold down the boot-selection button while connecting the Pico Initial testing module to your computer. This will result in the Pico powering The PicoMite will behave as a serial port over USB, so your up and appearing to the computer as an additional USB Flash OS (operating system: Windows, macOS or Linux) will likely drive. Your computer will automatically open a window showing automatically detect it (especially if you’re running a recent a ‘Pico drive’ and you will see that it contains two existing files: version of the OS) and hence no drivers are required. However, INFO_UF2.TXT and INDEX.HTM (see Fig.2). if you’re not running a recent OS, or the PicoMite is not detected, To load the PicoMite firmware into the Pico module, you copy then please refer to page 7 of the PicoMite User Manual. the .uf2 file downloaded previously, and paste it into the Pico With the PicoMite still connected to your computer, launch drive; alternatively, you can drag and drop the .uf2 file into the your preferred terminal program (ie, TeraTerm for Windows). Pico drive. (Note: at the time of print, the latest version of the You will need to select the correct COM port number that firmware file is named PicoMiteV5.07.03.uf2) the OS has assigned to the PicoMite – it will be shown in a list of possible COM ports as a ‘USB Serial Device’ – see Fig.4. The baud rate can be left set to the default (other than 1200). On starting the connection to the correct COM Port number, the terminal program will automatically connect to the PicoMite. Tap a few keys and ensure that you see the relevant characters displayed on the screen. Now disconnect the PicoMite, then reconnect it, and after a second or two you will see the PicoMite’s welcome message displayed in the terminal program’s window (see Fig.5). Note that if the terminal program’s baud rate is set to 1200 baud, then this will automatically be detected by the PicoMite and will result in the PicoMite switching into the update firmware mode; hence, for normal use, avoid using a 1200 baud rate! With everything set up, type the following three test commands at the command prompt Fig.3. After placing the PicoMite’s .uf2 firmware file into the Pico drive, a progress bar (signified by the usual ‘>’ character): will be displayed for a few seconds showing installation progress. Practical Electronics | July | 2022 43 Fig.4. The PicoMite will appear as a ‘USB Serial Device’, and the OS will assign it a virtual COM port number. Your terminal program (in this case TeraTerm) needs to point to the correct COM port – here, COM11. and running. If you are familiar with I/O control on a Micromite then you will have no problem interfacing hardware to the PicoMite. Please do refer to the PicoMite User Manual – specifically pages 9, 25-27, and Appendix A (serial comms), Appendix B (I2C comms), Appendix C (1-wire comms), and Appendix D (SPI comms) for detailed explanations and examples, and also refer to the Commands section (from page 79) which details the exact syntax for all commands. Fig.5. This welcome message is displayed when the PicoMite is powered up – it will be familiar to regular Micromite users! I/O pin voltage n PRINT MM.VER (to display the MMBASIC version number) n MEMORY (to display the amount of free memory) n PRINT PI (to display an approximation to the value of the mathematical constant ) The result of the above should look like Fig.6 (note: MMBASIC commands are not case sensitive). PicoMite I/O availability The pins that are available for connecting to the PicoMite are summarised in Fig.7. The 26 I/O pins are shown in green and you will see that each of these pins has a reference to a ‘GP’ number (as used by the Raspberry Pi Pico documentation), and also a physical pin position number. For example, GP0 is pin 1, and GP28 is pin number 34. When it comes to the familiar SETPIN command, either pin reference can be used. Hence SETPIN 1,DOUT and SETPIN GP0,DOUT will set the same pin to a digital output. So, if we were to connect an LED to this pin via a current-limiting resistor to ground, then we simply use PIN(GP0)=1 (or PIN(1)=1) to turn the LED on, and use PIN(GP0)=0 (or PIN(1)=0) to turn it off. This should be familiar to any Micromite user. Now back to the on-board LED. Currently, the firmware is using it to show a ‘heartbeat’; however, it is connected internally to GP25 (which if you refer to Fig.7 is not actually a physical pin made available for connection). So, we could take control of the on-board LED if we were to reference it as ‘GP25’ – let’s now see this in action. At the command prompt, type the following two commands: It’s important to note that the maximum input voltage to any I/O pin on the Pico module is 3.6V; hence, if you are using a 5V module that needs to output a signal to the PicoMite, then you must use a level shifter. Also, the maximum source or Fig.6. Three simple tests provide sink current per pin is 12mA, reassurance that the PicoMite is with an overall maximum total working correctly. for the module of 50mA. Exceeding any of these limits will at best result in eratic behaviour, and at worst you’re likely to damage your Pico module. Next Time This article has shown how quick and easy it is to create a versatile PicoMite module. Next month, we’ll move on to interfacing the PicoMite to some of the many Raspberry Pi Pico display modules that are available, including 2.8-inch ILI 9341 (320x240) and 3.5-inch ILI9488 (480x320) touchscreens. In addition, we will demonstrate how to connect a much larger 9-inch SSD1963 (800x480) touchscreen, and a PS2 keyboard, to convert the PicoMite into a powerful stand-alone ‘computer’. Until then, stay safe, and have FUN! Questions? Please email Phil at: contactus<at>micromite.org SETPIN GP25,DOUT PIN(GP25)=1 And you will see that the onboard LED is now turned on. To turn it off, simply type: PIN(GP25)=0 Ok, this isn’t too impressive, but it saved us having to hook up a resistor and an LED! And what if we wanted the on-board LED to revert back to being a heartbeat LED? Simple – just type SETPIN GP25,HEARTBEAT We’re not going to describe further at this point how to use the different types of I/O pins, as this article is primarily to Fig.7. The 26 available I/O pins on the PicoMite are summarised here. For more specific details (and explain how to get a PicoMite up the use of the power pins) refer to the PicoMite User Manual. 44 Practical Electronics | July | 2022