Posts Tagged ‘arduino’

Arduino Web GUI

Tuesday, June 1st, 2010

Taking the code I found here, I have sucessfully created the first part of my home automation system.

It enables you to log on to an Arduino-hosted ‘site’ and switch on and off the 13 digital outs on the Arduino board. Easy enough…

Download the code: http://floor44.co.uk/wp-content/uploads/2010/06/Web_GUI_Digi_Out.pde

Next on the list: User name and password authentication, Twitter updates, Facebook notifications, universal infrared remotes and so much more…

Peace out! :D

Wiimote + Arduino + IR LEDs + Max5 = Success!

Thursday, March 4th, 2010

After a lot of fiddling about on Max5 and testing different hardware, I have had a breakthrough! I have now successfully got a Wiimote to not only ‘see’ and follow 4 IR LEDs, but also return the values into Max5!

Below is a crude(!) video taken on my old-as iPhone 3G, showing the tracking as I move the Wiimote around:

The next step in my development is to use triangulation to determine the distance between the Wiimote and the LEDs, in such a way that I can change the configuration depending on the fixed distance between the LEDs.

If i were just moving the Wiimote along a single axis towards the LEDs, then the calculations would be very simple, but nothing in my life is that simple! Not only is the positional and spacial relationship between the 2 objects 3-dimensional, but the rotation (pitch, roll and yaw) of the LEDs (or in this case, the Wiimote) is also 3-dimensional and it is here that lies the problem.

If the 4 light sources are close together, there could be 2 possible senarios:

  • The LEDs are far away
  • The LED array has been tilted so that the angle of incidence is very small

A successful and stable solution for this has not yet been created. Until now…maybe!

Because the IR camera on the front of the Wiimote is of such a high quality (1024 x 768px!) with a narrow viewing angle (~45°) it suffers foreshortening much more pronounced and acurately reproduced than that of a normal webcam. This means that if the sensor is far away from the source, the distance between the points will be small, but consistant between them. If the sensor is tilted, the distance between the 2 leftmost points will differ from that of the 2 rightmost. There is a value returned for the size of each of the light points, but this is inacurate and unstable due to the narrowviewing angle of the LEDs. I am currently looking into way to increase the viewing angle of the IR LEDs, which will help the accuracy and reliability of the values returned.

Finally, credit where credit is due. Thank you to Alex Harker for the updated ajh.wiiremote Max5 patch: http://cycling74.com/forums/topic.php?id=22500

The Last Minute Change of Plan

Wednesday, February 24th, 2010

Right. A long time since I last ‘blogged’, so I have some housekeeping to do. Updates by the shed-load. My sound app has now changed dramatically to reflect my new instrument.

My original idea was to create a tactile-less instrument (similar to the one shown below) that required little or no musical experience. My new idea is similar, but with a new and different application of hardware.

My original design required the use of ping, or ultrasonic sensors that used echolocation (making very high-pitched clicking sounds and listening for the echo) to determine the distance to a surface (similar to bats and dolphins) or lasers that used a similar method, but with light instead of sound.

I discovered that there were a few problems with the ping sensors, the most worrying being that because I needed 2, and unless I could wire in a switch so that alternated the source and receiver or created 2 different wavelengths, the 2 pings would interfere with each other. The ping sensors for the Arduino cost around £35-40 each and being a final year student, I am very very very low on cash and I decided to look for a cheaper alternative. The biggest problem however, was that if I choose to use my own sensors (which I have sitting on my desk now) I had no idea how to create the circuit to make them work.

So began my search into alternatives. Whilst experimenting with getting values from LDRs into Max5 via an Arduino, I discovered that covering up an LDR was very inaccurate in that my hand covered such a large area that the poor little LDRs resistance would read close to infinity whenever I went near it. However, when I was playing around with one, I tilted it down onto the desk and the reading was a lot more consistent. I suddenly realised that if I were to attach one to the end of each finger, I could use them to trigger notes and chords by moving my fingers up and down. On my white desk, the LDR was giving back values until it was only a few millimetres off the surface of the desk.

However, as with the hand-covering, the data retrieved from the LDR varied quite considerably. I came to realise that the only true and reliable way of using LDRs was as a switch, giving a value of 0v or >0v. But this property completely destroyed my analogue-based distance system, so once again, I had to put pen to paper and have a re-think.

