Solenoid control w/Arduino

I am creating a solenoid lock system that is controlled by Arduino. I have a circuit set up but it doesn't seem to be working. I have checked and double checked everything but can't seem to find an issue. When I plug in the 12V 2A power supply into the wall the solenoid "turns on" unlocking the lock. It won't unlock and I want to be able to control its state via arduio. I am using a

Poilee 1N4001 Diode DO-41 Standard 1A 50V Rectifier Diode Electronic Silicon Diodes

and

Bridgold 20pcs TIP120 TO-220 NPN Darlington Bipolar Power Transistor, 5A 60V HFE:1000, 3-Pin

and

5K ohm resistor.

const int Lock = 3;

void setup() {
Serial.begin(9600);
pinMode(Lock, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(Lock, LOW);
  Serial.println("Locked");
  delay(2000);
  digitalWrite(Lock, HIGH);
  Serial.println("Unlocked");
  delay(2000);
}

Pictures.zip (993 KB)

The code locks and unlocks in a 4 second cycle. Draw and attach a wiring diagram.

I attached pictures before in a zip file, but this is the schematic drawn out. The code should output a 4 second cycle, however the lock is staying unlocked in the "HIGH" state.

The zip files are not the best, like small bird nests.
In the code You have defined "Lock" as 3 but Your drawing shows a Connection to Digital pin 13. That is where the onboard LED is connected.

Neither pin works. If I connect to pin 13 I see the LED flashing as it is supposed to. The lock however does not change state.

akinsjm:
Neither pin works. If I connect to pin 13 I see the LED flashing as it is supposed to. The lock however does not change state.

Hey. When the code accesses pin 3 You should only connect to pin 3. You can try and attach a resistor of some 10k to 47k between the base and emitter of the transistor. You can also reduce the base resistor to some 330 Ohm.

When I tried the different pins I changed it in my code as well. I tried both adding a 10K between the base and the emitter and reducing the base resistor to 330 and nothing has changed, the problem persists

'then it looks like the transistor is blown, burned through.

I have tried replacing the transistor and the diode multiple times and to no avail. Any other ideas? Your help is much appreciated!

Ok. Bring up Your multimeter and measure the voltage at the Arduino pin, the voltage at the base of the transistor.
You can also try a test code that outputs a LOW all the time.

Unfortunately I don't have a multimeter. I did try just doing low and it still activated the solenoid.

IMG_0385.jpg

IMG_0386.jpg

akinsjm:
I have tried replacing the transistor and the diode multiple times and to no avail. Any other ideas? Your help is much appreciated!

And no wonder it burns out every time! :astonished:

You have the diode connected the wrong way round, bypassing your solenoid! :roll_eyes:


Let me elaborate on that.

The diode bypasses the solenoid; the transistor is subject to the full voltage of your power supply - it burns out, in the process turning into a dead short. In turn this now burns out the diode making it open circuit so your solenoid is now permanently on.

Only outputting LOW in loop?
Has the diode been connected the right way? Else the transistor will blow immedeately.
Check the wiring.

Here it's getting late. See You tomorrow.

Paul__B:
And no wonder it burns out every time! :astonished:

You have the diode connected the wrong way round, bypassing your solenoid! :roll_eyes:

When I turn the diode the other way the diode only gets REALLY hot and the solenoid won't turn on then. The power supply also has a led that flashes on and off when the diode is switched. If the diode is the way I have it now then the diode doesn't get warm and the power supply led stays on constant.

A report but nothing untowards apart from too many "quotes" so what gives ?

Hfe is irrelevant for a saturated (switching) transistor.
To properly saturate a darlington transistor, like the TIP120, you need a base current of 1/250 of the collector current.
See the numbers top/right in the saturation graph of the datasheet.

You are driving the base with ~800uA (5volt, 4k7 resistor, ~1.3volt BE drop).
That's be ok for a small ~200mA solenoid.
But for a 1-2Amp door strike you should lower that base resistor to 1k, or even 470 ohm.
Even then the TIP120 will 'loose about 1volt, and could get warm.
It's the 21th century. We now use logic level mosfets instead of lossy bjt darlingtons.
Leo..

Hi,
The diode has a white ring printed on one end of the body, that is the cathode and in your case it should connect to the positive supply side of the solenoid.

If you disconnect the UNO from the protoboard and leave the 12V, transistor and solenoid connected, when you apply 12v to the protoboard, does the solenoid activate?

It is hard to tell from your picture, but is the blue wire going from the UNO to the protoboard gnd, connected to the UNO gnd or 5V?

Thanks.. Tom.. :slight_smile:

We are assuming the red PS wire is positive, could that be in error?