Magnetic Power Switch With Attiny85

Electronic projects that are either related to the firmwares for the 9x, or simply great for radio control applications.
Post Reply
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Magnetic Power Switch With Attiny85

Post by jhsa »

Here it is another little project of mine ;) :)
This time I decided to try to build a Magnetic Power switch. These are normally used on IC powered models and gliders, where a switch is most of the times used to turn the model ON and OFF.
The advantage is that it doesn't have contacts that can be damaged due to vibration, fuel, etc. It can be placed inside the model, for example, glued to the side of the fuselage. To turn it ON or OFF, just place a magnet on the outside of the fuselage, just above the hall sensor. This setup also prevents us from accidentally turning the model OFF when handling it or lauching it.
This kind of switches are not normally used with electric powered models due to the high currents involved..

One of the requirements is that it should be able to stay connected to the battery without draining it..
The problem of this is that it is quite difficult to find components that draw very little current when standby. We are talking about just a few micro amperes.

I did find a couple regulators that could do the job, and also a micropower Hall Effect Switch from Allergro. The A3212.
I found it here:

http://www.ebay.com/itm/10PCS-A3212-Hal ... SwLN5Wlkgn

Here is the datasheet:
A3211-12-Datasheet.pdf
(587.4 KiB) Downloaded 413 times
It takes about 8uA when sleeping, and about 2mA when awake (In the presence of a magnetic field)

The regulator I've used is:

LT1521-3.3 - This 3.3V regulator takes 12uA (micro Amperes) without a load on its output.The whole board will take 20uA when sleeping, if using this regulator. This means that if we leave the battery connected, it will take 173mA in one year. It is also a low dropout regulator, and it can handle a maximum of 300mA. Here is the datasheet:
LT1521.pdf
(205.04 KiB) Downloaded 366 times

I don´t post links because I bought the regulator at a local online shop.. "Reichelt" I think they also sell abroad though.

The Attiny85 can be programmed to enter sleep mode, and wake up when receives a signal from the sensor. Then toggles the output if the magnet is near the sensor for 3 seconds, and goes back to sleep. When a sleep it takes only 0.5uA
I found some Arduino code on the internet, put it all together, And got it working :) I was lucky I guess :D
Anyway, below there are the schematics and Eagle files for 2 different boards. One with 2 Mosfets, and another with 4 Mosfets.
I'm sure there are people here that can design PCBs much better than me.. So, if you also design a PCB, please share
The capacitors are all SMD 0805 non polarized..
Transistor can be any general use, BC846, BC847, etc..
Resistors are all 0805 size

For the MOSFET I used This one:
DS_IRF9310.pdf
(261.72 KiB) Downloaded 295 times
You can also have a look at this one (IRF7416). But it is rated at half the current of the IRF9310.
IRF7416_IR.pdf
(201.67 KiB) Downloaded 268 times
Attention: The amount of current the unit can handle depends on which MOSFET(s) you used, the PCB tracks area, as well as the MOSFET heat sink area, if any. Also, be aware that just because the Mosfet datasheet says it can handle a maximum of 20A, it doesn't mean it can do it in all situations.. You would need a good heat sink for that.



Magnetic switch with 2 Mosfets:
Magnetic Switch 2 Mosfets.jpg
This one according to my tests can handle 15A continuously and still be cold. I tested it at 20A and it started to get warm. After running it at 20A for a few seconds, I could still put my lips on the Mosfets and not burn myself ;)
I would limit the current to 15A continuous, being a little conservative..

Here is a zip file with all the information, and also the code:
Double Sided PCB_ 2 Mosfet.zip
(503.15 KiB) Downloaded 305 times

Magnetic switch with 4 Mosfets:
Magnetic Switch 4 Mosfets_TOP.jpg
Magnetic Switch 4 Mosfets_BOTTOM.jpg
This one according to my tests can handle 30A continuously and still be slightly warm. I tested it at 35A and it started to get warmer. After running it at 35A for a few seconds, I could still put my lips on the Mosfets and not burn myself ;)
I would limit the current to 30A continuous.

