Pi Wars – Part deux

Team Cyberchondriac – Pi Wars 2015

Further challenges….

Once the line following code was written and the sensor logic was working well I turned my attention to the other challenges. Next was proximity detection and I, like a lot of other contestants, decided to go for what I now know is the fairly ubiquitous HR-SC04 (I can feel my inner geek rising as I type that!) It works well with the Pi, there are numerous posts on getting it to work in Python and I didn’t really foresee too many problems (!)

IMG_0081

(hr-sc04 – Don’t cha know squire! – £2 each on ebay)

So, wired one up and started to test….

IMG_0082

Wasn’t getting any results from it at first and thought that I had more than likely soldered it together incorrectly – start with the physical connections first. Found what I thought was my error so swapped the connections to where I thought they should be.

Hmm…. wonder what this screen means? Never seen that one before…..

IMG_0089

After that little lot, a brief pause and then a shutdown. Nothing from the Pi. Nada. Zilch. Diddly squat.

And so, it came to pass that I had indeed managed for the first time ever to fry a Pi.

IMG_0094

(we held a small ceremony for our dear departed friend who gave his all for the cause)

After that fairly significant set back, I decided that I needed to get the sensors working, but away from the bot so I didn’t melt anything else. I was looking for a simple circuit I could work up to test them easily. It was the last week in October and with Halloween just around the corner I thought something a little spooky would be appropriate – ‘Pumpkin Pi!’ came the shout from my ever inspiring wife. So – a proximity detecting pumpkin with flashing lights and screaming noises when someone approaches it – how hard can it be? (must stop saying that)

Was actually fairly straightforward. Found my error in the proximity circuit, and cobbled together a Flip Flop Circuit that could turn on 2 sets of 3v white LED Christmas lights. I added an mp3 sound file, put together a very simple Python program and mounted the whole lot in a plastic box with some batteries.

IMG_0181

(pumpkin innards)

This all then went into a carved pumpkin – I was pretty pleased with the results!

IMG_0193

The project got picked up by the Pi foundation and added to their list of Spooky Pi projects for Halloween – you can see the pumpkin in action on the Raspberry Pi site here Interestingly in the video you can hear the ultrasonic ‘bips’ that the sensor puts out.

Where were we? – Oh, yes… PiWars! Enough distractions, now I had a working proximity circuit and this was removed from the pumpkin and added to the bot immediately Halloween was over.

More building, more breaking.

I do seem to have taken *almost* as many backward steps during this project as forward ones. I have been following the progress of other contestants via the blogs and Twitter and have often seen late night crisis posts from folks where things just aren’t working as they (blummin well) should! The complexity of building a bot to complete in all the challenges should definitely not be underestimated.

On rebuilding the bot with a new Pi and the proximity sensors, nothing worked. Again. This can all be rather frustrating sometimes – and that’s putting it mildly! Out came the multimeter once more to locate the source of the problem and fortunately fairly quickly found that the problem lay in my dodgy soldering skills. On putting everything back into the box I had managed to bend over one of the wires which had snapped the track clean off the stripboard.

broken

(found it – needed a magnifying glass to see it with my eyes though)

Once that was fixed and re-soldered, I finally had a working bot again for the first time in quite a while. With only 3 weeks to go until the competition I had been starting to get a little concerned!

Skittles.

Must confess, was looking forward to this one since the description of the challenge was updated to include…

“You may push or propel the ball using a mechanism attached to your robot.”

Ooh – now that got the old grey matter working overtime :-) I spent many hours considering how I would do this. Must confess I wish I had heard of ‘kicker solenoids’ at this point! – I believe at least one other team is using this solution. I however decided to opt for a far more Heath Robinson approach and designed (in the loosest sense) a spring powered cannon to propel the ball. I then somewhat prematurely put this video up on YouTube…

Sadly at this point, it was just me holding the end of it. There was no trigger mechanism to speak of – yet.

The spring is the throttle spring from a 1984 Mini Metro – actually, it’s half of the spring. I was amazed at how much energy can be stored in a fairly small piece of metal. Working out a successful way of firing the cannon was going to take many nights of head scratching, many failed attempts at printing 3D parts for it and an awful lot of swearing and bashed fingers.

I’ll tell you more next time.

Follow me on Twitter @davejavupride – I have been posting regular updates there and will do so until the competition.

 

 

 

Read More

A little late to the Pi Wars blogging party!…

Team Cyberchondriac – Pi Wars 2015

If you’re here and reading this, it is exceptionally likely that you already know about Pi Wars.

If you don’t – go here now Pi Wars (Or not a lot of what follows will make much sense)

This is more of an introduction to the bot as it’s now a bit late for running updates. It was always the intention but life gets in the way. I am currently studying full time for an MSc in Computer Science, sadly I wasn’t able to make building the bot part of the course!

