The circuit has two parts, the controller itself and the touch-pad PCB. First, the controller PCB schematic (*click on the image to maximize it*):
There are 3 pins to provide power that goes to connector X1. #3 pin is the ground, #2 is for the 3 volts and #1 is for the 6 volts. The diode D1 is a schottky diode to separate the PIC's voltage from the rest circuit. To ensure that the PIC will operate smoothly, i added a large 1000uF capacitor. C3 and C4 are 0.1uF capacitors to filter high frequency spikes.
I added a typical ICSP connector. I always use the same wires for the ICSP: Reset - +5 - Ground - Data - Clk. This way, i have a wire that can be connected to the ICSP input of all my projects. D4 is not really necessary, as long as the MCLR pin is kept as an input.
The connector X2 is for the door-pull switch. This switch, will be either a mechanical or a reed switch, used to detect whenever the door is pulled backwards. It will be used to wake up the PIC from sleep (using the RB0 interrupt), and also to enable the servo to open, IF the code entered was correct.
Rb1 through RB5 inputs of the PIC are sued for the touchpad. They can be multiplexed to provide up to 15 buttons, but i will use 10 or 12. The touch-pad is covered in another page.
RC2 is a PWM output from the PIC. The T2 transistor is a BC548 current amplifier, to drive the data input of the servo. RC6 drives through a similar transistor a passive buzzer. I chose to use a passive instead of an active buzzer, because i wanted to have different sounds than the typical "beep" annoying noise.
The servo is connected to the SV2. The power supply of the servo goes through the latching relay. An inductor is always important to drive a motor safely from the same supply with he microcontroller. RD2 and RD3 outputs control the SET and RESET coils of the relay. The reason that i chose a latching relay, is to save power when in operation. To set the output, only a 100mSec pulse is needed to drive the SET coil, and this is the only power that the coil will draw.
Making the PCB
The artwork on transparent film and the PCB
This is the PCB that i made
After drilling and soldering the parts...
The board has to be thin to fit in the door
The goal is to keep the board as thin as possible. So, i soldered the capacitors horizontally. Here is the EPS file for you to download and develop this PCB:
Sorry,to be more precise I meant the wire which is attached to your servo to unlock and lock the door. There is something like a piece of tape holding them together, looks really solid! May i know what did you use for to hold the 2 pieces of wire together?
Going through your schematics, the keypad (without the LED backlit) is powered from the main PIC, or am i missing something? Even going through the code you have the RB5 port set as KeypadSupply. I know that the PIC16F1937 can work with very low current, I'm just trying to confirm if i need an external power pin on the keypad. (The backlit is already powered externaly in my design)
I understand the color coding for the RC servos, i just wanted to confirm the connector layout on your project. In the code the PWM pin is connected to register C2, which means that the D registers and the relay are used for power, is that correct?
Also is it safe to power the keypad directly from the PIC via the B5 pin without a transistor?
Thank you for your replies, I'm trying to expand this project a bit with an LCD and other periferals. However that relay's got me a bit perplexed, still does tbh. Also I haven't seen the 100uH inductor on the photos. If im correct a 0.5A inductor should be enough, right?
Hello, Your work is interessant. I have well test the same capacitive
keyboard like your. Now I would like to test the
communication with a PC by rs232. But I do not sometimes happen to
find this program for the keyboard on your site. Could you help me to
find it? Thank you.
Great project. We want to make an electronic door for our hackerspace in Istanbul, Turkey. We are lokking for something that actually locks the door. In your case, the system only pulls the thing at the top, right? It does not actually fully lock or unlock the door.
How can we do that for more security? What would be your suggestions. Thank you.
@Giorgos Nak a solenoid would work as well, but the problem is that you want the "tongue" of the locker to remain open for 3 seconds so that you have time to open the door. This means that the solenoid must be always powered for these 3 seconds, something that does not happen with the motor. The breaking power of the gears is enough to hold the tongue in the opened position. So, the motor works for a few miliseconds to pull the tongue and then you remove the power for as long as you want, until again the power is connected to release the tongue. This is for me a good solution. For better power consumption i would get a better servo with smaller motor.
But think about this: every time you open the door, the servo draws 200mA for 1 sec to open another 150mA (less torque needed) for 1 sec to close, a total of 350mA for 1 second. A typical (non-alkaline) battery can provide 1200mAh. This means that the 4 batteries (6V @ 1200mA) can open and close the servo about 12.000 times (theoretically). I use 4 alkaline batteries.
I really thank you for the prompt reply.
I tried also to manufacture something similar, and I used a DC motor (with gearing to transfer the movement). The current that the motor draws is 150mA approx. So, you would also propose something different than the servo or the DC motor to create the wanted movement?
I had measured the current of the servo and it was around 200mA (if i remember correct). An estimation with many educative guesses was that the batteries will hold more than 1 year with normal operation (12 openings per day, every day). There are better products than the cheap servo i used of course, but not a simple DC motor because the servo has the built-in controller for the positioning.
The best 3 points for limiting the power consumption are the sleep mode of the PIC (16uA standby-current), the mechanical switch to wake up the PIC (so no more standby current is required) and the latching relay to power the servo only when moving.
I write to you some thoughts that came up seeing the videos.
1. Have you measured the mA that the servo draws and also the power consumption during the movement?
2. Which could be in your opinion an estimated lifetime of the batteries with a normal use?
3. A simply DC motor (of course using a gearing to reduce speed) could be maybe less power \"hungry\" than the servo?
@shobdy no this is not correct. check this out:
the touchpad is exactly this, only that i have add the resistors and the transistor for the leds. That page will help you. I use these channels:
which correspond to these buttons respectively:
OK, after going through the ASM with my limited knowledge the best I could figure out is:
Pin 34 (Cap_check_Ch_1) is hooked to touch pad 1
Pin 35 (Cap_check_Ch_2) is hooked to touch pad 2
Pin 37 (Cap_check_Ch_3) is hooked to touch pad 3
Pin 38 (Cap_check_Ch_4) is hooked to touch pad 4
Pin 06 (Cap_check_Ch_5) is hooked to touch pad 5
Pin 07 (Cap_check_Ch_6) is hooked to touch pad 6
Pin 19 (Cap_check_Ch_7) is hooked to touch pad 7
Pin 20 (Cap_check_Ch_8) is hooked to touch pad 8
Pin 21 (Cap_check_Ch_9) is hooked to touch pad 9
Pin 27 (Cap_check_Ch_10) is hooked to touch pad 10
I thought I just about had the keypad figured out when I noticed that the pins on the PIC didn't make sense to me. It looks like (from looking at your printouts of the front and back of the PCB):
Pin 37 is hooked to touch pad 1
Pin 35 is hooked to touch pad 2
Pin 27 is hooked to touch pad 3
Pin 38 is hooked to touch pad 4
Pin 34 is hooked to touch pad 5
Pin 21 is hooked to touch pad 6
Pin 06 is hooked to touch pad 7
Pin 19 is hooked to touch pad 8
Pin 20 is hooked to touch pad 9
Pin 07 is hooked to touch pad 0
Is this correct? I may be able to go through the ASM and figure it out before you respond but it is always better to ask the designer if you can :)
@shobdy correct, these are 2 more LEDs to show the status, the red and green LEDs. I do not use them any more, you can totally omit them. I do have though a connector in case that....
The VLED is not part of the PCB. It is a wire that goes directly onto a transistor. The transistor is on the air, it is not soldered anywhere. When i decided to add backlit, i had already the PCB made, and i did not make a new. (http://pcbheaven.com/projectpages/images/servoactuateddoorkeylockhack_1309163657.jpg)
As for the resistors, any value between 220 and 6K8 will do. I used 6K8 because the PIC can work with a little current. But i stated 220, because it is the lowest limit that someone can use without damaging the PIC from over current if something goes bad, like short-circuiting the wires or pacing them at +5v.
To me it looks like X3-1, X3-2, X4-1, and X4-2 are not really used on the newest version of the doorlock. It looks like it ran two different LEDS in the earlier version. Is it OK to omit that part of the circuit or is it used for something else I am unaware of?
Next part is to clarify something for me. It looks like you soldered 6 wires to the keypad. Your schematic shows 7. Did you solder the VLED somewhere else on your pcb?
The last thing for today is while studying the photos I noticed a few differenced in resistor values. Example is the for you added to the keypad for protection look like they are 6k8. Yet on the schematics you have them down as 220. Which is correct?
Will probably ask more tomorrow. I have started ordering parts to get this going. Wish me luck and thanks for answering all my questions.
@shobdy correct, the leds goes to the emitter. They are all connected in parallel with a limiting resistor.
For the 7th pin: The keypad gets power NOT from the +4.5V on the board. Instead, the PIC on the controller provides power from one pin to the board outside, just to save more power. When the PIC on the controller goes to sleep, the PIC on the touchpad gets absolutely no power, so draws 0 current. But the pin cannot provide enough current for the leds, so i need more current therefore i have one extra line. That other line is the VLED.
About the relay: 15-2 and 16-1 are the SET and RESET, 9-12 is the Normal Open contact for the servo power.
SG1 is the buzzer. It is a simple 5V buzzer.
One more point: Notice in the close image of the touchpad: I have connect the ground wire to the "hatched area" of the PCB, this is something that you need to do as well. Also, i have connect the bottom side hatched area with the top-side hatched area together, so both areas around the keys are grounded.
Thanks for the answers; I have had some training on assembly language years ago and have been trying to brush up on it recently;
The LED's for lighting the keypad, in the schematic I am creating, are hooked to the emitter of the transistor you labeled as Q1 on the keypad schematic; this it correct? The 4 LEDs you used, were they in parellel or serial?
The 7 pin connector you have. Why is there a LED power on the 7th pin if it isn't hooked up on the other end? Can I do away with that and just make the connector a 6 pin also?
Why did you label the VLED seperate from the other power sources? It is 4.5 volts like the rest; couldn't I just tie it in with the others?
Another question I have is about the latching relay. I can't find the one you used so I am going to adapt one from ebay to do it. What I need to know is: on the doorlock schematic, pins 1 and 16 of the relay, are they the ones that enable the relay? pins 2 and 15 disable the relay? and pins 10 and 12 run the servo? or do the first 4 mentioned pins do something else?
SG1, it is just a piezo buzzer? anything you can tell me about it that will help me find a replacement?
I am sorry that I am hitting you with these question but I am trying to re-create your work with different parts and I am not sure of my modding skills yet.
Any and all answers are appreciated and welcomed as they further my knowledge.
@shobdy VLED is the voltage for the LED indeed. The transistor T1 (bc548) is a last minute add. The emitter of the transistor should have the LEDs (which are not shown in the schematic - my bad). The thing is that the LEDs along with the transistor and the resistor are NOT in my prototype, i soldered them directly on the air. SO you need to keep that in mind.
Also, as you may notice, the 2 connector which connect the controller with the keypad are not consient, one has 7 pins and the other 6. So be careful when you connect them. Do you know anything about PIC programming and assembly? That will help you.
C3 and C4 are 0.1 uF ceramic capacitor and D1 is 1N4007 diode or any 1A shottky barrier diode (better use a shottky diode).
I wanted to say that your project looks awesome. I would like to try and do it but I am having a bit of a time following your schematics. The keypad schematic wasn't bad except I am not sure what the to lead called "VLED" go to. Are they supposed to hooked to the LED's you lit your keypad with? I don't see LED's anywhere in your schematic. On the other schematic I see that there are a few parts that are not labeled. Examples are: C3, C4, D1, The transistor in the bottom left corner. Did you create a part's list? Sorry to hit you with all these questions. I am excited about trying to build this and don't want to screw it up!
hye i'm really interested with this project.can U tell & show me the detail about the programming that U use to to operate the PIC here.I'm really not know how to create the programming.And also can U show the detail of circuit layout?please....
Wow. This is awesome. The tech editor at Instructables.com, my boss, put my onto this project and I've got to thank both of you! This is brilliant.
We're actually running a contest right now that this project would qualify for, if you're up for putting the instructions onto Instructables.com. You could win a bus pirate (http://dangerousprototypes.com/docs/Bus_Pirate) and a hundred bucks just for joining and adding this to the contest. Could be cool.
Let me know if you're interested. This is exactly the kind of project that benefits from the step by step format of Instructables.
@Stefan i strongly suggest you use different capacitance channel for each button. Use 10 channels and not 5 as i did. The paired method does not work very good when a 4mm plexiglass is between the buttons. I look forward to see photos from your project. Good luck.
It is an optical scanner. The previous ones are two scanners from Authentec. I found them on devices I bought from ebay. The problem is that they don't have an integrated processor on board, so I have to write the software.
It should not be too hard, I found some linux users who wrote the application and they say it works, so perhaps I 'll try to migrate the code from the C linux environment to a ARM7 or ARM9. I am too lazy to build the board though.
No I don't have a blog or a site, I am too lazy for that, perhaps when I finish (it won't be until the next couple of months) I will give all the material to you and you can host it here if you like.
@Panagiotis there is no trick in hiding inside the door, nor you need any ingenious way to do it. I just happen to know exactly how these doors are made (i used to work in a factory that makes doors). And i know, that, if you keep things thin (under 20mm), you can put almost anything inside. That is why i kept the PCB and the batteries thin.
"i will have more serious problems to solve than this, namely the hurricane katrina that is right above my house :D"
Ha ha ha ha....Thank God Greece is safe from hurricanes!!!Well i'll be waiting news...Also i would like to thank you for your useful instructions about the servo because i didn't know that you can make these calculations to calculate the torgue!!!!!!! :-)
" i post detail documentation about my hacks, no tricks hidden ;) "
I didn't mean that you will hide something,but it will be a tricky-(smart) way the way you will put it in the door!!! :-)
Hi panagioti. Regarding the waking of the PIC, i have include already a case that the PIC will only wake if the pull switch is continuously activated for 250mSec, exactly for this reason (the wind). Moreover, the door has rubber sealing which act as spring and prevents it from hitting and making noise from the wind. Because of these two, if the PIC ever wakes due to air, i will have more serious problems to solve than this, namely the hurricane katrina that is right above my house :D
Regarding the servos, 1.6 Kg-cm is very good torque. But after making this hack, i began testing all the door locks to see how "hard" the spring is. What i've found is that there are keylocks with very hard spring, as well as others with very soft. Luckily, the one that my door had is somewhere in the middle, and the servo can easily pull it back. Here is your calculation: Your servo can pull 1.6 kilos with a lever of 1cm. But there is no need to use a whole cm as lever. I used about 6mm, so the servo can pull about 1.6 times more weight (1/0.6) which is 2.56 kilos, far enough to overcome any spring.
Regarding the video now, as always, i post detail documentation about my hacks, no tricks hidden ;)
When you finish it please post a video of how you placed it into the door... that is going to be a little tricky.Also i would like to mention you something about the wakening of the pic,(if you have\\\'t consider it yet).I think that you must find another way of wakening up the pic.Everytime that the wind blows you will have a wakening of the pic so i don\\\'t know if these contacts are the best solution to wake up the pic.
(for energy saving and only)
Yeasterday i bought a pack of 9g servo and in the description was saying that have 1,6kg/cm.Is this value ok to pull the \\\"tongue\\\" of the keylock?
yes Fung, there are like a million different uses for the inductors. As a matter of fact, you could somehow consider inductors like the opposite of capacitors. They are used in filters, smoothing applications, PWM power supplies and many more.
Regarding the buzzer, the limiting resistor is mainly to protect the transistor, as it is selected to operate in saturation. So, no matter how small you make it, you will see no difference. You could try to change the duty cycle of the signal, but i have never test it that deep.