This is only a preview of the January 2019 issue of Silicon Chip. You can view 40 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. Items relevant to "DAB+ Tuner with FM & AM and a touchscreen interface!":
Items relevant to "ATtiny816 Breakout and Development Board with capacitive touch":
Items relevant to "Zero Risk Serial Link":
Items relevant to "The PicoPi Pro Robot":
Purchase a printed copy of this issue for $10.00. |
The PicoPi
Pro Robot
Here’s one for kids from 7 to 77; whether a raw beginner or a dab hand!
It’s a small, two-wheeled robot which you put together from a kit, then
program to perform a variety of tasks. For example, you can get it to
follow lines, detect edges, play music and much more. They’ll “learn by
doing” using a visual programming language and an inbuilt LCD screen.
It’s a great school holiday project but will keep them entertained all year!
Play complex musical tunes with
the piezo buzzer
It can be up and running within a
day of work
8-bit PWM motor speed control
(0-255 steps)
In-circuit programming with visual
programming language
Powered from four AA cells
Line, edge and wall detection
By Bao Smith
Good for beginners to electronics
Can move in eight directions
=
86
86 S
Silicon Chip
Australia's
Australia’s electronics magazine
siliconchip.com.au
T
o build the PicoPi Pro robot, you
need to do some basic soldering,
a little bit of mechanical assembly
and some simple programming. It is
a good project for children 7-8 years
and older.
This kit would make a good gift for
someone who wants to get into microcontrollers and robotics but doesn’t
want to learn C/C++ or Python programming languages (as would typically be used with an Arduino or Raspberry Pi-based robot).
It consists of about seven different
modules which can be built separately and then combined to form the final robot.
The total cost is $110.00 (or $93.50
without the LCD module) and it can
be built and running within a day.
You’ll need a soldering iron, side cutters, glue, Blu Tack, four AA cells and
a programming cable.
The micro is supplied pre-programmed, but you need to use a programming cable to load software onto
the robot so it can perform different
actions.
The latest version of the kit can be
programmed using a PICkit 3 or sim-
Parts List
1 circular piece of laser-cut acrylic,
125mm diameter
2 wheels with rubber tyres
12 M3 x 10mm plastic pins
12 M3 x 10mm screws
8 M3 hex nuts
2 velcro strips
2 metal gear 300rpm motors with
semi-D shafts
2 motor housings
1 plastic case for the driver module
1 large steel bearing ball & housing
1 16x2 backlit serial LCD module
1 3-wire cable with plugs at each end
Driver module
1 driver PCB, 45 x 28mm
1 PIC16F506-E/P microcontroller
1 L293D motor driver IC
1 1N4148 small signal diode
1 1µF 25V tantalum capacitor
1 180kW resistor
1 4 x AA battery holder
1 2.5mm jack socket
1 16-pin DIL IC socket
1 14-pin DIL IC socket
1 3-way screw terminal block
1 3x7-pin header
2 4-pin header
siliconchip.com.au
ilar via a 5-pin male header, and we
would recommend that you take that
approach since you will then have a
programming tool that’s suitable for
other uses.
The slightly older version of the kit
that we built is instead programmed
using a proprietary USB programmer
that connects to a 2.5mm 4-pole jack
socket on the robot. This programmer costs $26.40 as a kit or $41.03
pre-made.
Either way, the programming is done
“in-circuit” (ie, with the robot completely assembled), making it easy to
experiment with the robot.
Building the modules
All the parts come organised in
individual bags, as separated in the
parts list. You will need a soldering
iron with a fine-tip and a Phillips head
screwdriver, plus a pair of side cutters
to trim the leads after soldering the
components.
When soldering, it’s generally best
to start with the items that have the
shortest pins or pin spacings, as these
are more difficult to solder if the board
is already partially populated.
Polarised components
Some components are polarised and
it does matter which way around they
are placed in the circuit. This includes
the one diode, the LEDs, the tantalum
capacitors and the ICs.
The diode has a black stripe at one
end marking its cathode and this is
lined up with the white stripe printed
on the PCB where it is soldered.
Each LED has one shorter and one
longer lead. The longer lead is the anode (+), and the shorter lead the cathode (-). Make sure the cathode goes to
the square hole on the PCB.
Make sure the notch on both the
IC socket and the IC matches what’s
shown on the PCB.
The tantalum capacitors are polarised and will be printed with a stripe on
the body, indicating the positive lead
(which may also be longer). So when
fitting these capacitors, the positive
lead goes into the pad closest to the
positive symbol printed on the PCB.
When soldering the components
to the PCBs (printed circuit boards),
many of them are not polarised and so
it does not matter which way around
you place them.
All components listed here are included in the PicoPi Pro Robot Kit, available from
PicoKit (www.picokit.com.au; phone (07) 5530 3095), for $110 inc GST and P&P
1 3-pin header
1 jumper shunt
Microswitch modules (makes two)
2 microswitch PCBs, 20 x 11mm
2 snap-action microswitches
2 10kW resistors
2 3-pin right-angle headers
2 3-wire cables with plugs at each
end
Photodiode & IR LED modules (two)
2 photodiode sensor PCBs, 20 x
20mm
2 3mm photodiode sensors
2 3mm infrared LEDs (940nm)
2 photodiode/LED plastic holders
2 330W resistors
2 10kW resistors
2 3-pin right-angle headers
2 3-wire cables with plugs at each
end
Pushbutton modules (two)
2 pushbutton PCBs, 20 x 20mm
2 12mm tactile pushbutton switches
2 10kW resistors
2 3-pin right-angle header
2 3-wire cables with plugs at each
end
Australia’s electronics magazine
Potentiometer module
1 potentiometer PCB, 20 x 20mm
1 50kW linear potentiometer & knob
1 3-pin right-angle header
1 3-wire cable with plugs at each
end
Buzzer module
1 buzzer PCB, 25 x 25mm
1 17mm piezo buzzer
1 BC327 PNP transistor
1 2.2µF 16V tantalum capacitor
1 10kW resistor
2 4.7kW resistors
1 3-pin right-angle header
1 3-wire cable with plugs at each
end
LED cables (two)
1 5mm blue LED
1 5mm red LED
2 180W resistors
2 2-wire cables with plugs at each
end
You will also need the PicoFlow
USB programmer, PICkit or similar,
four 1.5V AA cells, glue and/or Blu
Tack.
January 2019 87
Building the robot
Step 1: assemble the driver module, fitting the parts where
shown on the PCB.
Step 2: assemble the two microswitch
modules, fitting the parts where shown
on the PCB. The microswitches mount
on the edges of the two boards.
Step 3: assemble the two photodiode/IR LED modules, fitting the parts
where shown on the PCB. Feed the
photodiode and LED pairs through
the plastic mounting blocks and
ensure the LED orientation is correct before soldering them to the PCBs.
Step 4: assemble the two pushbutton modules, fitting the parts where
shown on the PCB.
Step 5: assemble the potentiometer
module, fitting the parts where shown
on the PCB.
Step 6: assemble the buzzer
module, fitting the parts where
shown on the PCB.
Step 7: assemble the two LED
cables. Cut one of the leads of
each cable in half. Then strip
5mm of insulation off the wires.
Then trim the leads of the supplied
180W resistors short and solder them
to the exposed ends of the wire (as
shown below).
88
Silicon Chip
You will end up with two cables with resistors soldered
into the middle of one of the wires. Twist the wires together and plug the LEDs into one end of the cable, with the
shorter lead (negative) going to the wire you soldered the
resistor onto. You can trim the LEDs leads if you want, but
make a note which lead is the negative (cathode).
Step 8: peel the protective film off both sides of the laser-cut circular acrylic base.
Step 9: attach the driver module to its open plastic case,
using two short (~4mm) self-tapping screws.
Step 9: attach the driver module (in its case) to the middle row on the base, using two short M3 machine screws
and nuts. The notch for the programming socket should
be seated near the outer rim of the acrylic base.
Step 10: take the spare 2-wire cable and cut it in half,
then remove the insulation to expose about 5mm of wire.
Heat and apply a small amount of solder on the ends of
the wire (tin them) and then push them through the holes
in the tabs on the back of the motor and solder them in
place. Do this for both motors. When soldering apply heat
for only a short period, so that the soldering iron doesn’t
burn the plastic on the motor.
A pair of side cutters is
the safest way to cut the
off the end of the motor
housing. The motor
should fit tightly in the
housing, otherwise use a
file to widen it slightly.
Step 11: the plastic motor housings supplied are a bit
small to fit the motors. Use side cutters to completely open
up the rear of each housing, where the vertical slot is located (see photo above). That will give enough room for the
rear of the motor to fit and for the motor wires to poke out.
Once you’ve cut the unnecessary plastic out, you can use
sandpaper or a small file to smooth the edges and widen
the motor housing slightly.
Step 12: place the rubber tyres over the two wheels and
then push the wheels onto the motor shafts.
Step 13: place the motor into the housing so that it fits
flush. You might need to force the motor in to get it to fit.
Apply a small amount of silicone sealant or glue to the
wires so that they are attached to the inside of the housing, preventing the wires from moving around and breaking the solder joints.
Step 14: attach the completed motor housing to the base
using two screws and nuts each. The wheels fit through
the wide slots near the edges (see photos).
Step 15: attach the leads from the two motors to the
headers on the driver module labelled M1 (left wheel) and
M2 (right wheel). Don’t worry about the orientation at this
stage, since if one wheel runs backwards, you can easily
swap them around later.
Australia’s electronics magazine
siliconchip.com.au
Step 16: push four of the plastic pins into the holes
around to outer rim of the base so that the photodiode & IR
LED modules can be attached to the underside, as shown
in the photo below. We suggest you attach the two modules close to the driver module with the pin headers facing inwards, as we did.
Step 21: attach the ball housing to the underside of the
base, opposite the driver module, using two screws and
nuts (see photo below).
Step 22: attach the two microswitch modules to the underside of the base, one on each side of the bearing ball,
using two screws each. Note the orientation of the switches in our photos. The switch levers should face towards
the centre.
Step 23: now everything can be wired up to the headers on the driver module. Fig.1 shows where each lead
Step 17: using four more plastic pins, attach the two
pushbutton modules on the top side of the base, near the
wheels, facing inwards. You will need to bend the pin
headers up slightly so there is enough space to plug the
connecting leads on later (see below).
Step 18: attach the buzzer module on the opposite side
of the right-hand wheel using two more plastic pins, as
shown in our photos.
Step 19: attach the potentiometer module, on the opposite side to the buzzer module (behind the left wheel), using the same method.
Step 20: push the steel bearing ball into the supplied
housing (as shown directly right) as it provides extra support for the robot. It should be held in with friction.
siliconchip.com.au
Australia’s electronics magazine
January 2019 89
goes and also indicates the wire colour which should go to each pin. Start
by wiring up the buzzer, pushbuttons,
potentiometer, LCD, LEDs and motor
connections.
Note that you will almost certainly
end up with a mass of wires above the
driver module. It can’t really be avoided (see photo below).
In each case where there is a 3-wire
lead to plug into a separate board, plug
it in with the yellow wire closest to
the square mark on that board. The
exception is the photodiode/IR LED
modules, where the yellow wire goes
to the pin marked J2.
To keep the wiring relatively neat,
it’s a good idea to feed the leads between the two motor housings and
pull the loose ends back towards the
bearing ball end of the base.
Note that two of the 3-wire leads
pass from the top side of the robot to
the bottom, through the slots, and connect to either the photodiode/IR LED
modules or the microswitch modules,
Fig.1: connection diagram for the PicoPi Pro
Robot. Note the colour code on the seven
3-pin headers as they must match with the
provided wires. The 36V connection is not
used here – it’s only used to power larger
motors.
or a combination of the two, depending on which you want to use.
Step 24: determine how you will
mount the battery holder so that you
can access the on/off switch, replace
cells and fit the LCD screen. We attached the battery holder to the top of
the two motor housings using a stick
of Blu Tack split in half to create two
rectangular stacks (see lead photo).
The LCD screen is then attached to
the front of the battery holder using the
supplied velcro strips. I arranged it so
that the power switch was facing up
and next to the potentiometer module.
You may be able to attach the battery
holder using velcro as well; it all comes
down to how your wiring is arranged.
A more attractive method might be
to cut two small wedge-shaped pieces
of timber of around 15mm x 15mm,
with a height varying between about
10mm and 13mm. These could then be
glued to the top of the motor housings,
with velcro glued on top of the timber strips, to attach the battery holder.
Step 25: glue velcro to the back of
the LCD module and glue the matching
piece to the battery holder. You may
find that bending the 3-pin header on
the LCD module makes attaching the
wire lead easier. Plug the other end
of the wire onto the driver module as
shown in Fig.1.
Step 26: before attaching the battery
holder, connect the red and black wires
from the battery pack to the screw terminals on the driver board. As shown
in Fig.1, the red wire goes to the terminal next to the jumper (6V), while
the black wire goes to the middle terminal (GND).
Step 27: place the jumper shunt on
the 3-way pin header next to the screw
terminals, in the position closest to the
nearby IC. This selects low-voltage (ie,
battery) operation.
Step 28: insert four AA cells into
the battery holder, making sure it’s
switched off beforehand. Then attach the battery holder to the PicoPi
Pro Robot. We found with our battery
holder that it took quite a bit of force
initially to get it to switch on properly.
Be sure to give it a strong push if the
LCD doesn’t light up.
Step 29: the two LED cables are optional. You can place the LEDs wherever you want to. If fitting them, plug
the wires side-by-side into the 4-pin
header next to the programming interface on the driver module, with the
polarity shown in Fig.1 (if they don’t
work when you try them later, it’s easy
to reverse the plugs).
The Robot assembly is now complete and it’s time to program it to do
something useful!
Programming
The PicoFlow USB programmer
from PicoKit plugs into a spare USB
What does each module do?
Driver module – powers and controls all the other modules via digital and
analog signals. Also controls motor speed and direction.
Microswitch module – detects when the Robot bumps into something.
Photodiode & IR LED module – detects whether the surface beneath the
sensor is light or dark. This allows the unit to pick up and follow dark
lines beneath it.
Pushbutton module – gives you a way to control the Robot directly, eg,
start or stop a program or manually move it in one direction or another.
Potentiometer module – can control the motor duty cycle via PWM (or
some other parameter in your program).
Buzzer module – can be used to play sounds/music.
LED cables – use the red and blue LED to indicate status, as headlights
or just to make the Robot look nice.
LCD module – displays debugging details and text.
Resistor Colour Codes
90
Silicon Chip
No. Value 4-Band Code (1%)
o 7
10kΩ brown black orange brown
o 2
4.7kΩ yellow violet red brown
o 2
330Ω orange orange brown brown
Australia’s
magazine
o 2
180Ωelectronics
brown grey
brown brown
5-Band Code (1%)
brown black black red brown
yellow violet black brown brown
orange orange black black brown
brown grey blacksiliconchip.com.au
black brown
port and is supplied with a 4-pole
2.5mm jack cable which plugs straight
into the driver board and allows you to
reprogram the onboard micro directly
from their PicoFlow Alpha visual programming software.
If you have the later version of the
PicoPi Pro Robot with the 5-pin programming header, and a suitable programmer like the PICkit 3, you don’t
need the PicoFlow programmer.
The PicoFlow Alpha software is
available for Windows only and can
be used for free for two years. You can
download it from the link at the bottom of this web page: siliconchip.com.
au/link/aamb
Once you have installed this software, launch it and we are ready to
write our first program. It’s best to
start with something basic. For example, one which sets the micro’s output
pins to a static state which causes the
motors to run, eg, causing the Robot
to rotate in place.
Having launched the PicoFlow Alpha software, double-click on the “output tool” (which looks like a blue microcontroller). A window will appear,
as shown in Screen 1. This lets you set
the pins to a high or low state.
Screen 1 shows the simplest example program you can run on the
PicoPi Pro Robot. The program has just
two elements, the “Start” tool, which
looks like a traffic light, and the “Dig-
The PicoFlow USB programmer
will need to be used to program
the PicoKit if your robot only has
a 2.5mm socket. Otherwise, you
can use a PICkit 3 or similar.
ital Output” tool, which looks like a
microcontroller.
Drag and drop components from
the left-hand pane to the central pane
to create this program. Then doubleclick on the Digital Output tool to set
the output states.
In our example, we have pin C4 set
to high which causes the left wheel
to rotate forward, making the PicoPi
Pro Robot move in a circle. The motor
control pins are as follows:
C3 high – right wheel forward
B5 high – right wheel back
C4 high – left wheel forward
C5 high – left wheel back
Leave all the other pins in a low
state. For example, setting C3 and C5
both to high will make the Robot rotate in-place.
Once you’ve finished setting up the
output states, make sure that its “output” is fed back into itself so that the
program will keep the outputs in that
state forever.
You can right-click on the Assembly Code tab at the top of the window
to export the program as an ASM or
HEX file, but note that the HEX files
produced by this program cannot be
read by MPLAB IPE. So you will need
to use PicoFlow Alpha’s programming
support to upload code to the microcontroller.
You can do this by pressing the big
Program button at the top of the screen.
Make sure that the right type of microcontroller is selected in the dropdown box; it should be set to “14 Digital 16F505” or “14 Analog 16F506”.
The Robot also needs to be powered up
before programming. Make sure that
Screen 1: This is the simplest
program you can use with the
PicoKit. All it does is move
the left wheel forward (C4
high). Make sure that on the
Programming menu the value
selected is “14 Digital 16F505”
or “14 Analog 16F506”.
siliconchip.com.au
Australia’s electronics magazine
January 2019 91
all the leads are connected securely
as intermittent connections can stall
the programmer.
Note that the photodiode/IR LED
modules can potentially interfere
when programming, unplug them before you start programming.
If you’re having trouble getting it
to program correctly (freezes, fails or
takes too long), try putting some pressure on the connection between the
programmer and the board. We found
that the 2.5mm jack plug didn’t always
make good contact with the socket and
we had to hold it in to get the programming to work reliably.
You should see the LED on the programmer rapidly flash while it does
its job, which takes a few seconds. If
it’s still going after 10 seconds, then
something is wrong.
The Music Editor can be accessed by clicking on Edit Music within a Sound
tool. You can put notes into by selecting them as shown above, or you can load a
musicXML file found online.
A more advanced program
Delay Tool (hourglass). Again, by double-clicking it, you’ll bring up a menu
where you can set a time and units
(from microseconds to years).
We chose two seconds for our delay. Next, you need to place a Digital
Output Tool to control the motors. Set
C3 and C4 high similarly to how we
did it in the previous example. That
should make the Robot drive forwards
(assuming its motors are wired up with
the correct polarity).
Add another Delay Tool (say about
half a second), then use another Digital
Output tool to bring those same two
pins back to a low state.
Create a final Digital Output Tool
and connect this to the Sound Tool.
Once again, double-click the icon and
then go to the music sub-menu. This
uses musical notation to determine
the sound played on the piezo buzzer
using a square wave.
There are quite a few options you
can fiddle around with if you are musically inclined, to create reasonably
lengthy sequences of notes.
It accepts musicXML files, so you
can find sheet music online and load
it up in this software to replay on the
Once you’ve gotten the Robot to
move, you can move on to some more
advanced programs that take advantage of the different features of the PicoPi Pro Robot.
Next, we’ll write a program that
writes to the LCD screen, drives both
motors forward, stops, plays a small
tune on the buzzer and then restarts
the motors again and repeats.
First, we need a plain Start tool.
Then, we create a Comms Tool (it looks
like a serial port). Double-click on it
and set it to transmit mode. Then go
into the transmit sub-menu, set the
source to literal, data-type to DEC
(decimal) and value to 1.
Most importantly, the size needs to
be set to 9 bits and make sure the output pin selected is B4 (the pin connecting the LCD screen).
That step clears the LCD screen before any text is written to it.
Next, we create another Comms Tool
set to transmit, but this time we set the
source to text and again the output
pin is B4. Here, you can enter whatever message you want to display, up
to 32 characters long. Next, we use a
1-2
3
4
Silicon Chip
More experimentation
This Robot sample program and
several others are available as a free
download from the Silicon Chip website. Some of them take advantage of
the infrared sensors on the front of the
Robot to allow it to follow a black line.
There’s also a program that will move
a motor depending on which of the two
pushbutton switches are pressed.
You should be able to load each program, see how it works and start changing individual parts to see what does
what. You can then start to modify
your own, more advanced programs or
even create them from scratch.
Where to buy it
The PicoPi Pro Robot kit is available for $110 from: www.picokit.com.
au/Store/index.php?route=product/
product&path=2&product_id=122
You will need to make an account
to view prices and make orders. Otherwise, you can contact them via telephone at (07) 5530 3095.
5
This shows the complete advanced program, which is
available for free from the Silicon Chip website with a
few other example programs. Use the screenshots shown
at right to complete each major step of the program.
92
buzzer. The sound tool is fairly powerful, but it would help to know how
to read sheet music.
Australia’s electronics magazine
6
siliconchip.com.au
1
2
Connect the Start tool to the input of a Comms Tool, double click the Comms Tool and set it to transmit (left). Then in its
transmit submenu (right) the source should be set to literal, data type to DEC with a value of 1 and its size to 9 bits. The
output pin is then set to B4 of the micro.
3
4
A second Comms Tool (left) is linked to the output of the previous Comms Tool and also set to transmit, but the source is
set to Text. You can then enter whatever 32 letter long message you want to display and set the output pin to B4. A Delay
Tool of two seconds is then connected to its output (right).
5
6
A Digital Output Tool (left) is connected to the output of the previous Delay Tool, which brings pins C3 & C4 high, driving
both wheels forward. This is connected to a 0.4s Delay Tool before going to another Digital Output Tool which brings these
same pins C3 & C4 low again. After which it connects to a Sound Tool which outputs a small tune to the piezo buzzer, this
Sound tool is then connected to the first two second Delay Tool to form an endless loop.
SC
siliconchip.com.au
Australia’s electronics magazine
January 2019 93
|