Saturday 30 January 2010

Solenoids- done!

I am now, finally, able to control my solenoid through arduino and NOT just with a power supply.

Big Achievement!!

For the first time with my electronics, the problem was not in the coding, but in the circuit. This is one of the hardest things to hook up, made harder with the use of a program and external power supply.

Coding is simply turning the solenoid on or off. When it is turned on, it will suck the piston in, and when released (off) pushes the piston out. This is why it is easy to use with solely a power supply, turn on the power, the solenoid is on, turn off the power, the solenoid is off. But i want to control it via arduino.


To begin:
I hooked the solenoid straight to the arduino board. Along with the red led, i programmed them to go on and off every second. This did work however, not enough power was available so the piston did not hold very well, i.e it was not strong enough current.



So:
I began using a MOSFET to drive the current up and an extrenal power supply to allow a higher voltage to be available, therfore producing a stronger hold. As you can see in the image, i hooked up one of the solenoid's wires straight to the power supply. This magnetized the solenoid independently of arduino. (With a higher voltage, the strength of the solenoid was greatly improved.)



So:
I started looking at ways to connect the solenoid indirectly to the power supply so I introduced a voltage regulator, which looks identical to the MOSFET. (The MOSFET is to the right)

I believe i hooked this up incorrectly as i smelt burning and touched my voltage regulator. ouch! Next time i advise disconnecting the power and letting things cool down. I discovered that the green wire should not connect the two devices...

Then:
I tried for AGES to hook up the circuit with both components before removing the voltage regulator as i wondered if i even needed it...


So:

I went back to the web and searched for pictures showing how to connect the components. This was very tricky...not much available in books and online showing you how to do it. But i did find a few, and with my systems diagrams i just kept at it.

This one made the solenoid vibrate

This one made the MOSFET really really hot and the solenoid didn't do anything. I don't think the MOSFET likes a direct ground line from the power supply.

This one magnetized the solenoid independently from arduino but the MOSFET did not heat up...


So... I went to the arduino forum hoping they might have a tutorial on how to use them and the only thing i could find was this systems diagram which i had looked at few weeks earlier in the anticipation of receiving my solenoids.

http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf


After studying it for a while i noticed i had missed out the green wire below. This adds an extra ground line from the arduino board to the' source' in the MOSFET.

voila! this is how to hook up a solenoid to arduino

Now i just need to program the pattern i would like my solenoids to play!

No comments:

Post a Comment