Arduino Forum

Using Arduino => General Electronics => Topic started by: Gary_Arduino on Jul 20, 2018, 10:09 pm

Title: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 20, 2018, 10:09 pm
I have an electromagnet that is powered externally of my Arduino but that power is controlled by the Arduino through a relay.

Problem - the electromagnet will continue hold a strong residual magnetism after the power has been removed from it. This prevents the magnet from dropping it's load when the Arduino switches the power off.

Solution - turns out that a very SMALL amount of voltage applied in reverse polarity will instantaneously clear the magnetism. So, a quick pulse of low voltage from my Arduino would do the job!

Implementation Question
- Can I safely wire an additional Arduino circuit to the magnet, in reverse polarity, by using diodes to prevent the magnet's external power supply from traveling up that "reverse circuit" and shorting out my Arduino when the magnet is turned "on" ?


Things I have read about reversing polarity -
I understand that there is something called an "H Bridge" that allows you to reverse polarity on a motor, to run it in reverse. However, I don't need to "run" anything for any length of time. I just need a single, split second of power and a very small voltage at that. In a test (isolated from the Arduino) I have made the magnet release with a 3 volt spike but I suspect I can use even less than that. Also - the H Bridge seems complicated and perhaps expensive. 

I have also seen people mention they have used two relays to reverse polarity but I'd like to avoid that because that increase my project size and it will no longer fit into my project box. :(
Title: Re: Using diodes to protect from reverse polarity
Post by: bos1714 on Jul 20, 2018, 10:12 pm
Hello there!

During the operation of the electromagnet there is current going through the coil. When the power is removed via the relay, is there a path for the leftover current to go through or will it just stay in the coil?
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 20, 2018, 10:27 pm
Hi.
The magnetism can't actually be "drained off" and in fact can remain almost permanently ... until a current is allowed to pass through the magnet in the opposite direction.
It is apparently a physics phenomenon that I think I have seen called "Remanence".

To directly answer your question though, the circuit does not have such a "path". However in my initial attempts to deal with this residual magnetism (before I researched the problem) I did try connecting such a "path" but it had no effect.
Title: Re: Using diodes to protect from reverse polarity
Post by: bos1714 on Jul 20, 2018, 10:49 pm
I drew up a picture in microsoft paint of what I think your circuit looks like (I'm not sure if it's right or not). Is the black stuff correct for the most part?

If you put a diode in the configuration shown by the red symbol, that would allow current to flow through the magnet after the relay is turned off. After some time, the current should be dissipated by the magnet over time and should reduce the magnetic force.

