To summarize what was
decided so far:
Mikronauts "EZasPi" prototyping board specifically to make
it very simple to build circuits that need to connect to servo
connectors, headers, screw terminals, and 300/600 mil DIP
chips. The short bus lines do most of the wiring for you, as
long as you place the components carefully.
First, I added the upper resistors in the voltage divider
for all eight Pi GPIOs that I wanted to bring out to a servo
header. The placement of the parts is critical in order to
minimize the number of jumpers that will be needed.
Next, I added the 4.7K SIP resistor network, placing the
common lead farthest from the edge of the prototyping
board. The 3x8 servo header was next; I located it so that
two rows of
pins were
placed into two
of the power
busses, and
the third pin
into the bus
connecting
to the
corresponding
resistor.
1. Use a voltage divider for 5V to 3.3V bi-directional
interfacing.
2. Use continous rotation servos for the drive motors
and a standard servo for panning.
3. Use a regulated 5V power bank to power the Pi and
a 4.8V NiMH battery pack for the motors.
4. Use an Ardubot chassis.
5. Use a SeeedStudio ultrasonic range sensor.
Building the Simple Raspberry
Pi Robot Controller
I will freely admit that I am not particularly fond of
cutting and stripping a lot of wire, so I designed the
Photo 6: EZasPi prototyping board.
SPRITE Demonstration Code
How to Program SPRITE
My demonstration program for SPRITE is unimaginatively called
demo.c. After initializing the robot, it presents a simple text menu
of actions:
You can program SPRITE in a number of ways:
1. Local console using a USB keyboard and HDMI monitor.
2. Local desktop using a USB keyboard, mouse, and HDMI
monitor.
3. Remote console using SSH.
4. Remote desktop using the RDP protocol.
The forward/backward/left/right commands take an optional
single digit argument which specifices how many seconds to do the
action for. If a digit is not specified, one second is assumed.
The sonar scan demonstrates using the panning head to look in
different directions, and it shows the range to the closest object at
each servo position it tries.
If you use a local interface, just plug in your keyboard,
mouse, and monitor, and type away. This works, but you have
to plug in a keyboard and monitor (and a mouse for a
graphical desktop, so if you are using Wi-Fi you also need a
powered hub), then shut down, unplug it all, run the test,
re-plug ... rinse and repeat for debugging ... it’s very time
consuming.
The random walk code keeps going forward until the range
sensor finds something closer than 30 cm. Then, it turns left in place
until it finds a direction
with at least 50 cm to
travel.
while (1) {
while (last_range > 30) {
ping();
delay(100);
servo(LMOTOR, 500);
servo(RMOTOR, 3000-500);
}
puts("Obstacle detected");
while (last_range < 50) {
ping();
delay(100);
servo(LMOTOR, 500);
servo(RMOTOR, 500);
}
}
You will notice that
if you go forward or
reverse, the robot may
not travel in a straight
line. This happens due to
variations in servo
motors, and can largely
be compensated for by
adding a compensation
factor to the code.
My personal preference is a remote console over SSH. I
use the excellent free Pu TTY SSH client, and I connect to the
dynamic IP address my router assigns to SPRITE. Fortunately,
my router has a page that shows the IP address of attached
devices, so I do not have to use a static IP address (and the
more complicated Wi-Fi configuration it requires). You can get
the latest version of Pu TTY at www.chiark.greenend.org.uk/
~sgtatham/putty/ download.html. Android and iOS SSH
apps are available in their respective markets, and Linux
distributions tend to come with SSH clients pre-installed.
You can easily connect to a remote Raspbian desktop
running on SPRITE. All you need to do is install XRDP as shown
earlier, and use the remote desktop client supplied with
Windows (or any other RDP client) or the free clients available
for Android and iOS devices. You can then open a terminal on
the remote desktop and away you go!
Listing 1: Random walk
with obstacle avoidance.
You can use any text editor you want to use to write
C/C++ code for SPRITE — Vi, Nano, and Joe are just a few
examples of console based editors.
SERVO 01.2014 61