I want to control a small electromagnetic lock with an Arduino Nano. The input is by RFID - its not really a safe lock but its more something for fun.
The lock needs 12V, so I got a small plug-in 12V Power supply for it. To avoid needing a second power supply for the Arduino, I would like to use the same Power supply for this. The Arduino Nano has a Vcc input that can take up to 12V and internally converts it to the 5V which power the Arduino and the RFID reader module. The lock is activated with a Relais Module SRD05VDC-SL-C which is connected to the 5V out of the Arduino and of course GND and the control pin.
I attached a sketch without the RFID reader - and of course this is probably not going to be correct because the magnet is now directly connected to the same power supply as the board. I think at least I would need a diode to protect it, but probably that is not going to be enough. How can I make this work so that I only need one power plug? I think one option would be to use some kind of voltage regulator module like those "MB-102" Modules for breadboards, but is there another solution that may be easier, cheaper or smaller?
Connect a free wheel, kick back, diode across the inductor. Else You will face trouble.
Are You sure the Arduino 5 volt regulator can deliver current to both the controller and the 'RF reader? I am not.
Railroader:
Connect a free wheel, kick back, diode across the inductor. Else You will face trouble.
Are You sure the Arduino 5 volt regulator can deliver current to both the controller and the 'RF reader? I am not.
What do you mean with delivering the current to the controller - you mean the relais module?
I tried the setup without the magnet for a couple of times now to test the programming and so far it did work - read the RFID, set up the small relais and so on. So far it seems to work but I cannot exclude at the moment if this may be too much and cause issues in the long run?
I read up on the specs - the +5V delivered by the Nano can be used to power modules with 500-1000mA if the power input is 7-12V and at least 1A at the Vcc-input. This would be the power that cen be used by the RFID reader and the mini relais module. The Power supply I have has 2 A at 12V and the magnetic lock uses less than 500mA - so in theory the power should be ok for all elements.
If the 5 volt converter, on the Nano, has that much capacity, You must the be safe.
When the relay switches off the current to the solenoid the solenoid sends out the energy stored in the magnetic field. That will cause sparcs damaging the relay fingers and posibly disturb the execution of the code in the Nano. Therefore, always use a kick back diode when operating an inductor.
Ok, I tried doing it as I did in the drawing I attached. I put a Diode in the power supply to the board. The only ones I found in the Arduino Kit at the moment was a N4001 - is that the right one or do I need a special one?
I tried it but when the solenoid is deactivated, every 2-3 times the arduino stops and needs a reset, so clearly this is not preventing the power surge well enough, sadly. What else can I try?
P.S.: I tried another diode N4148 I found in the kit, but same thing happens - so maybe I will need one of these breadboard power supplies after all - or something similar that is smaller since I will eventually want to build this without the breadboard.
Paul_KD7HB:
Measure the resistance of the lock. That will tell you the current needed at 12 volts.
Paul
Hi. I measured the current with a multimeter - It was about 400mA I think. This would be drawn directly from the power supply though, which says it has 12V/2A, so I dont think the drain is really a big issue. I suspect it is more something like the power sparcs or how it is called that happens whenever the lock is powered down again, since only at that time the Nano stops working - powering the lock works and seems to work fine.
auroraglacialis:
Hi. I measured the current with a multimeter - It was about 400mA I think. This would be drawn directly from the power supply though, which says it has 12V/2A, so I dont think the drain is really a big issue. I suspect it is more something like the power sparcs or how it is called that happens whenever the lock is powered down again, since only at that time the Nano stops working - powering the lock works and seems to work fine.
That only shows the steady current. Unless you measure the resistance and use Ohm's law to compute the peak current, you will miss the most important current value.
Paul
Paul_KD7HB:
That only shows the steady current. Unless you measure the resistance and use Ohm's law to compute the peak current, you will miss the most important current value.
Paul
Ok - it reads at 30 Ohm. But I am not sure - this is the resting resistance, I think the issue here is with the induction? The 30 Ohm leads with Ohms Law to the 400mA I measured already. So that fits well, but it still does not really tell me about what happens when activating or shutting down the solenoid. However I did test it a few times now - it does activate fine, so there is clearly enough power to activate, the program keeps running and shuts it down after 10 seconds, the relais goes off and the solenoid goes off as well of course but then about half the time the Nano crashes - this clearly is from the shutdown of the solenoid as it only happens when it shuts down and not when it activates or when it is detached and the thing is running just with the relais to test (in that case it works fine for as long as I want)
Paul_KD7HB:
That only shows the steady current. Unless you measure the resistance and use Ohm's law to compute the peak current, you will miss the most important current value.
Paul
It's a solenoid so the steady current is enough. No inrush or stall current present.
Paul_KD7HB:
That only shows the steady current. Unless you measure the resistance and use Ohm's law to compute the peak current, you will miss the most important current value.
Paul
It's a solenoid so the steady current is enough. No inrush or stall current present.
auroraglacialis:
Ok - it reads at 30 Ohm. But I am not sure - this is the resting resistance, I think the issue here is with the induction? The 30 Ohm leads with Ohms Law to the 400mA I measured already. So that fits well, but it still does not really tell me about what happens when activating or shutting down the solenoid. However I did test it a few times now - it does activate fine, so there is clearly enough power to activate, the program keeps running and shuts it down after 10 seconds, the relais goes off and the solenoid goes off as well of course but then about half the time the Nano crashes - this clearly is from the shutdown of the solenoid as it only happens when it shuts down and not when it activates or when it is detached and the thing is running just with the relais to test (in that case it works fine for as long as I want)
auroraglacialis:
Ok, I tried doing it as I did in the drawing I attached. I put a Diode in the power supply to the board. The only ones I found in the Arduino Kit at the moment was a N4001 - is that the right one or do I need a special one?
I tried it but when the solenoid is deactivated, every 2-3 times the arduino stops and needs a reset, so clearly this is not preventing the power surge well enough, sadly. What else can I try?
P.S.: I tried another diode N4148 I found in the kit, but same thing happens - so maybe I will need one of these breadboard power supplies after all - or something similar that is smaller since I will eventually want to build this without the breadboard.
auroraglacialis:
Ok, I tried doing it as I did in the drawing I attached. I put a Diode in the power supply to the board. The only ones I found in the Arduino Kit at the moment was a N4001 - is that the right one or do I need a special one?
I tried it but when the solenoid is deactivated, every 2-3 times the arduino stops and needs a reset, so clearly this is not preventing the power surge well enough, sadly. What else can I try?
P.S.: I tried another diode N4148 I found in the kit, but same thing happens - so maybe I will need one of these breadboard power supplies after all - or something similar that is smaller since I will eventually want to build this without the breadboard.
Railroader:
It's a solenoid so the steady current is enough. No inrush or stall current present.A 4001 is fine but You added it in the wrong place. Across the solenoid, as close ad possible.
Sorry, but a solenoid is a motor. That thing that moves makes it a motor.
Paul
The difference between the OPs computed current and the measured steady state current came from where? On the other side, what will be the voltage generated by the armature returning to rest as the current generated by that is applied to an infinite resistance of the open relay contacts?
Difference? In reply #6 OP measured 30 Ohm and 400 mA. R * I == 12 volt, just as expected.
I say that the resistance of a conventional DC motor is quite low, so low that the we get a significant inrush current. When the motor has managed to spin up the load and the magnetic fields have settled, the inrush current goes down to a significantly lower steady current because of the electromagnetic forces built up in the windings.
Notwithstanding the current requirement of the electromagnet which is an inductor, not in any respect, a "motor" and has no "inrush" current, but does have a "kickback" when switched off and so requires a diode across the lock connections - not the power supply.
The problem here is that the relay module draws 90 mA when activated which is excessive for the on-board regulator on the Nano, especially when powered at 12 V. You need a switchmode "buck" converter to power the relay module and the Nano via its "5V" pin and the MFRC522 module with a 3.3 V regulator/ Level converter module as per this recent discussion.
The relay module power connections should be brought as a pair directly from the regulator board with its output bypass capacitor, and the 5 V power connections to the Nano likewise. The relay module control line should make its way along with the power connections to the regulator and then to the Nano if there is any distance between the parts.
Note that the "MB-102 Module for breadboards" is equally useless to the Nano on-board regulator as a 5 V source.
Railroader: Across the solenoid, as close as possible.
No, that is quite wrong as it happens.
The diode should be adjacent to the switching device (in this case the relay) and the supply bypass capacitor.
Paul_KD7HB:
Sorry, but a solenoid is a motor. That thing that moves makes it a motor.
This is to a small extent, true.
But it is not the same as a conventional motor with a "field" magnet, so no "inrush" current. The movement of the armature changes the inductance - it increases as it is pulled in - but this is really quite a slow occurrence.
In a motor, the "stall" or "inrush" current is limited only by the winding resistance; the running current by the back EMF. The winding inductance is actually mostly cancelled out as "shorted turns" by the construction of the motor.
This is not the case for the inductor which has substantial inductance irrespective of the armature position and rather than an "inrush" current, has a slow buildup. The maximum current is always limited by the winding resistance.
@Paul__B
I think we have settled the matter. I agree.
The power supply OP uses pulls the solenoid without failure. That's the main concern.
Regarding the positioning of the diode it's not critical but my general rule is to put a noice killer as close as possible to the source of the noice, which is the solenoid. But yes, putting it at the relay board will also work well.