I have 5 digits on each hand, making 10 in total. If each of them could give a value of 0 or 1, using binary notation I could have a potential 1,023 (210 – 1) combinations of fingers, ignoring the combination 0000000000 (all fingers up). That is far more than I originally had planned and maybe too many. If I split my hands up however and treat them as 2 separate entities, I could have 62 (2(25 – 1)) combinations, which would be more than enough, seeing as there are only 8 notes in a scale. Splitting the 2 hands up, I would have chords on the left and melody on the right, with 31 combinations of each.

Above is the map I drew to illustrate the combinations. The actual number of combinations in this configuration is 40 ((23 – 1) + (22 – 1) + 2(24 – 1)). The number I am using is less because I am restricting the notes playable by the 4 fingers of the right hand to 12, rather than the maximum of 15, purely because there are 12 notes in the chromatic scale and the thumb can then act as an octaver, adding 12 semi-tones to the current note. This means I can have 2 full octaves in the right hand and all 7 major triads, each with 3 optional variations on the left hand.

The other brilliant thing about this idea is its flexibility. In the future, I may look into the possibility of allowing the user to switch between playing notes and percussion. There is also the possibility of using more sensors for a wider range of possible sounds, instruments and dynamism in the music. Of course, the current design acts as a MIDI controller, so you can just alter the voice on the system to whatever you want, but you must remember that the mapping of the fingers would need to be made more intuitive for the instrument chosen.

The LDRs will be attached to a glove to allow the wearer to play the instrument anywhere, within reason. The position of the fingers in relation to one another is not important as it is with any tactile instrument. Given the right material, the wearer may even be able to play by tapping their fingers against their clothes.

Of course, my current working patch in Max5 was useless, so I set out to create a new one, stealing bits and pieces from the one that previously took me several weeks to carefully prepare. A work in progress:

Of course, the unlocked patch is as nasty-looking as ever:

There was of course, the problem I was dreading – I had to make 2 Arduinos talk to Max5 separately. This caused me a few headaches, but I overcame it. Lucky I bought 2, eh? :D

The only problem that I can foresee is that not many people can think in binary very quickly. I am having a lot of trouble trying to grasp it because I can only think either musically or binarily. Mixing the 2 is not easy for me! So as a fix, I am building LEDs into the fingers of the gloves and if I take the idea further, I will create a system that can flash the lights of the fingers you have to tap to play a particular song. I could also build in a function to allow the recording of your taps and play them back to you.

There are a few points that I believe make this instrument better than the one I had originally planned. With analogue inputs, it was hard to find a point at which to trigger the playing of the chord or note. There are of course, no such problems with digital; it’s either on or it’s not! Although not as technically outstanding, the new instrument should be more reliable, easier to reconfigure and more accurate.

This idea has already been produced (such as here and here), but every existing application only allows the user to play a single not per finger. My design allows a chord to be played with a single finger, making for many more possibilities.

Gloves off eBay – Check!
Arduino x2 – Check!
LDRs, LEDs and wire – Check!
Time – ARGH!

Arduino, Breadboard and PCB Basics

Thursday, November 26th, 2009

Well after a week of just making the LED on one of my Arduinos flash, I decided to get back in touch with some basic electronics and where best to find electronic components than in old electronic equipment?

I spent all of last weekend going through my roof and digging out anything with potentiometers, resistors, LDRs, infra-red, motors, solenoids and lasers and taking it apart to try and get some ideas for interactivity. Turns out that I found 2 computers, 2 additional graphics cards, 3 stereos, a PSU, an amplifier and a laser printer. Needless to say my mother wasn’t happy when she saw the state of the roof:

21112009(001)

21112009

However, I struck gold when I found my old ‘Cybot’, built from a week-by-week magazine collection, Real Robots:

RealRobots

2070832191_faab169f4c_o

Wow – he had it all! The LDRs, the ultra-sonic sensors, the infra-red, the LEDs, the motors and the ‘line-following’ snout. So i killed him. What’s left of him is sitting in an anti-static bag in front of me.

