Wednesday 30 September 2015

ElMo Cannon Creation

A long time ago, I posted about adding a solenoid to ElMo, that we could use to kick the ball as part of the skittle challenge.  Well, I found that Tris10 Robotics sell something called the kickball kit - a whole heap of capacitors that can be charged up and then discharged rapidly into the solenoid.  The force could apparently puncture a football - which appealed to the hooligan in me :)  We sent them some cash and a parcel arrived from Australia.  This weekend it was time to put it together.

The kickball comes as a kit of parts
that need to be soldered to the circuit board


 The finished circuit - comprising a few headers, 3 capacitors, a relay switch, a few resistors, a diode and a transistor
I was sceptical as to whether my soldering skills were up to the job - but it works!  For now we have only tested it using the supplied arduino code - I thought I'd rather fry the arduino than the pi if things went wrong!

The solenoid is attached to the kickball controller using 2 pins.  There are two more pins for Vin and ground - I used a 9V rechargeable battery first of all.  Another pin is used as the trigger (set the pin high for 70ms to trigger the 'kick' - you then need to wait ~10s for the capacitors to recharge) and a final optional pin can be used to query the charge of the capacitors (I didn't connect this - I don't think we need this for PiWars where we only need one kick).

9V was certainly enough to move the test ball - but it wasn't enough to kick the ball from a standing start and knock any skittles over.  The diddyborg we are using for ElMo has a 12V battery pack and when we connected that we did manage to knock over one skittle - yay!  I finally tried wiring up 2 9V batteries to give 18V and that felt pretty punchy - we managed to knock over 4 skittles with that.  So we might power ElMo with 18V (for that challenge at least).  It may be that with the robot pushing the ball, the 12V kick will be enough - once we have a moving robot (hopefully this weekend!) we can think about how to attach the cannon and do some more tests (and post some video)

Monday 28 September 2015

Controlling Raspberry Pi With A PS3 Controller

Lets try and get our PS3 controller talking to the raspberry pi. I started by attempting to do this on an old raspberry pi model B, but eventually realized this would require 3 available USB sockets - for the keyboard, bluetooth dongle and PS controller.  I suppose you could remove the keyboard and login in via ssh, or get a USB hub, but I decided instead to switch to using the raspberry pi 2, which has four USB ports on the board.  I am going to want the controller on ElMo in the end anyway.

There are some instructions on the diddyborg website (in the getting started tab) explaining how to do this, so lets give it a go.

First, install the joystick package

sudo apt-get -y install joystick

which installs and sets up evtest, inputattach and joystick.
I then need to look at another diddyborg page to get the details about installing QtSixA, also known as sixad

sudo apt-get -y install bluez-utils bluez-compat bluez-hcidump checkinstall

that installs a whole heap of additional packages as well as those listed.  I'm not convinced we will actually need all of those, but no matter.  Go make a cup of tea while that lot is unpacked and set up.  Then, some development libraries,

sudo apt-get -y install libusb-dev libbluetooth-dev joystick pyqt4-dev-tools

ahh - so you don't need that first install of joystick, if we include that here.  Another bunch of packages to install...

wget http://www.pabr.org/sixlinux/sixpair.c

gcc -o sixpair sixpair.c -lusb

wget http://sourceforge.net/projects/qtsixa/files/QtSixA%201.5.1/QtSixA-1.5.1-src.tar.gz

tar xfvz QtSixA-1.5.1-src.tar.gz

cd QtSixA-1.5.1/sixad 

make 

sudo mkdir -p /var/lib/sixad/profiles

sudo checkinstall

the checkinstall command creates a package that we can manage - when prompted, I called mine 'sixad'.  I didn't change any values, I just hit enter at the next prompt and it all seemed to go OK - I now have a package that could be removed at a later date.
Now, attach the bluetooth usb module - mine is a dynamode USB bluetooth adapter, bought from piborg at the same time as I bought the diddyborg

and attach the ps3 controller via it's usb cable and pair them using

~/sixpair

which says something about setting master bd_addr to some hex address - presumably that of my controller?  Now start the sixad software and press the PS3 button when prompted to do so

sudo sixad --start &
sixad-bin[8077]: sixad started, press the PS button now
sixad-bin[8077]: unable to connect to sdp session
sixad-bin[8077]: Connected Sony Computer Entertainment Wireless Controller

that looks promising?  I didn't feel it vibrate though, so lets try

jstest /dev/input/js0

Result! When I hold down buttons or move the joysticks, I get a notification that the button is on, or see that the axes coordinates change.  I think we are in business :)

I tried shutting down the pi, which also appears to turn off the ps3 controller - excellent :)

When I restart the pi, I don't need to rerun the sixpair program - that would appear to be a one off operation.  I just need to restart the sixad daemon.  I could probably do that as part of the boot up, but I would need to know when to press the ps3 button - which might be confusing if we don't have a terminal to look at?  So perhaps best to do it manually - at least until I have more of an idea of what I am actually doing :) - or maybe we could flash an led to alert us as to when we should press the button?

So I just need to remember to a) make sure the ps3 controller is charged and b) that I start the sixad program and pair the controller when I reboot the pi.

Google tells me that the ps3 controller should be good for at least 12 hours or so, so it ought to last the day at piwars without needing to worry about it.  Charging takes around 2 hours.

Tuesday 22 September 2015

ElMo Construction - session two

This weekend we continued the construction of ElMo - we drilled some holes in the perspex base using a dremel drill press

These will be used to bolt on some vex metal that we will attach sensors to

We also soldered wires to the motors and connected them up to the picoborg reverse controller

Next time we will be connecting the pi and the batteries and if all goes well we may be in a position to run our first test program - exciting :)

On the software front, we also managed to get a PS3 controller to connect to a raspberry pi - more details in a later post.  There are a few more package installations required to use the diddyborg, I'll be downloading those this week

Thursday 17 September 2015

ElMo Construction - first session

This week we got started on construction of ElMo, a modified diddyborg.  We're basically following along with the excellent build  instructions from the piborg website.
here are the diddyborg bits and pieces in their anti static bags

screwing in the motor brackets was a bit fiddly

adding the motors

and the motor hubs

With the picoborg reverse in place.  And we just couldn't resist trying the wheels for size - but will take those off again while soldering

All quite straightforward so far.  A couple of minor gotchas - we managed to put two of the motors in upside down, so had to do those twice.  We also put the raspberry pi pillars in the wrong place, so that needed fixing as well.  We have invested in a new raspberry pi 2 model B for ElMo - it has a beefier processor and more GPIO pins than the original model B.  As I type, I am upgrading the packages on the original model B - we plan to use that for testing some of the sensors before adding them to ElMo.  That just required (as the root user)

apt-get upgrade

Next time we are hopefully going to bolt on a few bits of vex hardware to attach our sensors to, then get the wires to the motors soldered.  We have about two hours of soldering experience between us, so that might be fun!