Wiring a Solenoid Door Lock/Unlock Question

Discussion in 'The Projects Forum' started by VulnoX, May 30, 2008.

  1. VulnoX

    Thread Starter New Member

    May 30, 2008
    Hello all, I am in my last semester of my computer engineering degree, and one of our last classes is a senior design project. My group is making a security door system using an HC12 Microcontroller, a solenoid, IR sensor, a "security" computer, and all that.

    What I am here for is that I want to have it so that when the user enters a correct password, the MC can trigger a solenoid to lock/unlock a door. I was originally thinking of using just a sliding bolt lock to work best with the solenoids movements.

    My main issue is that being a CE, my experience with circuits is limited, and our EE in our group is not... doing much on this, so since I actually want to graduate, I thought I would look into it myself. I found a couple of the parts I think I need. I found a possible solenoid:

    and I think this might work for a power supply:

    I talked to some of the instructors/lab people at school and they suggested I make a circuit that is basically the power running to, I think they said, a transistor. They said there was a transistor that would allow me to run the power to one connection, and a digital logic signal from my Microcontroller, and so when the MCU sends the signal to unlock the door, the power would pass through the transistor into the solenoid, and unlock said lock.

    They also suggested picking up a diode, while on lunch today waiting for the food to be ready, I picked up a 12V, I think 600mA, something like that, Diode from Radioshack. It was a buck, if it doesnt work oh well.

    They said this would prevent the sudden power jump when the solenoid activates from frying the transistor.

    Ok now, if everything I have said so far is wrong, please give me some slack. I am basically doing all the microcontroller stuff, the EE stuff, and probably having to learn Python programming language, and I am pretty new to much of it.

    What suggestions would you have for wiring this up? Know of a better power source? A better solenoid? What kind of transistor would I need to do what I want (Activate when the MCU signals it)? Diode advice?

    Thanks in advance for your help on this, I want to make sure I do it right and don't destroy too many parts along the way.

    Edit: I just looked at the power supply and the solenoid again, and unless I am doing the calculations wrong, it looks like the PSU only supplies 500mA at 12V and 6W, the solenoid says its 8W at 12V, which should be 666mA requirement right?

    So those two will probably not like each other.

    Edit2: Maybe this one?
    Last edited: May 30, 2008
  2. gerty

    AAC Fanatic!

    Aug 30, 2007
    This is normally what is used:
    It is cut into the door jamb where the bolt (plunger) from the door knob goes.
    To answer your questions on what you posted, the second power supply should be adequate. The solenoid you had listed draws 5 watts and the first power supply you listed wouldn't have enough current. Another thing, the solenoid should be listed as "continous duty". I didn't see that in the link. All that means is that it can remain powered up for extended lengths of time without overheating.
    There are several factors to take into consideration for access control, the main one being you cannot lock someone in a building should a fire break out.
    Life Safety codes prohibit that, anyone behind a locked door must have a means of "egress" in a emergency. The solenoid you show will work under the proper conditions. The door must be closed before the solenoid can be engaged, and it must retract upon power failure (spring return) to be in the fail safe mode. The diode you mentioned probably wouldn't withstand the current of the counter EMF and would probably burn open. Let us know more details of what you need to do.
  3. Michel_e_r


    May 30, 2008
    I just recently finished a project which involved pretty much the same thing. I used a different lock. It might be helpful to you too:


    And how I designed mine is that the door can only be unlocked when the student swipes their student ID card (think of it like the password) and so if name matches with database, the microcontroller sends a signal (~3.3V) and unlocks the doors for 5 seconds (enough time for person to open the door) and then locks and user just closes the door and remains locked.

    At first I also used transistors to drive enough current to it and even used it for a relay. Yes, the diode protects the transistor or relay coil from reverse voltage when shut off..anyway..I'll just go straight to the point:

    What I did is use 12V relay and 2 non-inverted amplifiers (these are easy). If I could attach images that are not from websites it would be much easier. anyway. through the coils of the relay you want to have the outputs of the opamps. So one output of opamp goes to one of the inputs of the coil of relay and the other output of the opamp to the other end of coil of relay. Since I only had 12V to play with in my design, one of my opamp was set as follows:

    pin3: had the voltage input from microcontroller (3.3V)
    pin2: had 22k ohm tied to ground and 18k ohm (feedback resistor) from pin 6
    pin7: is the positive power of opamp so 12V
    pin4: is the negative power of opamp..this case it was just grounded
    pin6: is the output which is just fed to one of the coils as mentioned before.

    Other opamp

    pin3: grounded (no input)
    pin2: just a feedback wire from pin6
    pin4: grounded
    pin7: 12V
    pin6: output to other end of relay

    So on relay:
    One of the pins (refer to data sheet of the relay you are using) you put 12V. the pins with the coils, you already know what to put. Finally, the locks you would connected to the pin that connects when the coils cause a magnetic charge to make the switch. That's pretty much it. So when 3V are sent to the opamps it creates voltage differential among the other components and current flows through the coils to make the switch and the cabinet locks do their magic.

    I don't know if any of this helped, but good luck to you.
  4. VulnoX

    Thread Starter New Member

    May 30, 2008
    Thanks for the replies!

    Gerty - Thanks for the recommendation on the mag locks, those are just out of the price range for what we are going for I think.

    As for the solenoid, the specs on the page list the duty cycle as continuous, thats what you meant by it needing continuous duty right?

    Also, you mentioned fire hazard, that is a very good point, and on that I had some follow up questions, it says the solenoid I listed is the type: Tubular (Pull). That means that when the power is engaged to it, it would pull back the lock, otherwise the lock is engaged all the time correct?

    Would I want one that is a push, so when the power is on, it keeps the door locked? Would that also be a security issue (someone cuts the power, the door just unlocks).

    Which way should I go with this? One side is a safety issue I suppose, unless people could just open the lock from the inside. The other is a security issue, power is cut, the solenoid retracts (Push style solenoid).

    What size Diode do you think I would need?

    Michel - Thanks for the input, I might look into that as another alternative to the solenoid if I hit too many walls with it.

    As for the project, I mainly need to understand how to wire it so that:

    A signal comes from the Microcontroller (Available signals are, 3.3v, 5v, or a logic signal (0 or 1)).

    That signal engages the solenoid to retract, allowing the door to unlock and the user to enter.

    What type of parts do I need to make that wiring happen?

    As I said, people told me that maybe one or two transistors would work as the receivers of the signal from the board, and for the power from the power supply, and they would engage when the signal came from the board, allowing the solenoid to get power.

    I would need a diode to keep the power spike from frying the transistors once the solenoid was engaged.

    Just wondering if anyone had ideas as to what size/type of transistors and diodes are needed, as well as how this might be wired, or any alternative ideas as to how to make the solenoid work.

    Thanks again!
  5. gerty

    AAC Fanatic!

    Aug 30, 2007
    you would mount it so that when power removed door is unlocked.

    they couldn't open it if you have an exit device (keypad, switch) failure.But powering down the panel removes the power from the solenoid
    This is where battery backup comes into play. Wouldn't you want to be able to get out during a power failure?
    As for the diode,something like a 1n4001 or greater should suffice.
    Since the solenoid draws a little over 1/2 amp at 12v you could use practically anything for wiring (wouldn't go smaller than 22ga wire )..
  6. VulnoX

    Thread Starter New Member

    May 30, 2008
    Once again, thank you for the reply. That is exactly what I wanted to know, and I have worked with a 1n4001 diode before for in class labs, I believe, so that is pretty convenient.

    Thank you once again for all your advice, it is very much appreciated.

    Last thing, any idea what type of transistor would work best? One person I talked to said I would use two, another said I would use one. Not sure if you have much experience wiring a transistor to a logic system like the microcontroller, but any resources you know of that would be helpful are again, appreciate.

    Have a good night.
  7. gerty

    AAC Fanatic!

    Aug 30, 2007