Simplest Way to Protect RPi Against EMF Caused by Electromagnet

ZetaPi1
Posts: 6
Joined: Wed Jul 28, 2021 10:37 pm

Simplest Way to Protect RPi Against EMF Caused by Electromagnet

Greetings all!

I'm thinking of doing a project to make a Raspberry Pi controlled chess playing robot arm similar to the Raspberry Turk I've read about online (https://www.raspberryturk.com/). Like the Turk, at the end of my robot arm would be a small electromagnet that would be used to pick up and place the chess pieces. But unlike the Turk, I would use a home-made electromagnet made with 16 AWG gauge copper wire and an iron screw. This brings me to two questions:

1. According to the research I've done online, the formula for calculating the force applied to a piece of metal by an electromagnet is:

F = (n * (V/R))^2 * K * a / (2 * g^2)

where:

F = force in Newtons
n = number of turns in the solenoid
V = the voltage in the circuit
R = the resistance of the circuit in ohms
K = the magnetic constant which is equal to 4 * PI * 10^-7.
a = the cross-sectional area of the wire in meters
and g = the distance between the electromagnet and the piece of metal in meters

According to my calculations, if:

n=100
V=5
R=0.0147286821705 ohms (The resistance in 1 meter of 16 gauge copper wire)
a = 0.00000130698108371 meters (the cross-sectional area of 16 gauge copper wire)
and g = 0.0254 meters (1 inch),

then the force applied to the piece of metal by the electromagnet would be 1.506 Newtons or 0.339 pounds of force. This would be plenty of strength to pick up the chess pieces, but I'm wondering if my math is correct.

2. Keeping the above description of the electromagnet I have planned in mind, would I be able to protect the RPi against the reverse EMF current produced when the electromagnet is turned off with just a simple LED serving as a Fly-back Diode? I understand LEDs are usually not sufficient to protect against the reverse EMF currents produced when more powerful electromagnets are turned off, and that special diodes are needed instead, but will an LED do the trick for a weaker electromagnet like the one I'm talking about? If not, then what would be the simplest way to prevent the electromagnet from frying my Pi?

ZetaPi1
Last edited by ZetaPi1 on Fri Jul 30, 2021 1:23 pm, edited 1 time in total.

ghp
Posts: 2025
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

If R=0.014 and U=5V, current is 357 A which is very very high, And far beyond what a RPi power supply can deliver,

Think your calculation is not perfect, 1000 turns around a 5mm screw need 1000 * 0,016 m minimum.

To drive a solenoid, use a separate power supply, a transistor switch and a 1N4007 flyback diode.

ZetaPi1
Posts: 6
Joined: Wed Jul 28, 2021 10:37 pm

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

ghp wrote:
Fri Jul 30, 2021 5:01 am
Think your calculation is not perfect, 1000 turns around a 5mm screw need 1000 * 0,016 m minimum.
I had planned 100 turns around a 3.5mm screw. 100 * 0.011m is approximately 1 meter.

Also thank you for your reply. I thought that would be the case that I would have to use a transistor, but I was hoping there was an easier way as I am relatively inexperienced when it comes to wiring circuits.

Unfortunately, I do not have a 1N4007 flyback diode on hand, and was hoping that I would not have to buy any special components. Is there a way to safely leave out the 1N4007 diode by maybe replacing it with a Red or White LED and some resistors?

Also, I only have 1 PNP and 1 NPN transistor. Which one should I use? If you could maybe attach a schematic of the proper circuit configuration, that would be greatly appreciated.

emma1997
Posts: 1610
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

I think to hold a chess piece you will need bigger coil with hefty power supply. Probably not 5v Pi supply but more like separate 12v at an amp or two. And doubtful your typical common to-92 BJT transistor will work so maybe look at to-220 power transistor. Preferably MOSFET type which would be cheaper and safer with no need to spend half a day calculating base resistor values. I understand it's a popular fun game for noobs (and some experts) but either way can work.

Protection diode across coil probably needed unless you use high voltage transistor or resistor in place of diode. With 3v circuits diode may not be needed but lots more amps for the coil. BTW a transistor can work as a diode configured properly.

Here's a circuit w/o diode for high voltage transistor but w/low voltage part probably need one:

If you have no diode a resistor across the coil can be used to bring EMF down to safe level even with low voltage transistor. Or you could use your pnp as a diode.

pidd
Posts: 2527
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

To stop your electromagnet getting very hot you need more turns and less current. It might be far easier to buy a cheap solenoid off ebay or dismantle a traditional style relay.

Provided it is metal-metal contact and you have lots of turns you don't need a lot of current.

To save more power and heat you can do what magnetic cranes do, use a permanent magnet with a coil that neutralises it, much more fiddly to set-up but the coil only has to be switched on for a shorter period of time.

ZetaPi1
Posts: 6
Joined: Wed Jul 28, 2021 10:37 pm

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

emma1997 wrote:
Fri Jul 30, 2021 4:12 pm
Here's a circuit w/o diode for high voltage transistor but w/low voltage part probably need one:

If you have no diode a resistor across the coil can be used to bring EMF down to safe level even with low voltage transistor. Or you could use your pnp as a diode.
So would this circuit work (Link to Interactive: https://www.circuito.io/app?components= ... 000,842876) if I replaced:
the "12VDC Lock-style Soleniod" with a home-made electromagnet,
the "Diode Rectifier - 1A 50V" with a PNP resistor,
and the "Wall Adapter Power Supply - 12VDC 2A" with a 9v battery?
Raspberry Pi Circuit.PNG (123.3 KiB) Viewed 777 times

ghp
Posts: 2025
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

Consider to use a logic level mosfet like the IRLZ44.

A 9V battery is for sure a 'safe' option as it has no mains connection... From the net: "A standard 9V battery has about 400-600 mAh capacity. In the most basic terms, these batteries can supply about 500 milliamps for one hour before being "dead"."

pidd
Posts: 2527
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

Your going to flatten the battery (or short out the power supply) if you don't have either some type of current limiting or have sufficient length of wire coiled that creates a resistance that is not nearly a perfect short.

As stated above, your original coil design would try and draw 357 amps, it has virtually zero resistance and hence no current limiting.

You need to use thinner wire and a lot of turns (thousands) to increase the resistance.

emma1997
Posts: 1610
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

ZetaPi1 wrote:
Mon Aug 02, 2021 2:08 pm
So would this circuit work
A brief glance (I prefer actual schematic over those fritz-agrams) tells me it should. Assuming you pay attention to the excellent advice from ghp and pidd. And you use 'pnp transistor' instead of 'pnp resistor'. lol

Do you have a multimeter?

ZetaPi1
Posts: 6
Joined: Wed Jul 28, 2021 10:37 pm

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

emma1997 wrote:
Tue Aug 03, 2021 5:36 pm
Do you have a multimeter?
No, I don't have a multimeter. Why do you ask?
Last edited by ZetaPi1 on Thu Aug 05, 2021 5:35 pm, edited 1 time in total.

drgeoff
Posts: 12188
Joined: Wed Jan 25, 2012 6:39 pm

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

ghp wrote:
Mon Aug 02, 2021 8:24 pm
Consider to use a logic level mosfet like the IRLZ44.

A 9V battery is for sure a 'safe' option as it has no mains connection... From the net: "A standard 9V battery has about 400-600 mAh capacity. In the most basic terms, these batteries can supply about 500 milliamps for one hour before being "dead"."
Those 9 volt batteries of size such as NEDA 1604 or IEC 6F22 are not suitable for delivering currents as high as 500 mA. They have an appreciable internal resistance which would cause significant voltage drop.
Quis custodiet ipsos custodes?

emma1997
Posts: 1610
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

ZetaPi1 wrote:
Wed Aug 04, 2021 1:38 pm
Also, no, I don't have a multimeter. Why do you ask?
IME when playing with this stuff it makes the difference between a project taking weeks/months and blowing lots of parts vs a few hours with far less magic smoke. Very useful tool to learn in any case. Cheap (\$5) or even free with coupon at Harbor Freight.

For example it would come in handy learning how a pnp can be used in place of a diode.

Note that some 9v battery chemistries can manage half amp but, as hinted, not for very long. Unless you found a case of them that fell off a truck then probably better to use a common 12v PSU as I suggested. Then power the Pi off that too with a DC-DC converter.

g4bch
Posts: 23
Joined: Mon Oct 01, 2012 12:06 pm

Re: Simplest Way to Protect RPi Against EMF Caused by Electromagnet

Take emma1997's advice and get a multimeter, for building circuits it is one of the best investments you can make. You won't get far without one.
You will be able to measure voltage, current and check resistors; some cheap meters can even check transistors.