Here's what the hardware currently looks like:
The wires to the neo-pixel header have been connected, and there are two flying leads - a purple and a green, which are attached to the two pins nearest to the GPIO pins on the Bot Board's 6-pin ISP header near the blue power LED. These are for when the Bot Board's Arduino needs to be re-set - they just need to be momentarily touched together to do a micro-controller re-set.
The rainbow-coloured 5-wire strip is running from the Bot Board's Serial interface to a USB to CP2102 TTL UART Module which I purchased for £3.70 from ATelecs on ebay. This module has a USB connection for inserting into the PC's USB socket.
Be careful not to connect both the Pi's power supply (through the Pi's micro USB connector) and the UART module to the PC at the same time. There is currently no battery in the PiBot, and in any case, its main switch is in the off position. This is a third potential power conflict, so pay particular attention to what power sources are connected!
I thought I would start with a clean sheet - a new SD card, for the PiBot. Actually, it's an 8 GB micro SD card slotted into a micro SD to SD adapter. Here are the steps I took:
- Download SDFormatterv4 from https://www.sdcard.org/downloads/formatter_4/eula_windows/
- Unzip this and put the SD adapter card into the USB/SD adapter, and run SDFormatterv4
- Download NOOBS from www.raspberrypi.org/downloads, unzip and copy the files onto the SD card. The NOOBS_v1_3_4.zip was only 1.27GB - much more compact than the images I used to download.
- Put the SD card into a Model B Raspberry Pi (because it has an Ethernet connector), connect to the WiFi Router via Ethernet, and fire up the Pi
- Insert the WiFi dongle (the Edimax appears to be the most recommended)
- Start the WiFi Config program on the Pi's desktop, click on the Scan button, and double-click the required network from the listed networks which have been found.
- Choose TKIP encryption, enter the WiFi Wireless Key code into PSK, then Add - that's it!
- Move both the Edimax dongle and the SD card to the PiBot's Pi (mine has a Model A Pi).
- Download PUTTY (I used this before in an earlier post) to the PC
- Download TightVNCViewer to the PC (again I used this before in earlier posts)
- On the Pi, do a sudo apt-get update, and sudo install tightvncserver
- Run tightvncserver by typing vncserver:1 (I used the same command as before - vncserver:1 -geometry 800x600 -depth24 - the extra attributes -geometry 800x600 specifies the size of desktop to be created - the default is 1024 x 768
-depth24 : 24 specifies the pixel depth in bits of the desktop to be created - the default is 16 and other possible values are 8, 15 and 24 - don't use anything else.
- Run PUTTY and TightVNCViewer on the PC (you can save the VNC session for later convenience) and hey presto - we have the PiBot's Pi desktop running on the PC, through WiFi!!
- Download the driver for the USB to CP2102 TTL UART Converter from http://www.geeetech.com/Documents/CP2102%20USB%20Driver.rar, unzip, and run the installer file.
- Download the Arduino sketch for the Bot Board's Arduino from https://github.com/pi-oneers/bot-firmware and upload to the Bot Board via the UART Converter.
Okay - this brings us to the point where we can communicate with the PiBot from the PC over the WiFi network. But we still need to fill the PiBot's brain with thoughts and intentions which make it do some proper robot stuff!! Even before we do this, there's some further preparation to be done - the system needs to be configured:
- Enable the SPI interface on the Raspberry Pi:
a. first do a sudo raspi-config, choose Advanced Options and then choose Enable SPI interface by default
b. do a sudo nano /etc/modprobe.d/raspi-blacklist.conf to open that file for editing, and make sure that the SPI line is NOT blacklisted, by making sure the line is commented out with a '#' at the start
c. restart with a sudo reboot
d. check that the module has been loaded with a lsmod | grep spi_bcm2708
- Install the SPIdev python module:
sudo apt-get install python-dev
cd bot-command && sudo python setup.py install
- Download the PiBot code repository from Github
The following command can be used to do a software update:
git clone https://github.com/pi-oneers/bot-command
- Test the hardware:
There are some test programs in the /python-spi/bot-command/examples folder:
which should put the hardware through its paces. These can be executed by using, for example:
sudo python test_pibot_hardware.py
or sudo python drive_in_square.py
or sudo python monitor_ultrasonic.pyor sudo python robot_teleop.py
And here's the screen shot to show the headless Pi's desktop and the Arduino IDE with the Bot Board's sketch after loading.
And I got it to move! Have a look at the following video - it's battery-powered, WiFi-enabled, Arduino-firmwared and controlled by python on the Raspberry Pi!
This python script - drive_in_square.py - simply sends the Bot around the sides of a square (for ever - or until the batteries run out, or, in this case, it collides with something solid!) I also got the script monitor_ultrasonic.py to run successfully - it gives a continuous reading of distance from the ultrasound transducer to an obstacle, in centimeters. There are a couple of other test scripts which I have to get going yet - but it's so exciting that the Bot has come to life!!
Next time I will try to explain the software and develop some more python programs.