I printed out the front half of my Raspberry Pi camera module mount. It serves two purposes, providing a way of mounting the camera on my robot, and giving me a place to attach the wide-angle lens I’d bought earlier.
Before I pick a battery I need to know what power requirements my robot is going to have so I took it into the hackspace to test. I hooked it up to one of the power supplies then ran all the systems, so Streaming video off the Raspberry Pi over wireless whilst running the motors. I weight it down with a large motor (the big black thing) and then provided resistance, it peaks at about 1.6 amps.
In the video you can also see the new side mounted Raspberry Pi and the base of the ping-pong ball hopper.
Detail view of the side mounted Raspberry Pi and the base of the ping-pong ball hopper:
I’m currently powering my robot via cable and mains adaptor. This works fine but. I need to power it by battery so it can roam around a room. I’ve looked at which batteries to get, and I guess I’m going to get something like a NiMH battery. LiPo sound like a good idea, except for the whole exploding/setting on fire thing, the robot will be left alone while charging and if I burn down the office no-one is going to be pleased. So I’m thinking of buying something like this NiMH battery for my robot.
The problem I have is how to charge the battery. The robot needs to “dock” and charge unattended, rather than have someone change it’s batteries manually so standard consumer battery chargers are out. I also need to get charging status somehow so I can get remote status / prevent the robot from moving off until the battery is charged so some sort of SPI/I2C interface will be needed (the docking station will be a Raspberry Pi).
Unfortunately I have 0 surface mount skills, or confidence that I could make a circuit out of that that would work so I need some help:
The MotorPiTX I’m using for my robot comes with a power switch that can either hard power-off the Raspberry Pi, or signal software running on the Pi to do a clean shutdown:
Purely to control the ATTiny chip, to turn on the Pi, but also to shutdown as well. With the Pi off, pressing it once will turn the Raspberry Pi and MotorPiTX board on. With the Pi active, pressing it again will set GPIO 8 high, signalling that the button has been pressed and should be used to shutdown the OS. See Installation for more details.
Holding the button for 3 seconds will cut all power, useful if something goes wrong, such as the Raspberry Pi crashes and refuses to respond.
I’d never bothered to write any software to listen for GPIO8 going high before, I’d always relied on being able to SSH in to shut the machine down. Recently however I’ve been playing with the Pi camera, this was causing the Pi to pull too much power and it would shut down the USB ports cutting off my (wireless) SSH access and my USB keyboard both at the same time leaving me with no alternative but to hard power off. It was time to do something with that GPIO8 pin signal, and so I wrote motorpitx_power_control.
motorpitx_power_control is simple, from the README:
A program to listen for MotorPiTX power button presses and cleanly shutdown your Raspberry Pi.
It’s a really small program written in Go that checks the status of GPIO8 every half a second and initiates a shutdown sequence if the pin goes high. I’ve included instructions for building and installing on Arch linux, but it will work on other distros too.
I think Go is a great language for the Raspberry Pi. Go creates small, efficient, statically compiled binaries that easily fit within the resource limits of the Raspberry Pi. motorpitx_power_control is a relatively small 2.5MB binary that uses almost no CPU at all.
The project requires a working Go install to compile, this is simple enough to get on Linux and OS X, check your package manager or homebrew. If you have Go installed head over to the motorpitx_power_control Github page and clone the repo. Follow the build instructions, copy the binary file to your Pi and run it. That’s it!
Check the Contributing & TODO sections of the README if you want to contribute back to the project.
I’ve re-designed a prototype robot mount in OpenSCAD as Sketchup wasn’t up to the job. It took a while, you have to program the model in a text editor so there’s lots of trial and error. Will have to wait to print it to see if this design will work.
I’ve made some improvements over the original design, most notably thicker side walls and motor mounts, more accurate measurements and added the cross-pieces with a Raspberry Pi mount.
Here’s the original Sketchup design for comparison:
Sketchup was great, really easy to use, the only problem was that it seemed to create invalid model files.