So I then started to read more into electronics. I was quite good at electronics in college, but then it did just consist of soldering a couple of resistors onto a pre-made PCB and plugging in a battery to test fuses. Boring! I know what component is what and its basic function, but I decided to look into things like how a transistor works and the tolerances of a relay and what a J-K flip-flop chip does. I looked at logic circuits in more detail than I realised and I think I now have enough knowledge to start building my own circuits for the Arduino. Starting off nice and simply, hooking up an LDR to the board and getting a reading.

Screen shot 2009-11-26 at 16.13.32

Easy! For my new idea, the hardware side of things only requires 3 or 6 LDRs, 2 ultra-sonic sensors, 2 potentiometers, 6 PTM switches and a microphone. My final year project is, as yet, undecided! An update is imminent…

My Final Year Project Idea – The Hand

Tuesday, November 10th, 2009

project

Taken from my project proposal:

I plan to create a robotic hand/arm that can respond to human commands and perform in basic problem-solving situations, where human guidance is kept at a minimum. After seeing a lot of different types of robotic arms, I believe that creating an arm isn’t that difficult, but writing the software that allows the robot to make informed decisions would be much more of a challenge.

I intend to create a humanoid hand (possibly with only 3-4 digits) that can perform a range of tasks, such as replicating a simple tune on a piano that the droid has been played, picking up objects, distinguishing weights and possibly even colours and materials which will require the robot to adjust the level of grip. This will require me to look at video pattern recognition for shapes and objects and possibly rely on the robots memory for previously-encountered objects.

I would like to use a combination of either Max5 or Flash and the Arduino for the hardware-software interaction and a series of servos and pulleys wrapped within an aluminium, plastic or copper construction, with FSRs (Force-Sensitive Resistors),  and a spring-loaded immersion resistor for measuring the weight.

I am not looking to create a particularly fast-moving limb, but rather one that is dexterous enough to try a larger range of movements to complete a certain task.

My original idea was to create a pair of hands that could pick up and play a games console controller, like a PlayStation 3, but this would require extreme amounts of both dexterity and speed.

Now, the human hand is a complex thing and I’ve never looked at it more. The shear levels of dexterity are incredible, particularly in the thumb, which has to oppose the fingers perfectly in order to function. The human hand has a huge number of different muscles and tendons in order to create a vast library of shapes for different applications.

3936469406_722bf104c2

However, the main movements of a human hand can be summarised as shown below:

Movement2

Movement1

This of course ignores the 3 axis of movement that the entire arm has, with one hinge join in the elbow and 2 axis of movement in the shoulder – up/down and forward/backwards. However, the hand itself is comprised of just 16 major ‘bones’, but even this can be simplified. Most of us will find it hard to bend the 2 joints in our fingers independently of one another, therefore the finger itself only needs one form of control – curl up and extend. The knuckles are the next degree of movement and on top of the fingers fist>flat movement, they only require a small movement to spread the fingers apart and together again. The wrist is another simple joint with just 2 degrees of rotation. The most challenging digit is the thumb. I never noticed just how freely it moves in all 3 axis as well as bending in 2 places.

If I can design and build a hand that can accommodate all of these movements, the rest should be relatively easy(!)

Using 1, possibly 2 Arduino Duemilanove ATmega328 boards (I have just ordered 2!) and either Flash CS4/CS5 or more likely Max5 MSP, coupled with a variety of servos ranging from torques of 2kg/cm to a massive 15kg/cm, some PVC-coated steel braided wire and a multitude of sensors, I think I can make a hand that can perform almost as many tasks as a human hand. From thereon in, pre-recorded tasks and movements should(!) be easy…

My plan from my project proposal:

  1. Design a humanoid limb which is capable of the levels of dexterity of a human hand
  2. Build a skeleton to work around using a resistant material
  3. Fill the limb with servos and wires
  4. Connect everything up to Max5 to make sure the servos work as planned
  5. Experiment with moving different servos in different orders in order to mimic human-like movements
  6. Physically move the arm to get some values and data back for the different positions
  7. Program in some pre-recorded functions like “Pass to me” for extending the arm when it has something and ‘Yes/No, True/False’ for trial and error or reinforced learning
  8. Get the arm to see objects and move to a position over them
  9. Use the pre-recorded ‘grasp’ movement to grasp objects
  10. Use the pre-recorded “Pass to me” movement to pass me an object, or the “Move to” command to move the object to another place.

Good luck to me!