The First Rover Car

Luís, Bjørn, Pedro and me built a rover car, within Pearson’s Hackathon 2013.

We work at Fronter, a Pearson’s company, and Luís bought a ZL-4 chassis kit car on dx.com, and just wanted to make it work with his Raspberry Pi. His knowledge on electronics was near zero, so was mine. Bjørn knew a little, but we basically started from scratch.

So, first things first: try to get sole LEDs working. We followed a beguinner’s guide on GPIO and managed to light some LEDS, using the WiringPi library.

It works!

In a nutshell, we picked up 4 GPIO pins, and started writing, on a console:

gpio XX mode out
gpio XX write 1
gpio XX write 0

Where XX is the GPIO pin number. That felt really good.

Next step was to use those four GPIOs to control the engines (one on each wheel). The chassis kit had fixed wheels, so the steering could be made only by asymmetrically turn on and off the engines. I was afraid that we had to somehow had to control the engine powers with PWM, but turns out the engines were not that powerful, so simply turning them on and off was enough.

To do that, we used a dual H-bridge, and Luis had bought This H-Bridge from dx.com, because he read somewhere that he was going to need it. Only Bjørn knew a little what it does. Here is the H-Bridge that we used.

Assembling a rover car

In a nutshell, on the Raspberry GPIO, we can send/receive two signals: HIGH, and LOW. HIGH is given by a 3.3 Volt, and LOW by 0 Volt. That is what turned on those LEDs. Yet, the wheel engines could be operated with higher voltages, such as 6 or 9 Volts. If you send that 3.3 Volt signal to the engine, it will be too slow.

What the H-Bridge does, is to channel the energy from, say, a 6V or 9V battery pack, depending on the commands received from signals, such as the GPIO ones. So, with 4 GPIOs connected to the H-Bridge, we could send 4 signals:

1 – Left engines forward
2 – Left engines backward
3 – Right engines forward
4 – Right engines backward

And then we reached this state, where we could finally turn the wheels using the console!

Assembling a rover car

So, with this second milestone, we wrapped all this into Python scripts (you can check them on Luís’ Github repo). We created a rudimentary HTTP interface to control the car, allowing us to press buttons on a web page to execute each python script.

Assembling a rover car

Just for the fun, we also added a webcam feed (using motion — just type sudo apt-get install motion, connect it, and check for the localhost:8081 feed). Here is a YouTube video of the car, assembled so far:

The final touch was adding a ultrasonic sensor to measure distances.

We started this hackathon knowing nothing about electronics, and we now could wire the ultrasonic sensor in 5 minutes! It has 4 pins: power and ground were easily connected to pins 2 and 6 of the Raspberry Pi (5V and GND), and the other two pins (trigger and echo) went to other 2 GPIOs. This sonar.py script helped us understanding how to use the sensor, and we of course, added it as a emergency brake to keep our car from hitting the walls.

The hackathon is over, and we were quite happy on what we’ve accomplished. Yet, we felt that there was much more to do, so… that’s the queue for the next post.

Leave a comment