Posts tagged arduino
Last Thursday I took this project to my uni’s (Bournemouth) sports hall to take it for a spin. I can say that after 6 months of development, money wasting, blood swear and tears it nearly made me shed a tear to see this fully working with no issues whatsoever (apart from the camera static) in the hands of some of Bournemouth’s most dangerous and incapable drivers. Even worse I’d not been in a sports hall for a while and had forgotten about how polished and pristine the floor normally is.
Any way enough talk here’s the video!
If you want to get your hands and try this out, make sure you keep upto date with our Bournemouth University Graduation show taking place at the end of May this year! @gotoandplay2010
I wanna try and get this on the front page of Digg so… DON’T FORGET TO DIGG THIS POST!
I’ve made a few modifications to my Arduino sketch to keep it small… and I’m happy with it! I’ve learnt that the smaller the footprint on a device with limited memory the faster it can process things. So I’ve gone from an Arduino Sketch of roughly 100 lines of code… to something so slim and simple that it almost feels wrong to use it! Below is the graph from the output of the serial socket…
I’m releasing this code… now… I’m feeling a little nervous about releasing it… If you’re going to copy and paste this code, could you please at least leave the credit at the top? I’ve worked hard on this, and I didn’t do it so some twat can steak his claim on my work!
That’s right, no advanced algorithms, no crazy conversions, I’m just taking the first 3 bytes of the buffer from the socket and assigning it to the acceleration, and the last 3 bytes and assigning it to the steering… There are no heavy HTTP protocols to handle the requests, just one socket stream connection from the iPhone to the Arduino/BlackWidow! I can’t believe that the last 4 months of R&D has led to 8 lines of code!
Just to show you what I mean, the sketch started out like this…
Which works fine if you’re not trying to push through 60 requests per second to a device with 2 KB of SRAM and 1 KB of EEPROM. Just to put it into perspective the iPhone 3GS has 256mb’s of RAM…
Update… sorry guys, I’ve taken the code down… for now! I’ll put it back up once I’ve made my mind up about how to distribute it!
I know I’ve been away for a while but this is why…
On the left you can see the old Arduino and on the right you can see the new streamlined Black Widow from Async Labs, which is just a modified Arduino with WiFi built into it. I’ve also decided to go down the sockets route to communicate between the Arduino and the iPhone, all is going well! I’ve started creating the iPhone app, which is looking pretty nifty, when you turn the phone the steering wheel turns too! And it sends commands to the Arduino. I’ve had a few problems where the servo’s jitter from the commands from the iPhone but have found that connecting directly to the Arduino over WiFi in ad-hoc mode seems to have mitigated this.
Using the serial out on the Arduino I was able to see what values were being received from the iPhone, obviously trying to analyse a load of numbers (several thousand of them) is pretty boring, and I have better things to do with my life. So I downloaded Â Plot for the mac, which will turn a load of data into a graph (before you ask, Numbers and Excel can’t process stupid amounts of data quickly to display them in a graph, even on my dual 2.26ghz quad core mac pro). So below are the fruits of my labour, there are still a few anomalies as you can see, but it’s getting there, once the jitter’s all gone I’ll feel a bit more confident and hook up the speed controller!
Just imagine that those curves are from me tilting the phone.
A friend of mine (Tom) wanted to drive the car over the net, thought I’d give it a go as I haven’t even tried it yet. I’ve basically opened up my network so Tom has direct access to the car from a few URL’s, when he clicks on the URL’s I’m just messaging him telling him where which way the car’s going. The video’s below.
Alright, so I’ve been working on the iPhone app today and thought I’d start with something simple, you know, “press button car go forward” kind of thing child’s play… one might think. Well I was wrong! Unfortunately from my testing the WiShield can only handle 1 http request per second, in laymen’s terms think of it as a really juddery movie, you know when you watch a movie on megavideo or something and it’s constantly stopping to buffer because your stupid house mate is taking up all of the bandwidth downloading hardcore porn, think of how frustrating that is for you, and you’re just watching the thing.
Any way! Now I need to find some other way to communicate with the arduino that’s not to processor intensive. Apparently the WiShield supports other TCP/IP protocols such as UDP and Sockets, once I find out what these things mean I’ll get back to you, to be honest I’m quite surprised I got this far in the first place, I haven’t got a clue what I’m actually doing, I guess I’m just leaving it to fate and hoping everything just falls into place, which it normally does!
On a positive note though, I’ve created my first useful ugly iPhone app today, it’s not pretty I’m not gonna lie, but it’s reading the accelerometers on the iPhone, I’ll translate this into degrees so that when I turn the iPhone the wheels turn too and when you tilt the iPhone forward the car goes forward, and when you tilt it backwards… well I think you can see where I’m going here. Luckily my Nissan GTR kit came with some headlights, so I’ll add a lights button on the app too, so you can be all stealth and then BOOM! LED’s come on! And Dan’s been helping me paint the car, so it’s looking pretty sexy right now.
Any way, that’s it for me for today, it’s 3:00 in the morning, and I’m pretty sad to be on here to be honest, I should be in bed or out getting drunk.
Alright… so I went out to Maplin today and thought I’d splash out a bit and get a sexy project box, dremel grinder and some accessories… the result of this… that bad boy car’s completely wire free! Pictures below!
It’s 1:47 in the morning, my eyes hurt and I’ve voluntarily been at it all day messing around with this WiShield… I can tell you that it’s finally paid off! I’ve managed to get the WiShield to give an XML response based on a URL passed to it… Basically creating a REST webservice on the WiShield/Arduino which will control the servo’s on the car over Wi-Fi from… you guessed it ANY application that can open a URL! I’ll post how I did it in the cook book in the morning when I’m awake!
Wi-Fi enabling the Arduino from a hacked LaFonera+ router has proved tedious and annoying at best. I wouldn’t recommend it to any one unless you’re willing to deal with the agro of having to spend vast amounts of time flashing it and rebooting it every time a serial connection to the Arduino board drops.
Luckily for this project I’ve always had a backup for the Wi-Fi connectivity, it was my second option purely because of the lack of ethernet port for an ethernet IP camera. This backup has arrived today… and I give you… WiShield!
It literally arrived today and took me 3 mins to set up and get on the network, it has two modes, ad-hoc and infrastructure, all of the configuration can be done in the arduino sketch and is pretty self explanatory from the comments.
You can purchase one from asynchlabs directly, their store didn’t seem to work so I got mine from here cutedigi.com no where in the UK seemed to have them, they do international shipping, mine took under a week to arrive.
I’ve finally managed to flash my LaFonera+ through serial with DD-WRT, so I can send commands through SSH wirelessly to my Arduino board to control the servo’s.
I’ve also managed to power my LaFonera+ from the Arduino. I haven’t connected up the TX for now because I have no intention of letting the arduino talk back to the router, so for now this should shut it up.
Credit has to go to echoditto labs for giving me the initial idea. The full tutorial to flashing the LaFonera+ 2201 (UK Version) and connecting it to the arduino will be published soon.