I found out in August that I’d been selected to take part in Pi Wars 2015. Yippee  I thought, no problemo as I had recently completed the build of my first ever rover type bot which I christened ‘Coder-Bot’ as it used the Google Coder IDE. I then read the requirements for the Pi Wars challenges and realised what I had was a looooooong way short of what would be required to compete effectively.

Additionally the Coder-Bot code was not exclusively written by me and for a competition where the code will be judged, I saw this as cheating a little so wanted to write everything from scratch.

coderbot

Let the planning commence…

One challenge I set myself with the bot was that *nothing* should be bought at all wherever possible. So, the main chassis is simply 2 recycled boxes and everything else is made from recycled bits of junk / wire / tubing and stripboard.

One end is a project box that is now on it’s nth incarnation. The other is an old electrical box. Just to further complicate matters I decided to add rudimentary suspension by linking the two boxes with a rotating joint so the two sides are articulated. You can see an early, botched attempt at getting this to work in the photo below.

IMG_0146

(later version was significantly more successful)

I also did not want to buy any motors or controller boards – after all, how hard can it be?

Um… Very. Trying to find 4 matching scrap motors with enough juice to drive anything turned out to be hoping a little too much. I therefore relented and purchased 4 ‘proper’ geared motors from Pololu. They are fantastically torquey but this does mean they are not particularly fast (I don’t think I’ll be winning any speed competitions! But at least they are all the same speed and they do match.

Also it means there’s none of yer fancy pants controller libraries and such niceties, just a whole lotta GPIO mangling & wrangling!

First Hurdles

This is my first real foray into physical computing and I wanted to learn and build as much as possible. I spent many evenings researching and learning about motor control, PWM, dual H-bridges etc etc etc…. And eventually I ended up building a 2 way H bridge from 4 relays. This is built on stripboard and gives bi-directional control of 4 motors from 4 GPIO pins which is perfect for this type of rover. Having never really soldered before, I don’t think I be winning any build quality trophies but at least I can say it’s all my own work (whether that is a good thing in the long run remains to be seen)

I wrote the basic control system in Python, using PyGame to add very simple manual keyboard controls for driving. This works very well with no lag and means I don’t need wifi to run on the day.

Then I started to look at the autonomous challenges and started counting the GPIO pins that would be required for all the sensors and widgets. I was using a Pi Model B and it was looking likely that I was going to be several pins short of a robot picnic. So – new toys time, I broke the ‘don’t spend anything rule’ for a second time and splashed out on a shiny new Pi 2. Much excitement. Many pins.

Except the number of pins I needed to use and specifically the change in location of the power socket on the Pi 2 meant the current housing was no longer going to be large enough so a change was required.

First Rebuild

Having realised I was going to need to increase the size to hold everything I found an electrical box that fits everything nice and snugly without being too much of a squish.

IMG_0298

(Loads of space – woohoo! – notice the shiny new centre joint too)

The centre joint is made from 2 tightly fitting tubes, one fixed to either box so that they can rotate freely. There is then also an internal overlapped piece  to prevent the two from separating.

Once I had the new box and joint in place with all the wires routed nicely through I could then mount the new Pi in place.

Let’s get some new wheels, baby.

I wanted big. I wanted funky. And fortunately I joined the amazing Cheltenham Hackspace in June this year. Whilst they don’t (yet!) have a laser cutter – (I’m looking at *you* AverageMan) in July they were just finishing putting the final touches to the 3D printer they had built. So, I joined the queue to have a play. I learned a little OpenSCAD a long the way – a really cool open source tool for designing stuff for 3D printing. It’s almost language based and you use script commands to build cool and interesting stuff.

IMG_0392

(the first wheel takes shape)

IMG_0048

(and here’s the first two wheels with some nice tyres all ready to go)

It was then time to look specifically at some of the challenges and work out exactly what was required.

The Challenges

Line Following – Autonomous.

Mark C. at Astro Designs designed these lovely little sensor boards which he was using for his Dalek-Pi (see @Dalek_Pi on Twitter) He graciously not only donated 3 for my bot, he also gave me a brilliant lesson in line following logic.

IMG_0328

(the sensors, all lined up and ready to.. um, sense)

And now for the bit that actually makes it all work…..

IMG_0319

(Eek – nope, not a Scooby-do. At least not to start off with. Thanks Mark.)

George Boole has a lot to answer for in my book! – but hey, none of this would be possible without him.

I built a removable mount for the sensor array so it can be tucked safely inside the chassis for the other challenges. I think the obstacle course may well be a bit much for it, and it is *very* close to the ground for best effect.

Am really quite pleased with the results!….

So – we have a bot, that can be manually controlled and that can follow lines autonomously. Tick two. Then I started to look at the skittles challenge and got excited, started coming up with some fairly ambitious designs that would allow me to propel a ball the required distance to actually knock something over. And then disaster struck. But that’s a story for the next post.

Next Time!! – Big Weapons!! – Big Disaster!!

Stay tuned.

Read More