Sunday, 13 October 2013

Arduino Controlled Fan

My very first arduino project was about 2 years ago, and it was (you guessed it) an arduino uno controlled 240V fan.. For reasons I don't know myself I never published it on my blog until today ;)

Concept

An arduino receives "data" from a RF receiver circuit and then controls a relay board which is in turn connected in a fancy way to a fan running on AC mains (more on this later). The arduino also controls a bunch of indicator LEDs and also a passive buzzer.

Parts List

1. The relay board in question (shipped from China - eBay reseller)


2. An ULN2003 darlington IC (for those who are unfamiliar with it.. Its basically made up of 7 npn transistors) 


3. This guy needs no introduction!


4. The target.. hmm

5. The Frankenstein Remote Controller (RF 49Mhz)


6. The RF receiver unit (holding it between my fingers)


7. Some funky LEDs... (who doesn't use LEDs these days :)


8. Opamp circuit I made which generates a 1Hz output.. toggles LEDS (red and blue) alternately added it too cause I liked it too much.. where's my handkerchief I'm getting emotional..




How does it work?

A fan which runs on mains usually has got one mains wire (coming from the power plug) connected to 
one tap of the AC motor of the fan... Therein 3 wires come out of the AC motor ( presumably from the 3 coils of the motor).. these 3 wires go to individual switches on a panel.. 

When you press on one switch .. this basically connects one coil to the other mains wire.. and the fan's RPM will be based on which coil was switched on.. does this make sense?

Hope the following diagram helps clear any confusion..


As you can see in the picture above, inside the motor we have 3 coils wound .. the resistance of the coils differ and that is why the fan spins at different RPMs.. 

What I did was I threw the switch panel away and rigged the relay board instead !

If by any chance the arduino would trigger 2 relays on at the same time it would surely cause the fan to release the "magic smoke" and maybe cause a fire...

So to avoid this I came up with a way to wire up it all as follows :


The "resistor" you see in the image represents the Coil impedance and not a resistor physically...

The topmost relay receives the mains power and when switched on .. feeds power to the 2nd relay...
The 2nd relay either powers up the primary coil or powers the third relay..

Third relay either turns on secondary or tertiary coil.. Nice story isn't it :)

This is a fail proof version that I came up with (atleast I think so).


Beware here is Frankenstein's remote controller !



If you take apart a cheap chinese toy you will find an RC receiver circuit which gives basically 4 outputs..
these outputs can be read by arduino and in turn arduino does stuff ..

What are those 4 outputs.. well one output makes the toy go forward.. one backward... one to the right .. finally one output makes it go to the left

You might be wondering there are 8 freaking pushbuttons on the remote controller above, what's this guy talking about?

One more diagram to help clear things out..


Yes effectively the extra row of buttons (5-8) short out buttons accordingly... this gives 8 functions out of 4



Some diodes had to be soldered to avoid "interference" in between button presses.. 


This LiPo above powers the transmitter.



Build Process (some snapshots)


Yes wires were soldered to the underside on the uno.. permanent installation plans..

I didn't want to have to poke around a barebones arduino with an FTDI chip in case I wanted to make a firmware upgrade .. so I used a cheap chinese uno from eBay..


Early "beta testing " of relay? :)


UNO having fun with the ULN2003.

Looks crazy as hell :P

Between notice 4 red wires on the right hand side of the picture.. these are wires from the AC motor.. one of them comes directly from the power plug and the other 3 are from the 3 coils of the AC motor..

The ugly thing in the middle is the power supply.. But it works! :)

Some info before you watch the video linked below:

NO two coils are on at once.

Button 1: Turns Fan ON - - Default speed is max
Button 2: Sets max RPM (again doesn't matter)
Button 3: Second Coil kicks in .. medium speed 
Button 4: Third Coil is on..  lowest speed
Button 5: Turn off the AC motor
Button 6: Turn on 1Hz opamp (the arduino could have toggled the LEDs itseld)
Button 7: Turn on timer mode... turns fan on at max rpm for 30sec.. then off for 5minutes .. cycle repeats (I love it )

Button 8: Disables the led toggling and timer mode disabled.

Video as promised (Please forgive the crappy camera .. I am sorry.. really..)


CONCLUSION

First, I would like to honestly thank YOU so much for going through this lengthy post.

This project was made using bare minimum parts as you have correctly understood, ofcourse to keep costs a minimum.. also that time I didn't have any coding skills I have today. :(

Well. Its been up and running for 2 years flawlessly so I never bothered improving the hardware yet but surely I would maybe in the future do any of the following:

1. Dump Frankenstein Remote and get an IR sensor with matching remote from eBay

2. Or maybe use a Bluetooth module like the HC-07 and thereby control the fan from my android phone

3. Maybe WiFi control? Is that too crazy? :)

That's it folks! I'm glad finally I did make a post about this project and I don't know what to type anymore so Cheers!!








Friday, 26 April 2013

A commonly used light source is the Fluorescent Tube.  Unlike other models.. old school Fluorescent tubes need a starter and a ballast to get going and you may end up waiting for a while till it finally gives you some light. And besides they get pretty noise and flickery which is a bad problem.



Above you can see the various components that sit inside the Fluorescent tube.
How about eliminating the delay in start-up completely? One solution is to shift to an electronic ballast!


So I decided to crack open a CFL (Compact Fluorescent Lamp) and take out the electronic ballast inside..

NOTE: If your bulb for example is 10W then look for a CFL with around 10W electronic ballast.



And this is what it looks like when you crack open a CFL.  You can see clearly an electronic ballast sitting inside.  Using a soldering iron , heat the metal on top of the CFL to get the two mains wires loose. 

DO NOT simply cut the electronic ballast wires close to the PCB board since there is a resistor / inductor (haven't figured out which one it is yet) soldered to one of the mains wire..





Once you pull the ballast out you will notice 4 pins on the front side of the pcb ... two pins on the left and two on the right
(I bent the pins a little for soldering later on)

Now time to crack open the Fluorescent tube.


You can see the old school ballast inside .. I removed the starter and discarded it already



You will notice a pair of wires coming out at each tube socket .. Cut them close to the ballast and starter if needed.. 

The pair of wires coming from one tube socket is to be screwed into a connector. Repeat for other tube socket So that in the end you land up with 2 connectors close by.

NOTE: The pair of wire coming from one socket is not to be connected to the wires coming from the other socket.. These pairs need to be separate..  and each pair has to have its own connector



Solder 4 wires to the electronic ballast pins... the two pins on the left side of the ballast connects to any one of the connectors... the two pins on the right side of the electronic ballast connect to the remaining connector



In this picture, you can see two pink wires coming from the left 2 pins of the ballast and going to one connector.  And 2 brown wires coming from the right 2 pins are going to the remaining connector

Here is a schematic in case what I typed above made no sense.. 


Make sure that no wires are shorting.


Testing the ballast on the tube reveals that it works exactly like a CFL as expected..

Finally use some duct tape to wrap the tape all around the electronic ballast and make sure again that there are no shorts .. You really don't want the metal casing to go live? Do you ? 




Well that's it fellow hackers! I hope you enjoyed reading this and thanks alot for your interest.
Have fun!