This is only a preview of the March 2023 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
Make it with Micromite
Phil Boyce – hands on with the mighty PIC-powered, BASIC microcontroller
Part 45: Updating the PicoMite firmware
D
uring development of the
PicoMite Fingerprint Reader (our
current Make it with Micromite
project), a new version of the PicoMite
firmware was released. Normally, we
would simply make you aware that a
new version of MMBASIC was available,
allowing you to update your PicoMite(s)
as and when convenient. However,
in this latest release, there are some
fundamental changes to the way the
PicoMite behaves (as well as the usual
performance improvements, and some
new commands).
One noticeable change concerns the
storage (and subsequent access) of program
files, data files, image files and sound files.
Traditionally, if required, files would be
stored on an attached SD card; however,
this new firmware allows files to be also
stored in the PicoMite’s own internal Flash
memory. This new feature is something
that we should be able to benefit from in
the Fingerprint Reader, and hence this
firmware update should be regarded as an
essential requirement for your PicoMite(s).
Therefore, we will begin this month with
a quick explanation of how to upgrade
your PicoMite(s) with this latest release of
MMBASIC, and then we will discuss the
hardware required to build the Fingerprint
Reader. We will explain how to configure
the required OPTIONs to ensure that the
new firmware is able to access the SD card;
and we will finish by loading a simple
test program to ensure that everything
is connected correctly. Let’s begin by
downloading the required files.
PicoMite v5.07.06
Just two files need to be downloaded:
the firmware file (PicoMiteV5.07.06.
uf2), and the User Manual (PicoMite_
User_Manual.pdf). These are both
available for free download by visiting:
https://geoffg.net/picomite.html
Simply scroll down to the ‘Downloads’
section (located towards the bottom of
50
Fig.1. To see
what OPTIONs
have been
set, use the
OPTION LIST
command.
the page) and click on the DOWNLOAD
button which is next to the description:
PicoMite firmware V5.07.06 (includes
the above manual). This will download
a zipped folder from which you can
unzip (extract) the two required files.
Alternatively, you can download them
both from the March 2023 page of the
PE website: https://bit.ly/pe-downloads
Once you have these two files, store
them in a convenient folder on your
computer. I tend to leave the .uf2 file in
the Downloads folder, and put the User
Manual in the Documents folder.
Uploading the firmware
This process was covered in MIWM Part
35 (PE, April 2022); however, since it’s a
quick-and-easy process, we will cover the
steps again here. Note that it should take
you less than a minute to complete the
upload. However, if you’re upgrading from a
previous version of MMBASIC, then before
you begin, there are two points to consider.
First, if you are currently working on a
project and you simply want to upgrade to
this latest version of MMBASIC, then ensure
that you make a note of any OPTIONs that
you currently have set. This is because this
firmware upgrade will wipe out all existing
OPTIONs – you have been warned! The best
way to do this is, at the command prompt,
type OPTION LIST and then simply take a
screen grab (or photo) of what is displayed.
(See Fig.1 for an example list of OPTIONs).
Second, if you have any program code
that you wish to keep, do back it up. To
do this, at the command prompt, type
LIST ALL and then (for TeraTerm) simply
highlight the code displayed (to copy it
onto the Windows clipboard), and then
paste it into something like Notepad
(or any other text editor). Next, save the
Notepad file with a suitable filename
into an appropriate folder.
After saving any important information,
you can now perform the firmware upload
by following these four steps:
1. Begin by disconnecting the PicoMite
from your computer (ie, remove power
to the PicoMite).
2. Press the BOOTSEL button (on the
PicoMite) and hold it down as you plug
the PicoMite into the USB port. This will
result in the Pico powering up into what
is known as ‘Bootloader Mode’ – it will
appear to the computer as an additional
USB Flash drive. This is signified by a
new ‘Pico Drive’ Window automatically
displayed on your computer (see Fig.2).
NOTE: Do not delete either of the two
files currently in the ‘Pico Drive’.
3. Paste (or drag / drop) the downloaded
firmware file (PicoMiteV5.07.06.uf2) into
the ‘Pico Drive’. This will immediately
start the upload process, and a progress
bar will appear briefly (see Fig.3)
4. Once the upload is finished, remove
the PicoMite, then re-insert it and start
up your preferred Terminal program.
You should now see the firmware has
been upgraded to version v5.07.06, as
indicated in the PicoMite’s power-up
‘Welcome message’ (see Fig.4)
Practical Electronics | March | 2023
Fig.2. If the BOOTSEL button is pressed while connecting the Pico to a computer, this
‘Pico Drive’ window will automatically appear.
Fig.3. When the .uf2 firmware file is moved into the Pico Drive, it will automatically be
processed, during which time a progress bar is displayed.
Fig.4. (left) Here, the PicoMite’s welcome
message (displayed at power-up)
confirms that MMBASIC has been
upgrade to version v5.07.06.
Fig.6. Our preferred RTC module. It will
capture the time/date of a finger detection.
Fig.7. The R503 capacitive fingerprint
sensor module. This was covered in detail
in Parts 1 (PE, December 2022) and Parts
2 of the project (PE, February 2023).
With the firmware upload complete,
you can now proceed to set OPTIONs
as required. However, if the upgrade
failed, then simply repeat the above four
steps again. The most common issue
is with step 2 if the BOOTSEL button
isn’t pressed at the time the PicoMite is
powered up. If you don’t see the ‘Pico
Drive’ window appear shortly after you
insert the PicoMite, then re-insert it with
the button firmly pushed.
Fingerprint Reader hardware
The completed unit will comprise of the
following four hardware modules:
1. PicoMite
2. 2 .8-inch Touchscreen (Waveshare
PicoRes Touch-LCD-2.8) – see Fig.5
3. Mini Real-Time Clock (RTC) module
(Fig.6)
4. R503 Fingerprint module (Fig.7)
To assist with development, a Pico
expander module (see Fig.8) will also
be useful to link everything together.
We will use one to initially check that
everything works as expected. Note that
the Touchscreen module also comes with
Fig.5. (Left and above) Front/rear views
of the Waveshare 2.8-inch touchscreen
module. Its three advantages are: low
cost, based on IPS technology (better
image than normal TFTs), and it has an
onboard SD socket.
Practical Electronics | March | 2023
Fig.8. A Pico Expander module will
simplify the connections to all the
hardware elements.
an onboard micro-SD socket which we will
also be using in the Fingerprint Reader.
All connections are shown in Fig.9,
and this will prove useful when it
comes to connecting the RTC and R503
modules. It will also help clarify the
parameters we’ll be using when setting
the required OPTIONs.
Begin assembly by plugging the
PicoMite into the Pico expander, taking
care to align the micro-USB socket on
the PicoMite with that shown on the
Pico expander. (Note that the PicoMite
should not be powered up at this stage.)
Next, carefully insert the Waveshare
module into a convenient place on the
Pico expander, ensure you align the USB
silkscreen on the display module with
that on the Pico expander.
51
R503 RX
GP0
1
40
VBUS
R503 TX
GP1
2
39
VSYS
GND
3
38
GND
GP2
4
37
3V3EN
GP3
5
36
3V3
GP4
6
35
ADC REF
GP5
7
34
GP28
GND
8
33
GND
GP6
9
32
GP27
GP7
10
31
GP26
TFT DC
GP8
11
30
RUN
TFT CS
GP9
12
29
GP22
GND
13
28
GND
R503 Finger detect
Fig.9. The Fingerprint Reader hardware
is based around the PicoMite. All
connections to it are summarised here.
n
GUI
SD CS
SPI CLK (TFT/SD)
GP10
14
27
GP21
I2C CLOCK (RTC)
SPI MOSI (TFT/SD)
GP11
15
26
GP20
I2C DATA (RTC)
SPI MISO (TFT/SD)
GP12
16
25
GP19
TFT Backlight PWM
GP13
17
24
GP18
GND
18
23
GND
GP14
19
22
GP17
TOUCH IRQ
GP15
20
21
GP16
TOUCH CS
TFT Reset
R503
(fingerprint module)
Red
3V3
Black
GND
Yellow
Tx
Green
Rx
Bue
Finger detect
White
Induction power
3V3
0V
GP1
GP0
RTC
3V3
With the PicoMite connected to your computer, launch your
preferred terminal program. At the command prompt, work
through the following steps to configure each required OPTION:
n O PTION CPUSPEED 252000 – this ensures that the
PicoMite runs at 252MHz.
n OPTION SYSTEM I2C GP20,GP21 – defines the I2C pins
(SDA and SCL) that connect to the RTC module’s D and
C pins.
n OPTION SYSTEM SPI GP10,GP11,GP12 – defines the SPI
pins (CLK, MOSI, MISO) that connect to the TFT and the SD.
n OPTION LCDPANEL ST7789_320,L,GP8,GP15,GP9,GP13
– defines the TFT pins (DC, RST, CS and Backlight) as
used by the TFT module.
Fig.10. By
default (on
power-up),
the FILES
command will
show any files
stored on the
internal Flash
drive (Drive A).
52
3V3
D
GP20
C
GP21
–
0V
GP2
The mini-RTC module can be connected by using four
female-male DuPont leads. Pin D (I 2C Data) on the RTC
connects to GP20, and pin C (I2C Clock) connects to GP21.
It is connected to 3.3V (and not 5V).
The R503 module is also connected to 3.3V, and to the
PicoMite’s COM1 pins on GP0 and GP1 (refer to Fig.9). The
‘Finger Detect’ output signal is connected to GP2.
With all the modules connected to each other, we can now
proceed to configure the required OPTIONs so that we can
then test everything is connected correctly.
Configuring OPTIONs
3V3 +
T E S T L C D P A N E L – draws
multiple, colourful overlapping
circles to confirm that the TFT is
configured correctly. It will continue
until you press a key on your terminal
application. If nothing appears, it is
likely that a parameter in OPTION
LCDPANEL is incorrect (in which case,
enter OPTION LCDPANEL DISABLE
and carefully re-key the above step
with the correct parameters).
n
OPTION TOUCH GP16,GP17 – defines
the touch panel’s CS and IRQ pins.
n
GUI CALIBRATE – follow the onscreen
instructions to calibrate the touchscreen
(touch the four crosshairs in turn).
n
GUI TEST TOUCH – this should draw
a dot at the exact point that you touch
the screen. Use a plastic stylus for this
process so that you can confirm the
accuracy of calibration. If the dot is
not accurately placed, press any key
to exit the test, and repeat the GUI
CALIBRATE command.
n
OPTION SDCARD GP22 – defines the
pin that connects to the SD card’s CS pin
Having configured the SD card, we would
normally test it with the FILES command
which will display the names of any files stored on the inserted
SD card. However, if you try the FILES command now, you
will see a different result – see Fig.10. This relates to the
new feature of file storage mentioned at the beginning of this
article. By default (at power up) the FILES command will
show the files that are stored in the PicoMite’s own internal
Flash memory (which can be regarded as an inbuilt Flash
drive). So, how do we now access files stored on the SD card?
The DRIVE command
There are now two locations that the PicoMite can store
files: the new Flash drive (built into the PicoMite’s internal
Flash memory), and an external SD card (if defined by
Fig.11. The DRIVE “B:” command is used to switch focus to
the SD card.
Practical Electronics | March | 2023
Fig.12. This is the ‘splash’ screen that will
be displayed when the Fingerprint Reader
is powered up. Also used in the Flash
drive demonstration.
using the OPTION SDCARD command
as we have done above). The Flash
drive is referred to as ‘Drive-A’, and
the SD card is ‘Drive-B’. To switch
between them you simply use the new
command DRIVE.
So, to select the SD card, simply
type DRIVE “B:” after which any
subsequent command relating to file
access will act upon the SD card. Try
this by typing FILES to confirm that
you can indeed see any files stored
on the SD card (see Fig.11). Note that
DRIVE “A:” will switch back to the
Flash drive, but for now let’s leave it
pointing to the SD card.
The COPY B2A command
Now let’s demonstrate one example of
how we can use the new Flash drive
storage feature.
Typically, if we want to display an
image file on the TFT display, we would
use the LOAD IMAGE “filename$”
command. This would then read the
image from the SD card (with the
relevant filename) and load it onto
the display. However, this means that
the SD card (containing the image file)
must be inserted whenever we want to
load the image to the screen. A possible
alternative that we now have is to store
the image file in the Flash drive, and
use the LOAD IMAGE command to load
the image file from there instead. This
means that the SD card no longer needs
to be present (apart from the initial
copying of the image file from the SD
card into the Flash drive).
Let’ work through the steps to
demonstrate this; noting that along
the way we will be using another new
command: COPY B2A.
1. Begin by downloading a copy of the
sample image file (Welcome1.bmp)
from the March 2023 page of the
PE website (see above). This image
is shown in Fig.12; it is what will
be displayed on power-up of the
completed fingerprint reader.
2. Copy the Welcome1.bmp file onto
an SD card.
Practical Electronics | March | 2023
3. Insert the SD card into the socket on
the Waveshare display module; then
check the file can be seen by typing
the FILES command. This should
reference the B: drive – if not, type
DRIVE “B:” followed by FILES.
4. To copy the image file from the SD
card into the Flash drive, enter the
command COPY B2A “Welcome1.
bmp” TO “Image1.bmp”
5. Switch to the Flash drive by typing
DRIVE “A:”
6. Now type FILES to check that the
image file is now in the Flash drive
(see Fig.13). Note that we renamed
the file Image1.bmp when we used
the COPY B2A command in step 4.
7. Remove the SD card from the socket.
8. With the PicoMite still referencing
Drive A, type the command LOAD
IMAGE “Image1.bmp” and it will
appear on the display.
The above is just one example of how we
can use the built-in Flash drive (instead
of an SD card) to store files – in this
case, just a single image file. Likewise,
we could store some sound files onto
the Flash drive (copied initially from
an SD card like we did in step 4 above).
The PicoMite’s program-code could
then trigger the relevant sound file
as appropriate without the need for
an SD socket in the final circuit build
(useful if making a large quantity of a
particular product).
Now consider the Pico expander
Module we assembled above. This has
a PicoMite installed, and a separate
display module that includes an
onboard SD socket. The arrangement
of these two makes a great configuration
platform because we can use it to copy
any required files from the SD
card into the PicoMite’s Flash
drive. Once this is done, the
PicoMite can be removed and
replaced with another one. Then,
by repeating the C O P Y B 2 A
process, the second PicoMite’s
Flash drive can be loaded with
the required files. Repeating this
process allows a lot of PicoMites
to be configured quickly without
the expense of an SD socket in
the final project build.
For anyone interested in the
other available commands and
features regarding the Flash drive,
I recommend referring to the
latest version of the User Manual.
Waveshare display module, there is
nothing really to test since it is simply a
plug-in module. During the configuration
performed above, the command GUI
TEST LCDPANEL provided a suitable
test to ensure it was working. Likewise,
the DRIVE “B:” command followed
by the FILES command checked that
the SD-socket was working.
However, the R503 fingerprint module,
and the RTC module are connected via
DuPont leads – so let us now work
through the steps to check these.
R503 test
To check the R503 fingerprint module,
we enter a short test program. Type
EDIT to launch the Editor, and then
enter the following five-line program:
SETPIN GP2,DIN
DO
PRINT PIN(GP2)
PAUSE 100
LOOP
Referring to Fig.9, you will see that
GP2 is connected to the R503 ‘Finger
Detect’ output signal. In the above
program, GP2 is set as a digital input
(DIN), and then a continuous LOOP
prints the logic level present on this pin
(with a delay of 100ms between each
‘sample’). With no finger present, the
value 1 should be returned; and when
a finger is detected on the R503 sensor,
the value 0 should be returned. Now
test that this is indeed the case. If not,
check the 3.3V power connection to the
R503, and also check the connection
to GP2. If it is still not working, it is
worth removing the Finger Detect signal
from GP2, and then with the program
Hardware test
Having assembled the Fingerprint
Reader hardware on a Pico
Expander module, we just need
to confirm that everything is Fig.13. The COPY B2A command is used to copy
connected correctly. For the files from the SD card to the Flash drive.
53
still running, use a wire between GP0 and 0V to check it
shows a returned value of 0. Likewise, short GP2 to 3.3V
and check it shows a value of 1.
To check the Tx and Rx pins, download the test program
file R503ComTest.txt from the March 2023 page of the PE
website (go to: https://bit.ly/pe-downloads) and load it into
the PicoMite. Type RUN to launch the test, which will turn
on the ring LED with a blue colour. If this is not observed,
check the Tx and Rx signals, and switch them over if needed.
With everything connected correctly, the LED will be lit
blue, and that completes the R503 checks.
to + and –), and the two I 2C connections going to pins
GP20 (D) and GP21 (C). Also check the OPTION SYSTEM
I2C parameters are GP20 and GP21 (use OPTION LIST
to do this).
Once the time is set in the RTC, power down the PicoMite,
and after a few seconds, reapply power.
Now type RTC GETTIME to load the RTC’s maintained
date and time into the built-in system variables DATE$
and TIME$.
With this done, type PRINT DATE$ followed by PRINT
TIME$ to check that the correct date and time are displayed.
If they are showing correctly then this test is complete.
However, if the time is showing 00 for hours and minutes
(and the true time is not just after midnight!) then there is
an issue, as the time has not been maintained by the RTC.
I have only ever experienced this on one occasion and that
turned out to be a faulty RTC backup battery.
RTC test
Next time
The first step involves setting the date and time in the
RTC module with the RTC SETIME yy,mm,dd,hh,mm,ss
command. Use a suitably accurate time source such as an
internet-based clock (https://time.is/GMT) and replace the
parameters shown with the appropriate values. For example,
if it is currently 8:36:45PM on 16 February 2023, round up to
the next whole minute (or two minutes if more appropriate)
and at the command prompt, enter the command as: RTC
SETTIME 23,02,16,20,37,00
If an error is displayed that states ‘RTC not found’, then
carefully check the four wires connecting the RTC to the
PicoMite. There are two power connections (3.3V supply
Next month, we’ll finish the Fingerprint Reader with a brief
description of the software that we’ll be making available.
Plus, we’ll begin the discussion of our next project, which
is based around the popular ESP32 Wi-Fi module.
Until then, stay safe, and have FUN!
Micromite code
The code in this article is available for download from
the October 2022 page of the PE website.
GET T
LATES HE
T CO
OF OU PY
R
TEACH
-IN SE
RIES
AVAILA
BL
NOW! E
Questions? Please email Phil at:
contactus<at>micromite.org
Order direct from
Electron Publishing
PRICE £8.99
(includes P&P to UK if ordered direct from us)
EE
FR -ROM
CD
ELECTRONICS
TEACH-IN 9
£8.99
FROM THE PUBLISHERS OF
GET TESTING!
Electronic test equipment and measuring
techniques, plus eight projects to build
FREE
CD-ROM
TWO TEACH
-INs
FOR THE PRICE
OF ONE
• Multimeters and a multimeter checker
• Oscilloscopes plus a scope calibrator
• AC Millivoltmeters with a range extender
• Digital measurements plus a logic probe
• Frequency measurements and a signal generator
• Component measurements plus a semiconductor
junction tester
PIC n’ Mix
Including Practical Digital Signal Processing
PLUS...
YOUR GUIDE TO THE BBC MICROBIT
Teach-In 9 – Get Testing!
Teach-In 9
A LOW-COST ARM-BASED SINGLE-BOARD
COMPUTER
Get Testing
Three Microchip
PICkit 4 Debugger
Guides
Files for:
PIC n’ Mix
PLUS
Teach-In 2 -Using
PIC Microcontrollers.
In PDF format
This series of articles provides a broad-based introduction to choosing and using a wide range
of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints
and tips on using, and – just as importantly – interpreting the results that you get. The series
deals with familiar test gear as well as equipment designed for more specialised applications.
The articles have been designed to have the broadest possible appeal and are applicable to all branches of electronics.
The series crosses the boundaries of analogue and digital electronics with applications that span the full range of
electronics – from a single-stage transistor amplifier to the most sophisticated microcontroller system. There really is
something for everyone!
Each part includes a simple but useful practical test gear project that will build into a handy gadget that will either
extend the features, ranges and usability of an existing item of test equipment or that will serve as a stand-alone
instrument. We’ve kept the cost of these projects as low as possible, and most of them can be built for less than £10
(including components, enclosure and circuit board).
© 2018 Wimborne Publishing Ltd.
www.epemag.com
Teach In 9 Cover.indd 1
01/08/2018 19:56
PLUS! You will receive the software for the PIC n’ Mix series of articles and the full Teach-In 2 book – Using PIC
Microcontrollers – A practical introduction – in PDF format. Also included are Microchip’s MPLAB ICD 4 In-Circuit Debugger User’s Guide; MPLAB PICkit 4 In-Circuit Debugger Quick Start Guide; and MPLAB PICkit4 Debugger User’s Guide.
ORDER YOUR COPY TODAY: www.electronpublishing.com
54
Practical Electronics | March | 2023
|