Here is a zip file with all the files and code:
Double Sided PCB_ 4 Mosfet.zip
(720.93 KiB) Downloaded 295 times
On the PCB files you can see some little squares with holes placed just outside the board. I used them to line up both sides of the PCB

You can see I also have put some programming pads on the PCB's. They make it easy to flash the Attiny85. Just connect the programmer to those pads.

I always have trouble burning the bootloader to the Attiny using the Arduino IDE. It always fails. Actually there is no bootloader. The IDE just programs the fuses to the chip. But I have to use AVR Studio 4 to program the fuses. Perhaps there are other programs that can also do it, but I didn't try any other.
After changing the fuses I can program the Attiny with the arduino IDE using an UsbAsp programmer. I guess other supported programmers might also work, but I didn't try any other..

IMPORTANT: when using a programmer that can only supply 5V, better you do not power the board from the programmer as the Hall sensor might get damaged. Just power the board normally from a battery pack using it's own 3.3V regulator and don't connect the +VCC wire coming from the programmer.

The fuses are:

Low - E2
High - DF
Extended - FF

On the Arduino IDE, you should select "Attiny85, 8Mhz internal clock..

A little video of the Switch working:

https://www.youtube.com/watch?v=DphuRzk ... e=youtu.be

To turn the switch ON or OFF just hover a magnet over the sensor for 3 seconds.. This delay protects against any magnetic interference, or just passing the magnet near the sensor and activating it.

I hope you find this useful

Enjoy building your magnetic switches.. ;) 8-)
João

EDIT: By the way, build this at your own risk, as usual :)
It seems to work for me. It might not work for you..
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Magnetic Power Switch With Attiny85

Post by jhsa »

A little update. I will try to make a double sided PCB and parallel some Mosfets so the switch can handle more current . The board will be just a little smaller than my previous ones. I also included a mosfet that protects the regulator and ATtiny from reverse polarity. Still not sure if it is worth it, as reversing the battery will probably destroy the Power Mosfets anyway. But I guess I will just leave it in for now and test it.
I'm keeping the Attiny, resistors, regulator and transistor on one side of the board, and place 4 mosfets (SO-8 package) on the other side. If you build it, you can put just one, or all 4, depending on how much current you need it to handle..
Here is the schematic of what I will try to do. It needs some cleaning.. ;)
I will use other mosfets this time though, the IRF9310. They can handle the double of the current of the IRF7416. Basically, if you dicide to build a switch, you just use what suits you better :)

João
Attachments
Magnetic Switch With Attiny85_With Protection_Double Sided.png
DS_IRF9310.pdf
(261.72 KiB) Downloaded 267 times
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Magnetic Power Switch With Attiny85

Post by jhsa »

Ok, here is a double sided version with 4 mosfets. Need to do some current tests, and find out what is the maximum current without them getting to hot.
Just connected it to one of my electric models that pulls 10A at full throttle with a 3s LiPo (not fully charged), and let it run for a while. I monitored the current and voltage on my wattmeter. Mosfets remained cold. Will try with a more powerful model tomorrow.. meanwhile, here are some pictures.

João
Attachments
Top.jpg
Bottom.jpg
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Magnetic Power Switch With Attiny85

Post by jhsa »

Ok, just connected it to one of my electric models.
Managed to pull around 30A for several seconds until the voltage on the battery started to go too low (old batteries). The switch didn't even get warm.. Maybe due to the fact it was in the prop wind? But yeah, I think I can say that with the 4 IRF9310 Mosfets it could safely handle 30A or probably a bit more.
I did run it longer at 20A, and no problems at all.. Mosfets were cold.

I don't have extremely big models yet ;) so my question is, what kind of current values would be expected on one of those big models?

Thanks

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Magnetic Power Switch With Attiny85

Post by jhsa »

First post updated with my final(ish) versions of the switch..
One with 2 mosfets, and another using 4 mosfets..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Magnetic Power Switch With Attiny85

Post by jhsa »

Installed the 30A version in the model I normally use for testing stuff. Here is a little video..

https://www.youtube.com/watch?v=88UGBRoIDaw

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

Post Reply

Return to “General RC Electronic Projects and Discussion”