PgBox Robot is a robot built upon two coupling boxes. The robot uses a Raspberry Pi as brain. These chapters will describe in detail how the robot is built and programmed.
Raspberry Pi B Rev 2 700Mhz single core is used.
There are many different Linux distributions for Raspberry Pi, PgBox Robot uses Raspbian, which is built upon Debian.
Raspbian install, follow this procedure:
- Download Raspbian Debian Wheezy:
- The following version is selected:2015-05-05-raspbian-wheezy.zip
- Format an SD card for ext4 with Gparted
- Make sure you know what you are doing to format the correct disk.
- Unzip the file
- Open terminal in the folder you unzipped 2015-05-05-raspbian-wheezy.zip
- Type the following command to write the Raspbian imaged to the SD card, in this case the SD card is on /dev/sde
- sudo umount /dev/sde
- sudo dcfldd bs=4M if=2015-05-05-raspbian-wheezy.img of=/dev/sde
- Be sure to write to the correct disk sda is usually the operating system disk and you ruin your operating system if you write to this disk, the disk used here is sde.
- Run: sudo sync
- ync forsikrer å flushe minnet slik at det er sikkert å ta ut minnekortet.
After installation, the memory card is inserted into the Raspberry Pi device.
Use SSH to log on to your Raspberry Pi after inserting the memory card and booting up.
- ssh email@example.com
- password raspberry
- This is the IP address your Raspberry has received on your network.
- Configurate Raspberry
- sudo raspi-config
- Update your raspberry:
- sudo apt-get update
- sudo apt-get ugrade
Now the Raspberry Pi should be ready to use. And we can start programming and connecting devices that are going into the robot, such as motor drivers, sensors, etc…
There are several ways / programming languages you can use to program a robot on the Raspberry Pi.
Initially, Python will be used, which will put some real-time restrictions on the robot. But in most cases, the control system will respond quickly enough to perform the robot’s tasks without problems. If you have programmed a little in Python, it is quick to develop programs for such a robot, as much is available in libraries. A good number of libraries have also been created for Raspberry Pi. C code might be easier if you want to make drivers.
You can also program in C, C ++ and otherwise everything else of programming Linux has to offer.
CoDeSys is also a PLS programming tool that you can use on Pi. This makes your Pi a PLS. CoDeSys for Raspberry Pi costs 50 Euro from store.codesys.com.
Motors, wheels and steering electronics for the drive module are all purchased on e-bay and mounted in a junction box.
The robot has two wheels one on each side and one ball wheel at the back.
To control the motors, two channels are used from an RC servo controller, which is controlled using the UART serial port RS232. This outputs PWM signal correspondingly for control of RC servos.
There is a motor driver for each motor, these are RC motor drivers for brush motors. It is important that these are driverless brakes, otherwise it will be difficult to control the robot when reversing. These motor drivers are controlled from the RC servo controller board.
There are two wheels, this for the robot to be able to turn around its own axis. This is the most common for this type of robot that uses odemetry control. The ball wheel helps the robot to turn around its own axis.
360deg linear potmeters are mounted as encoders on the wheels.
- Motors and wheelsl: 2 sets Smart Car Robot Plastic Tire Wheel Tyre + DC3-6V Gear Motor For Robot
- Ball wheel: Roller Ball Bearing Metal Caster Flexible for Smart Car robot
- Servo driver card: 16 Channels Servo Motor USB UART Controller Driver Board For Arduino Robot MCU
- Motor driver: RC 10A Brushed ESC Two Way Motor Speed Controller No Brake For 1/16 1/18
Motor driver installed
To be able to use both the mains voltage and the battery on the robot, a power supply has to be installed.
Most of the robot uses 5V power, similar to USB power.
To obtain sufficient power, a “DC-DC Converter 12V to 5V 3A Step Down Power Supply Module Micro USB Waterproof” has been used.
Link: DC-DC Converter 12V to 5V 3A Step Down Power Supply Module Micro USB Waterproof
There are also fuses, an on / off button, and a 12V power in plug.
The last picture here shows a series of pins for 5V and GND.
As the pictures show, most of the robot is attached with either screws or glue gun.
To be able drop the cord on the robot we install a Wifi device, WiPi, which is a USB wifi adapter, designed for Raspberry Pi.
The WiFi adapter has to be configured for the network.
pi@raspberrypi ~ $ sudo cp /etc/network/interfaces /etc/network/interfaces_org
pi@raspberrypi ~ $ sudo jed /etc/network/interfaces
The interface file:
iface lo inet loopback
iface eth0 inet manual
iface wlan0 inet manual
iface wlan1 inet manual
Change wlan0 to:
iface wlan0 inet dhcp
wpa-ssid “Your network SSID”
wpa-psk “Your network passord”
pi@raspberrypi ~ $ sudo ifdown wlan0
pi@raspberrypi ~ $ sudo ifup wlan0
Now the robot will connect to the network.
Ultrasonic range sensor HC-SR04 is installed at the front and back.
The camera module is a custom camera module for Raspberry Pi.
It connects to one of the sockets on the Pi board, and uses the CSI interface.
The CSI bus has ha high data rate whish gives almost no delay on the camera, compared to a standard USB camera which can have a delay up to a couple seconds.
The Custard pi 3 card is a 12 bit 8 channel analog io card for the Raspberry Pi. The card is has a stack connector for the Pi. SPI interface is used for the data transfer.
Further configuration will come later this week.