# Using Electromagnet to Detect Steel Door

1. Feb 5, 2016

### Michael P C

Hi guys,

I'm using an electromagnet to detect the presence of a steel door through analog pins on an Arduino. This works great if the magnet itself isn't under power, but once I'm running 12 volts through it, the sensitivity of the readings fall apart. I'm using a resistor based voltage divider to bring that signal back in.

Any ideas how I can get a more sensitive reading while the EM is under power?

2. Feb 5, 2016

### Michael P C

Just thinking through this, is there a module available that might sit between the EM and Arduino to amplify resolution?

3. Feb 5, 2016

### Nidum

I'm not quite sure how your detector works ?

4. Feb 5, 2016

### Michael P C

I've got a picture of it attached. The battery sitting on top is representative of the door that it's holding.

File size:
48.2 KB
Views:
45
5. Feb 5, 2016

### Jeff Rosenbury

BTW, it's still not clear how the detector works. There are several possibilities, so ...

I suspect your problem is the change in inductance as the core of your magnet saturates. This could drop the inductance by 2-3 orders of magnitude. But it's hard to be sure without understanding the circuit.

If that's the problem, you might get by with a software fix. Simply use a different detection level when the core is saturated compared to when it isn't.

6. Feb 5, 2016

### Michael P C

Oh yes, the detector ideally needs to be on the electromagnet side of the equation, hence my trying to use it as the detector. The way it's wire up, I have 12 volts going to the electromagnet, with a line coming off it that goes to an analog IN pin on the Arduino. I have a voltage divider to take it down to 5 volts for the analog pin. That's the basic circuit. Without power to the electromagnet, the Arduino (with 1023 integers of value to read) picks up an easily readable difference of about 300 integers with the steel door present vs. away. With 12 volts powered, that 300 spread goes down to 2-3, which is so small that misreadings are common.

What do you mean different detection level? Perhaps using another analog pin with a different voltage division value?

7. Feb 5, 2016

### Nidum

Well I'm truly puzzled now ! With no power going to the solenoid I can't see what the AD converter is finding to detect the level of .

Are we talking all DC in your circuits ?

Could you draw out the complete circuitry of everything to do with the electromagnet and post it for us to look at ?

8. Feb 5, 2016

### Staff: Mentor

As Nidum is implying, you would usually use AC to detect nearby ferrous metal with your test coil. Does your Arduino have an analog output available? What frequency sine wave could you output with it?

9. Feb 5, 2016

### Michael P C

This is all DC. I can draw up a circuit but it will be a little crude. Give me a few.

10. Feb 5, 2016

### Jeff Rosenbury

When the iron core is saturated, it no longer multiplies the inductance by µiron(≈600). Instead it multiplies it by µ0(=1). If you can spare another tap and input pin, use it with a different voltage divider.

Of course there are other possibilities. As the other posters alluded, transformers don't work with DC. Are you checking (and adding a check current) less often when the magnet is energized? (I assume you do something like this many times a second to get any result at all.)

11. Feb 5, 2016

### Michael P C

Circuit attached.

What do you mean by tap? Do you mean a second voltage divider to operate in the EM's on state?
And yes, I believe the readings are occurring every 50 milliseconds.

#### Attached Files:

• ###### EM.png
File size:
80.2 KB
Views:
40
12. Feb 5, 2016

### Jeff Rosenbury

In addition to being a magnet and and inductor, a coil can also act as an autotransformer. I had assumed yours did, but I see I was wrong. (A very clever design, BTW. I would have guessed it wouldn't work at all.) To do this extra leads are "T'd" in to the coil. These are called taps. Your coil doesn't have any.

If your only goal is knowing when the magnet is attached to metal, you might try the following:

1) Measure PC2. Store as PC2i. Check the real time clock.
2) Turn off the magnet.
3) Loop
3 a) Measure PC2 again
3 b) If PC2<(0.8)PC2i exit loop
4) Check the real time clock to see how long the loop took. (loop time)
5) Turn on the magnet. Return the loop time.

What this does is briefly weaken the magnet (by 20%) and measure the time it takes to drop by this amount. This time should vary depending on the state of the magnetic circuit formed by the magnet and either attached metal or air. My hypothesis is that these will be different. Test it and see.

This is a fairly ugly hack, but it might work.
Good luck.

13. Feb 5, 2016

### Staff: Mentor

TBH, that's a strange way to try to make a ferrous metal detector. Is there a reason you used that circuit? Where did you find it?

(and again, does your Arduino have an analog output pin that you could use instead?)

14. Feb 5, 2016

### Michael P C

Well, it's primary function is as an electromagnetic catch, but I also need to detect the presence both with the magnet powered on and off. Just trying to use it for both before I use a secondary sensor.

What are you suggesting I use an analog output pin for? It does have a couple available.

Last edited: Feb 5, 2016
15. Feb 5, 2016

### Michael P C

Still trying to absorb this solution. Does this require running this loop non stop until a hit is detected? I think I read this as changing my measurement from a voltage change to the time it takes for a voltage change of N amount. Is that right?

16. Feb 5, 2016

### Jeff Rosenbury

It is changing from detecting a voltage to detecting the time needed for a voltage change.

I'm not sure how much time the loop will take. First, it will need to be run every time you want a detection. Second, it may need to be run continuously, but it may not. The key is to get the time of the voltage change. If you can figure out a way to do that while doing other things, that would be great. If not, sadness. A lot depends on how long the loop takes which I can't estimate because I'm lazy. Since it will need to be measured anyway...

17. Feb 5, 2016

### Hesch

From the attached picture in #1, it seems to me that not the iron core of the magnet will be saturated, but the steel door.

By the way: What is meant by "steel" in this context?
Remember that stainless steel will not react to a magnetic field.
Maybe a capacitive sensor should be considered?

18. Feb 5, 2016

### Michael P C

The door is a ferrous alloy and the core is electrical steel. Do you think a capacitive sensor directly adjacent to the electromagnet be affected by the EM's fields?

19. Feb 5, 2016

### Hesch

Closing up a capacitive sensor, the change in capacitance will change the capacitive current, which can be measured. You must use AC-voltage, say 24V, 200 kHz.

You can sense an empty (wine)glass within a distance of 5 cm! And, well, with a steel door you must take care, that your capacitive sensor will not be "saturated".

20. Feb 5, 2016

### Michael P C

How about an inductive proximity sensor? I'm kind of planning on this as a last resort as long as it's not affected by the adjacent field.