Author Topic: Switching 12v magentic lock with NPN PN2222  (Read 2221 times)

HeneryH

  • Full Member
  • ***
  • Posts: 229
Switching 12v magentic lock with NPN PN2222
« on: November 26, 2018, 11:03:55 PM »
Is this simple NPN as a switch a proper design?  Do I just replace that cloud area on the low side of the lock with the NPN as shown?

I have a 12v magnetic lock for a gate that I'd like to switch via Moteino.  There is currently a simple 12v transformer that is driving the lock.

Sorry for the hand-drawn...

Should the 12v ground and the 3.3v ground be tied together?

[edit - the vcc is actually likely the 3.3v rather than 5v]


Using this design would be much cheaper than dedicating a SwitchMote to the 12v transformer.
« Last Edit: November 27, 2018, 07:56:23 AM by HeneryH »

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Switching 12v magentic lock with NPN PN2222
« Reply #1 on: November 26, 2018, 11:30:50 PM »
One of my gate locks runs at 300mA while the other uses 450mA so using https://learn.adafruit.com/transistors-101/faq I calculated the resistor values to be 0.9 k-ohm and 0.6 k-ohms respectively.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Switching 12v magentic lock with NPN PN2222
« Reply #2 on: November 27, 2018, 08:44:36 AM »
Since the Lock is undoubtedly a solenoid and is, therefore, an inductive load, I'd recommend a clamp diode across the Lock.  Cathode to 12V, Anode to the collector of the transistor.  This will clamp the inductive voltage spike produced by the solenoid when the transistor turns off.  Current rating of the diode needs to be slightly greater than the current drawn by the solenoid (1Amp 1N4001 would be common).

Tom

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Switching 12v magentic lock with NPN PN2222
« Reply #3 on: November 27, 2018, 11:13:45 AM »
Thanks Tom.


HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Switching 12v magentic lock with NPN PN2222
« Reply #4 on: November 27, 2018, 11:26:51 AM »
Hopefully it doesn't fry!


Jason

  • Jr. Member
  • **
  • Posts: 57
Re: Switching 12v magentic lock with NPN PN2222
« Reply #5 on: December 06, 2018, 09:30:05 PM »
Since the Lock is undoubtedly a solenoid and is, therefore, an inductive load, I'd recommend a clamp diode across the Lock. 

I was curious about this.  Apparently this diode can also be called a Flyback Diode.  The page on Wikipedia https://en.wikipedia.org/wiki/Flyback_diode explained it well enough for me to understand.  I also found this diagram to be helpful.
« Last Edit: December 07, 2018, 08:40:19 AM by Felix »

galah

  • NewMember
  • *
  • Posts: 9
Re: Switching 12v magentic lock with NPN PN2222
« Reply #6 on: December 11, 2018, 03:19:38 AM »
The 2222 is a bit small for this. Its really a small signal general purpose NPN.

For a 500mA collector current, beta might be as low as 10, meaning you have poke 50mA into its base to get it to turn on properly. Which the moteino cannot supply. There are better choices.
 
There are lots of NFETS that would turn on to a lower on resistance, and not need to waste base current.   Choose anything rated for 1 or more amps of drain current, and logic level gate drive. They will switch this load reliably.

And yes, that catch diode across the solenoid is a really good idea.      If you expect the transistor to turn off again.     More important for a bipolar than a DMOS.

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Switching 12v magentic lock with NPN PN2222
« Reply #7 on: December 11, 2018, 08:12:43 AM »
The 2222 is a bit small for this. Its really a small signal general purpose NPN.

For a 500mA collector current, beta might be as low as 10, meaning you have poke 50mA into its base to get it to turn on properly. Which the moteino cannot supply. There are better choices.
 
There are lots of NFETS that would turn on to a lower on resistance, and not need to waste base current.   Choose anything rated for 1 or more amps of drain current, and logic level gate drive. They will switch this load reliably.

And yes, that catch diode across the solenoid is a really good idea.      If you expect the transistor to turn off again.     More important for a bipolar than a DMOS.
I might go with a relay solution that I have some parts for.  Thank you for the topics to think about with this solution.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Switching 12v magentic lock with NPN PN2222
« Reply #8 on: December 11, 2018, 09:23:17 AM »
The 2222 is a bit small for this. Its really a small signal general purpose NPN.

For a 500mA collector current, beta might be as low as 10, meaning you have poke 50mA into its base to get it to turn on properly. Which the moteino cannot supply. There are better choices.
Good catch!