Monday, 22 August 2016

Back in December 2015 I created my first Raspberry Pi Zero based Bot. It was a little ungainly with cables looping all over it and a USB WiFi dongle sticking out the side but it was relatively small, moved around and, at the time, I felt there was still plenty of room to make it more compact.

PiZero Bot V1.0

The aim of the next variant was to squeeze all the components into a mint tin that was only slightly larger than the Pi Zero itself. This proved something of a challenge and it wasn't until the release of Pimoroni's Zero LiPo board and Average Man's ProtoZero development board that I was able to get everything compact enough to fit inside.

The tin is only slightly bigger then the Pi Zero

I had never quite figured out how to best connect the AdaFruit PowerBoost to my PiZero without it getting in the way of the other components I needed to squeeze in, but the Zero LiPo fits snugly onto the Pi Zero PCB, taking up a minimal amount of space. With the power in place next step was to come up with a more minimal motor driver. After ordering a pack of L283D motor controllers (Buying several in case I killed one) I mounted it upside down on the ProtoZero board, after doing several dry runs to ensure I had enough space to fit in the wires and somewhere for the motors to attach.

A thin, PCB sandwich.

As this bot has no sensors (yet) it has to be manually controlled. After several attempts to squeeze in a USB dongle failed I settled on using a TTL to Bluetooth adaptor (A HC-06 module), soldering it to GPIO pins 15 and 18, the Tx and Rx pins on the Raspberry Pi. This particular TTL module is designed for 3.3V IO operations, so I didn't need to risk driving the pins at 5V, or trying to find space to fit a 5V to 3.3V converter. Using an app called 'BlueTerm' I could now connect to the serial console on the Raspberry Pi and send it commands from my phone.

Hardware is of little use without software to control it. Normally I'd be looking at connecting up a PS3 DualShock controller to drive the bot around, however that isn't quite so easy to set up over a serial link, so it was time to look at a different way to control a bot. A few weeks previous I had taken a look at the GPIO Zero python library and knew it had a variety of helper classes. Taking a look at the currently supported devices I found that it not only had a GPIO based Motor class but a fully implemented Robot class, allowing a 2 motor robot to be up and running in 3 lines of python.

A couple of tweaks to the connections to make sure the motors were going in the right direction and it was time to fit everything inside the tin. Being a metal tin it was conductive on the inside and, as I didn't want a short, I covered it as best as I could with Kapton tape, adding extra tape to the PiZero itself for extra safety.

With the motors and ball caster glued into place, and the battery held in place with blu-tak, PiZero Bot V2 was almost ready to go. I extended the python code to listen for the WASD keys to drive the robot from my phone and it was off for a test drive.

A relatively successful trip, although the battery appeared to be dying towards the end as it was starting to struggle to move. I know the battery wasn't fully charged at the time, so I'll have to test again to see how well it lasts. I do have a larger battery that is around the size of the mint tin, but I was avoiding using it as it adds to the height of the robot, and that somewhat defeated the point of making the smallest robot I can.

Of course its also a little tricky to control when driving it via key presses alone, but it should be possible to write an Android app, or similar, that can implement an analogue controller that communicates over serial to the Raspberry Pi.

As ever there is always more to do. I still want to add at least one sensor to this bot, probably a proximity detection one, so it can be left to drive around by itself. However with all the wires stuffed inside it there's not much room to extend it cleanly. I may have to look at designing my own PCB so I can get rid of most of the wires, freeing up some space to connect up a sensor, punching some holes in the front of the tin to allow it to be connected up. But that will have to wait for V3, as I have some other projects that need finishing up first.