(http://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=266897)
Title: Re: Using diodes to protect from reverse polarity
Post by: DVDdoug on Jul 20, 2018, 11:36 pm
Quote
Implementation Question - Can I safely wire an additional Arduino circuit to the magnet, in reverse polarity, by using diodes to prevent the magnet's external power supply from traveling up that "reverse circuit" and shorting out my Arduino when the magnet is turned "on" ?
Through another relay, yes.   The Arduino can't directly-power anything other than an LED.

An H-bridge will work but it has to be able to handle the current.

Diodes will NOT work.   The back-EMF from an inductor can be thousands of volts and it can fry the diode if you put the diode in series.      It is standard practice to add a reversed diode in parallel with the driver (or across the relay contacts).    The kick-back voltage from the inductor is reversed, so the diode conducts and the voltage is knocked-down to the diode's forward voltage (~0.7V).  The current through the coil remains the same for an instant after power is removed and that current flows-trough the diode and it decays as the magnetic field decays.  That's why you get a high-voltage spark when you disconnect a coil...  It's trying to push current through an infinite resistance.

Here (http://www.gammon.com.au/motors) is a motor driver with a protection diode.   


But, with the parallel diode you can't reverse the voltage because the reverse voltage will be "shorted out" the same way the back-EMF was shorted-out.

Quote
During the operation of the electromagnet there is current going through the coil. When the power is removed via the relay, is there a path for the leftover current to go through or will it just stay in the coil?
No, the current flow stops but the iron becomes permanently magnetized (to some extent).    A coil does "try" to keep current flowing as the magnetic field collapses.   

"Capacitors resist changes in voltage."
"Diodes resist changes in current."


That's an over-simplification and a series  capacitor passes  AC (changing voltage) and it blocks DC (constant voltage) as it "tries" to keep constant voltage across the capacitor.
Title: Re: Using diodes to protect from reverse polarity
Post by: ReverseEMF on Jul 21, 2018, 12:19 am
OK, since nobody (so far) has actually addressed the OP's actual question, how about this StrawMan:

(http://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=266907)
Caveats:



Also, "Dn" & "Dm" stand for the "Digital Outputs" on the Arduino.   For instance "D3" or" D12", etc.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 21, 2018, 03:18 am
Yes Thanks !
DVDdoug seems to have grasp my project exactly. Sorry for the initial, poor description.

While my Graphics Foo is not very good, I have drawn a VERY simplified version of the existing circuit and have attempted to attach it to this post.
I will also attach a simple diagram of what I had hoped to do ... but you have advised against.
(https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=266917)

 (https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=266915)

Before I read your reply, I did did a breadboard version of my idea (completely separate from the Arduino) using two diodes as shown and a 3volt power supply (two 1.5 volt batteries) for the V release. I did notice that only .7v came through the diodes but that was enough to instantly release the magnetized plate. BTW - I am powering the magnet with 5volts stepped up to 12v through a small (ebay special) amplification circuit.

Still ... better safe than sorry I suppose. Your suggestion would seem to provide that.
I may be able to squeeze another relay into my project box but I will have to "unmount" my existing componants :( and move things around a bit.

Thanks everyone. :)

Title: Re: Using diodes to protect from reverse polarity
Post by: MorganS on Jul 21, 2018, 06:27 am
How many amps and volts is this electro magnet? If it is under 30 then it is very easy to get an H-bridge motor driver to do that.

I do like Doug's schematic but if condition 3 (isolated supplies) is met then NONE of the diodes are required. You are losing up to 2.4V which is a significant fraction of a 12V supply. And the diodes get hot.

With dual-pole relays you don't need isolated supplies or diodes. With DPDT relays you can protect yourself from software errors switching both relays on at the same time. You could even make it work with a single supply, like an H-bridge.
Title: Re: Using diodes to protect from reverse polarity
Post by: MarkT on Jul 21, 2018, 12:31 pm
Yes Thanks !
DVDdoug seems to have grasp my project exactly. Sorry for the initial, poor description.

While my Graphics Foo is not very good, I have drawn a VERY simplified version of the existing circuit and have attempted to attach it to this post.

The second circuit seems to make no sense.  If the supplies are isolated the diodes can do nothing,
if the supplies are not isolated then one of the diodes is a direct power supply short to ground.

Isn't this a case of overthinking a simple problem?

You can use two current-limiting resistors to set a small reverse current through the electromagnet,
and a double-pole relay to switch the forward current.  In forward mode the relay also carries
current through both resistors, but this is a small fraction of the forward current so no problem.

On switch off the small reverse current is re-established by the resistors, cancelling the remanent field.

The resistors are cross-connected w.r.t. relay contacts of course so to reverse the current.  Two are needed
to prevent the relay from shorting the power supply.

Saves needing a whole H-bridge, and if the values turn out suitably the resistors would also act as
snubbers and speed-up the magnet switch off compared to a diode.

[ Its best to choose a thread title reflecting the nature of the problem, not of a proposed solution. ]
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 21, 2018, 12:42 pm
Diodes will NOT work.   The back-EMF from an inductor can be thousands of volts and it can fry the diode if you put the diode in series.
Well, actually, a series diode will neither have an effect, nor be "fried" since it will only ever be passing current in the forward direction whether that is while the electromagnet is powered or when it is turned off.

I understand that there is something called an "H Bridge" that allows you to reverse polarity on a motor, to run it in reverse. However, I don't need to "run" anything for any length of time. I just need a single, split second of power and a very small voltage at that. In a test (isolated from the Arduino) I have made the magnet release with a 3 volt spike but I suspect I can use even less than that. Also - the H Bridge seems complicated and perhaps expensive.
The H-bridge is the way - essentially the only way - to reverse the current in the electromagnet (using a single power supply).  A resistor or an alternate voltage source can be used to provide a lesser voltage/ current in the "reversed" direction.
Title: Re: Using diodes to protect from reverse polarity
Post by: MarkT on Jul 21, 2018, 02:29 pm
To clarify my circuit:
(http://sphinx.mythic-beasts.com/~markt/relay_circuit.jpg)
The diode might be optional if the resistor values needed for the reverse current happen to be
good enough to snub arcing in the relay contacts.

And of course the relay drive circuit needs a snubber diode, goes without saying...
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 21, 2018, 11:40 pm
So you are proposing using the forward voltage drop of the diode as a regulator to deliver about 1 V to the electromagnet in reverse?

Use two diodes in series if a higher voltage is required.
Title: Re: Using diodes to protect from reverse polarity
Post by: MorganS on Jul 22, 2018, 12:15 am
It seems like a good scheme for heating up the diode. I doubt that it will do much for killing the electromagnet quickly.
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 22, 2018, 12:26 am
No, he actually did say:
I did notice that only .7v came through the diodes but that was enough to instantly release the magnetised plate.
Title: Re: Using diodes to protect from reverse polarity
Post by: FredScuttle on Jul 22, 2018, 01:28 am
How 'bout this?
(http://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=267071)
The small reverse current does not demagnetize the plate, but repels it (same polarity magnetic fields), wonder if a charged up cap would be enough instead of opposite current?
Title: Re: Using diodes to protect from reverse polarity
Post by: Wawa on Jul 22, 2018, 04:39 am
SPDT relays are more common in the Arduino world.
Both NC conatcts to ground, both NO contacts to supply, solenoid between the two CO contacts.
Maybe easier to understand when drawn as an H-bridge.

Four diodes can be a bridge rectifier.
2*AC to solenoid, + to supply, - to ground.
Leo..
(https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=267076)
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 22, 2018, 07:11 pm
Wawa's idea seems do-able. Although it still has me trying to squeeze yet another relay into my project box. When I initially designed this project I didn't know about Remenance. If designing a circuit to deal with it seems like such an after thought ... that's because it is.  :smiley-confuse:

Four diodes can be a bridge rectifier.
2*AC to solenoid, + to supply, - to ground.
Leo..
When you say "2*AC" what does this refer to? Not AC as in AC vs. DC ?

BTW - here is a picture of the type of Relay I have been using.

(https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=267144)
Title: Re: Using diodes to protect from reverse polarity
Post by: Wawa on Jul 22, 2018, 11:05 pm
When you say "2*AC" what does this refer to? Not AC as in AC vs. DC ?
Referring to the terminals of a bridge rectifier.
Leo..
Title: Re: Using diodes to protect from reverse polarity
Post by: Wawa on Jul 22, 2018, 11:09 pm
Could have a resistor in the 12volt line to the "reverse curent relay", for a lower reverse current.
Leo..
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 23, 2018, 01:23 am
Could have a resistor in the 12volt line to the "reverse current relay", for a lower reverse current.
Could have?  Must have to fulfil the objective.

But MarkT's circuit with a DPST (or DPDT) relay should actually work just fine, except that it continues to drive the reverse current.
Title: Re: Using diodes to protect from reverse polarity
Post by: Wawa on Jul 23, 2018, 01:37 am
But MarkT's circuit with a DPST (or DPDT) relay should actually work just fine...
The diode limits reverse voltage across the coil to 0.7volt.
Leo..
Title: Re: Using diodes to protect from reverse polarity
Post by: FredScuttle on Jul 23, 2018, 04:49 am
I don't like drawing higher currents (did the OP ever say how much?) thru NC contacts, most relays I've ever replaced that were switching motor current had the NC contacts burned or welded.
Also, I used a FWB (1 part, 4 leads) instead of 4 diodes (4 parts, 8 leads), me lazy :)
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 23, 2018, 04:59 am
The diode limits reverse voltage across the coil to 0.7volt.
Which as I did point out out in reply #13, the OP had stated in reply #6 was quite sufficient to provide the counter-magnetism so should be quite effective.

But if more voltage was required, this could be arranged by putting two or more diodes in series which would equally (or arguably even more) effectively manage the "kickback" since allowing a higher voltage quenches the current more rapidly.  :smiley-lol:

I don't like drawing higher currents (did the OP ever say how much?) thru NC contacts, most relays I've ever replaced that were switching motor current had the NC contacts burned or welded.
More support to using NO contacts only, though I suspect this actually relates to breaking current through NC contacts, which does not happen in this case.  12 V was mentioned, but not the actual current.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 23, 2018, 06:03 am
Sorry about not posting the current. I actually don't know.
The last time I ran a powered up test and had my meter hooked in-line ... seems like the magnet was pulling maybe .5 amps.

What I DO know is that it was like .1amp over what the USB output of my computer was rated for so THAT was the point I decided that the magnet needed it's own power supply.

I will also add that, while using that same power supply to provide the reverse power spike does simplify things somewhat (one circuit to rule them all) ... 12v is WAY overkill for what is required to eliminate the Remenance.
I really am curious as to how little it will take. We already know that .7volts from a AA battery was more than sufficient.  I may spend my next bit of bench time, setting up and testing that.
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 23, 2018, 08:33 am
The last time I ran a powered up test and had my meter hooked in-line ... seems like the magnet was pulling maybe .5 amps.

What I do know is that it was like .1amp over what the USB output of my computer was rated for so that was the point I decided that the magnet needed it's own power supply.
Well, you did say:
I am powering the magnet with 5volts stepped up to 12v through a small (eBay special) amplification circuit.
So if you multiply the voltage by 2½ times, then the input current to your boost regulator will be multiplied by at least three times, so a magnet current of .5 Amp will require 1.5 Amps at 5 V.

Just measure the magnet resistance with the Ohms range of your digital multimeter.  Subtract the resistance of the multimeter probes measured when you hold them (firmly) together.

I will also add that, while using that same power supply to provide the reverse power spike does simplify things somewhat (one circuit to rule them all) ... 12v is WAY overkill for what is required to eliminate the Remanence.
Clearly.  So you will need at least one resistor and  for the circuit with the DPST relay that will be the total of the two "crossover" resistors.  If you control the "shutdown" input of the boost converter, you can avoid it consuming power once the "release" pulse is delivered.  Now that I think of it, an "H-bridge" may actually be arranged very simply in this situation as the boost converter itself would form half of the H-bridge and avoid using a relay.

I really am curious as to how little it will take. We already know that .7volts from a AA battery was more than sufficient.  I may spend my next bit of bench time, setting up and testing that.
Well, an AA (Alkaline) battery gives 1.5 V, not 0.7 V.  But if 0.7 V is sufficient (and you do need to double check that measurement), then that is also the voltage across a power diode if you specify the "crossover" resistors accordingly.
Title: Re: Using diodes to protect from reverse polarity
Post by: MarkT on Jul 23, 2018, 12:40 pm
The diode limits reverse voltage across the coil to 0.7volt.
Leo..
Who cares, the bulk of the voltage is across the current limiting resistors.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 23, 2018, 04:24 pm
Well, an AA (Alkaline) battery gives 1.5 V, not 0.7 V.  But if 0.7 V is sufficient (and you do need to double check that measurement), then that is also the voltage across a power diode if you specify the "crossover" resistors accordingly.
That reading of .7v was the voltage of the AA passed through a diode during an early test to make sure I understood how the diode worked and if it would pass enough current/volts through it to clear the Remenance.

One of the underlying purposes of this project is to give me hands on experience as I teach myself electronics Sadly, I learn better by doing (and frequently failing) then from JUST reading something in a book.

BTW - the resistance of the magnet is .064ohms. So subtracting the probe resistance gives me a reading of .056ohms
Title: Re: Using diodes to protect from reverse polarity
Post by: MarkT on Jul 23, 2018, 04:49 pm
The completely random other approach is to stick tape on the electromagnet pole till there's enough
magnetic gap to defeat the remanence (assuming this doesn't reduce the active force too much for
the application).
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 23, 2018, 10:30 pm
BTW - the resistance of the magnet is .064ohms. So subtracting the probe resistance gives me a reading of .056ohms
And what current would flow if you applied 12 V to .056ohms?
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 23, 2018, 11:01 pm
And what current would flow if you applied 12 V to .056ohms?
Wait wait, I think I remember THIS one!
It's I = V/R   
So 12/.056 =
... that can't be right.   
214 amps?!?

If it is pulling that much shouldn't all of this be on fire?

I am clearly confused.
Title: Re: Using diodes to protect from reverse polarity
Post by: MorganS on Jul 24, 2018, 12:01 am
You did the calculation correctly. 214 amps is the correct answer.

But I suspect the measurement was wrong. Might that be kilo-ohms? Decimal point moved? Most multimeters won't read micro-ohms.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 24, 2018, 09:56 pm
More data -

I have a Drok USB Tester and hooking that in line between my power supply (A USB battery supply) and the power amplifier I see that the supply is putting out 5.08v and the amplifier is drawing .51amps.

Putting that tester between the amplifier output and the electro-magnet, I see that the amplifier is putting out 10.5V  It is adjustable and apparently that was the setting I decided I needed when I first set it up a few months ago.
The magnet is drawing .21amps

I am now I am wondering if one of the Arduino's PWM pins (with a circuit to dial down the 3volt power supply) might be able to put out the small pulse I'd need to remove Remanence.
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 25, 2018, 12:23 am
I am now I am wondering if one of the Arduino's PWM pins (with a circuit to dial down the 3volt power supply) might be able to put out the small pulse I'd need to remove Remanence.
And that is exactly what I was thinking.

If you use an Arduino pin to switch the boost converter on or off by its enable pin, connect it to one end of the magnet.  The other end of the magnet is grounded by a diode and connected through a resistor to a second Arduino pin.  You have a logic level FET, also controlled by the same (that is, second) pin which grounds the output of the boost converter.

You now have an H-bridge.  When the boost converter is enabled, it powers up the magnet, losing only the voltage drop of the diode.  When you shut off the boost converter, waiting for its output capacitor to discharge, you then switch on the second Arduino pin for a short time which applies 0.7 V to the diode and grounds the first end of the magnet.

PWM has absolutely nothing to do with this.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 25, 2018, 11:14 pm
Paul__B ... Is this diagram what you were suggesting?

(https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=267574)
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 26, 2018, 12:28 am
Paul__B ... Is this diagram what you were suggesting?
(https://forum.arduino.cc/index.php?action=dlattach;topic=559200.0;attach=267574)
Errr, no!  That would not do anything.
(https://forum.arduino.cc/index.php?action=dlattach;topic=175015.0;attach=267581) (https://forum.arduino.cc/index.php?action=dlattach;topic=175015.0;attach=267581)


Title: Close, but no cigar!
Post by: Paul__B on Jul 26, 2018, 12:35 am
You could indeed use a relay in this configuration to switch the "hot" end of the magnet between your 12 V and ground if it were not practical to find the enable pin on the boost converter, but I figure what I have suggested is substantially more compact and - avoids the relay (current draw).

OK, you just put the diode in the wrong place.  :smiley-eek:
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 26, 2018, 03:14 am
Ok.
I'm going to need to study this a bit.

Wow - so now I have many questions. It's embarrassing really as this has gone well beyond asking for advice and has now moved into the area of tutoring. I apologize.

Starting with a clarification. My power booster is VERY simplistic. Unlike the booster in your diagram mine only has + and - Vin and Vout. No other connections.

1) As it is wired now, my 5 volt power supply and the power booster are entirely separated from the rest of the Arduino circuitry. They go directly to the magnet with just an in-line relay to interrupt the power flow. That relay IS controlled by the Arduino but I believe the "power" side of that relay is opto-isolated(?) from the Arduino.
Your circuit drawing seems to have everything sharing the same ground. Would that provide a possible path for some errant power surge from the magnet to get to my Arduino?

2)What is "Logic Level" in your circuit? Is that a transistor or maybe a relay?

3) It appears that the "release pin" is wired directly to the "ground" side of the magnet. What keeps the 12v power from traveling up that wire to the release "output pin" and frying the Arduino? I thought that is where a diode would need to go because it would only allow power to travel from the pin and not up into it (like a one way valve).
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 26, 2018, 08:56 am
Starting with a clarification. My power booster is VERY simplistic. Unlike the booster in your diagram mine only has + and - Vin and Vout. No other connections.
Actually, I don't believe you.  I suspect it is one of those ones from eBay and with a bit of hacking, does have an enable line.  You need to show which one it is and we can work from there.

1) As it is wired now, my 5 volt power supply and the power booster are entirely separated from the rest of the Arduino circuitry. They go directly to the magnet with just an in-line relay to interrupt the power flow. That relay IS controlled by the Arduino but I believe the "power" side of that relay is opto-isolated(?) from the Arduino.
The photograph suggests the relay module has only four connections on the control side, which would be Vcc, ground and two control inputs.  If so, it can not be isolated, whether or not it happens to have opto-isolators on it.  Again, a Web link to where it is described would be most practical.

In any case, you can use the relay to switch the voltage to the magnet between ground and the 12 V (but you will need another diode!), in which case you do not need the FET.  My proposition is that you can do without the relay.

Your circuit drawing seems to have everything sharing the same ground. Would that provide a possible path for some errant power surge from the magnet to get to my Arduino?
It might if you did not make the connections in the correct order.  No part of the ground wiring path should be shared between the magnet and power supply to the Arduino.

2)What is "Logic Level" in your circuit? Is that a transistor or maybe a relay?
A FET specified as a "logic level" device whose lowest effective "on" resistance is achieved at 3 V.

3) It appears that the "release pin" is wired directly to the "ground" side of the magnet. What keeps the 12v power from travelling up that wire to the release "output pin" and frying the Arduino? I thought that is where a diode would need to go because it would only allow power to travel from the pin and not up into it (like a one way valve).
And indeed, there is a diode there that does exactly that.  It holds the voltage when the magnet is energised, to one forward diode drop voltage, and also limits the voltage which is used to reverse-power the magnet to no more than about 1 V, if that.  The current from the Arduino is defined by the resistor, which will probably be close to 1k if your coil resistance is in fact, 56 Ohms as you measured.
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Jul 27, 2018, 01:07 am
So this, to me, seems like an elegant solution to this. I just have to figure out how to make it.
I'm about to go on travel and hopefully I will get some time to study it.

BTW - Here is a link to information about the power booster I am using
 https://www.addicore.com/MT3608-Boost-Converter-p/ad300.htm (https://www.addicore.com/MT3608-Boost-Converter-p/ad300.htm)
I ordered it before I knew even as much as I do now ... which isn't much. It seems to work well but if you needed a very precise voltage it probably wouldn't do the trick.


I couldn't find a schematic for the relays I am using. It is the 2PH63091A 2 Relay Module although I am only using one of the relays for the magnet. The other relay is being used to apply completely separate power to something else.
The modules themselves are the JQC-3FF-S-Z
A picture of which is here https://i.stack.imgur.com/TWLit.jpg
but the controller board is different for the 2 Relay Module I am using.
Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Jul 27, 2018, 01:58 pm
So this, to me, seems like an elegant solution to this. I just have to figure out how to make it.
I believe it is a terribly elegant solution.  Well, perhaps not - second thoughts as below:

BTW - Here is a link to information about the power booster I am using
 https://www.addicore.com/MT3608-Boost-Converter-p/ad300.htm (https://www.addicore.com/MT3608-Boost-Converter-p/ad300.htm)
I ordered it before I knew even as much as I do now ... which isn't much. It seems to work well but if you needed a very precise voltage it probably wouldn't do the trick.
But you do not require a precise voltage - that is quite a different circuit.  OK, here is your module (from another well-known seller):
(https://i.ebayimg.com/images/g/31kAAOSwNkJaL3gi/s-l1600.jpg) (https://i.ebayimg.com/images/g/31kAAOSwNkJaL3gi/s-l1600.jpg)

If you look at the datasheet (https://www.olimex.com/Products/Breadboarding/BB-PWR-3608/resources/MT3608.pdf), you will note that the enable pin is pin 4 which on the module you have is connected to pin 5, Vin and a simple hack to this module is to cut that connection with a craft knife so that with due care, you could solder the bared end of a fine flexible insulated wire to pin 4 (lower right pin on that image).  This is the pin you would connect to your Arduino (by as short a path as possible) to switch the boost converter on and off.  Unfortunately, I have just realised that this will not drop the output voltage to less than 4.7 V on a boost converter so we will have to forget that and use the relay!  :smiley-roll:

One last thought - the supplier from which you bought that module at least has used capacitors of reasonable size.  Hopefully they are the 22 µF specified in the datasheet.  I notice many suppliers picture very small capacitors which I suspect are dodgy.

Anyway, I just ordered five of those boost converters (https://www.ebay.com.au/itm/5PCS-MT3608-2A-DC-DC-Step-Up-Power-Apply-Module-Booster-Power-Module-Arduino-S/191917352178) to play with.   :smiley-lol:

I couldn't find a schematic for the relays I am using. It is the 2PH63091A 2 Relay Module although I am only using one of the relays for the magnet. The other relay is being used to apply completely separate power to something else.
The modules themselves are the JQC-3FF-S-Z
A picture of which is here (https://i.stack.imgur.com/TWLit.jpg).
but the controller board is different for the 2 Relay Module I am using.
(https://i.stack.imgur.com/TWLit.jpg) (https://i.stack.imgur.com/TWLit.jpg)

Right.  I think from your rather congested photograph that you are using one of these (https://www.ebay.com/itm/5V-Two-2-Channel-Relay-Module-With-optocoupler-For-PIC-AVR-DSP-ARM-Arduino-NEW/281683101414) modules.
(https://i.ebayimg.com/images/g/jtQAAOSw2PtaqFxX/s-l1600.jpg) (https://i.ebayimg.com/images/g/jtQAAOSw2PtaqFxX/s-l1600.jpg)

These are actuated by a LOW level output though you could re-work the connections for a single relay to operate on a HIGH output.  This is the schematic diagram:
(http://arduino-info.wikispaces.com/file/view/OptoRelayChannelDataE.jpg/601070012/800x329/OptoRelayChannelDataE.jpg)

To use them correctly, you remove the jumper, connect GND and JD-VCC with a pair of wires (in one bundle) direct to the 5 V power supply, connect Vcc and your inputs but not GND to your Arduino which is powered by a separate, bundled, pair of wires from the power supply.  A 470 µF capacitor across the relay power wires at the relay board would be a good idea.

Happy holiday!  :smiley-lol:  :smiley-lol:
Title: Re: Using diodes to protect from reverse polarity
Post by: Gary_Arduino on Aug 02, 2018, 11:53 pm
An update for anyone still following this thread.

Just because I could, I ran a test.
- I energized the magnet, picked up a metal plate and then removed the magnet from the power source.
- I ran Arduino Pin 4 through a diode to what had been the negative side of the magnet.
- I ran what had been the positive side of the magnet to Arduino Ground.

A quick bit of code that assigned Pin 4 as an output, initially set to LOW, then changed to HIGH for a delay of 100
and then back to LOW.
When run, the magnet drops its metal plate immediately. I experimented with several delay settings until I found the shortest period that would reliably cause the magnet to loose it's Remanence.

So, as was predicted - 5volt Arduino output run through a diode and reduced to .7volts WILL remove the Remanance in this scenerio.


Title: Re: Using diodes to protect from reverse polarity
Post by: Paul__B on Aug 02, 2018, 11:59 pm
It is not clear from your explanation there whether the diode was in series or in parallel to the magnet.  If it was in series, you would have been applying 5 V minus 0.7 V, thus 4.3 V to the magnet.  Only if the diode was in parallel to the magnet would you have been applying just 0.7 V.

In any case you would need a (220 Ohm) resistor to limit the current as putting a 56 Ohm load across the Arduino output overloads it.
Title: Re: Using diodes to protect from reverse polarity
Post by: ReverseEMF on Aug 05, 2018, 07:13 am
Sadly, I learn better by doing (and frequently failing) then from JUST reading something in a book.
Nothing sad about it.  Most college courses in this arena are composed of both a Lecture and a Lab -- because there is nothing like hands on experience when learning something new.