IonescuA
May 30 2009, 2:13 PM
Can anyone show me how to design a system that has 3 components : 1. a door bell , 2. a button to open up the door , 3. an electrically controlled lock
The point is to make the system that operates a door , when the door bell is rang u can choose to push the button and open the lock. Must be written in Keil C.
Any suggestions, solution or pointers are much appreciated.
Thanks in advance.
The point is to make the system that operates a door , when the door bell is rang u can choose to push the button and open the lock. Must be written in Keil C.
Any suggestions, solution or pointers are much appreciated.
Thanks in advance.
rearthur2003
May 30 2009, 6:18 PM
is it opening and closing or what
IonescuA
May 30 2009, 7:14 PM
yes the button opens the door (basically operates the lock to open) , u have to close the door manually 

ExperimenterUK
May 31 2009, 12:54 PM
Can you explain why you need to use a microcontroller.
You could just wire the lock to the button.
You could just wire the lock to the button.
IonescuA
May 31 2009, 1:18 PM
It is more or less a didactic example , so i can understand the basics for a more complicated project. And i need to figure out how to create simulation in Proteus Isis for it . Maybe think about it as if it were a basic package where u can add more options later like an alarm, different ringtones for the bell or a fingerprint scanner to open the door etc.
Just the very basic would help me a lot to understand right now .
Thanks for the interest again and waiting for a reply.
Just the very basic would help me a lot to understand right now .
Thanks for the interest again and waiting for a reply.
ExperimenterUK
May 31 2009, 3:51 PM
Connect the button to an input pin of your micro.
Add a pull up resistor(1K) to keep the pin HIGH until the button connects it to ground.
Use a transistor or purpose made driver chip such as the ULN2003 to switch
your door latch.
Door latches are basically relays,so follow any advice given here for switching relays.
IE check that the current is not too high for the driver, and always fit a diode
across the coil.
Connect your driver (transistor or ULN2003) to an output pin of your micro.
Most pins on a micro can be made input or output. (read the data sheet).
It's simplest for now to make all pins on one port IN and all on one port OUT.
Write a very simple program that goes in a loop.
StartLoop:
Read the IN port..
IF the button pin is low (button pressed), set the relay pin of the OUT port high... (open the door).
IF not (ELSE) set the OUT pin low (door locked)
Jump back to StartLoop
Add a pull up resistor(1K) to keep the pin HIGH until the button connects it to ground.
Use a transistor or purpose made driver chip such as the ULN2003 to switch
your door latch.
Door latches are basically relays,so follow any advice given here for switching relays.
IE check that the current is not too high for the driver, and always fit a diode
across the coil.
Connect your driver (transistor or ULN2003) to an output pin of your micro.
Most pins on a micro can be made input or output. (read the data sheet).
It's simplest for now to make all pins on one port IN and all on one port OUT.
Write a very simple program that goes in a loop.
StartLoop:
Read the IN port..
IF the button pin is low (button pressed), set the relay pin of the OUT port high... (open the door).
IF not (ELSE) set the OUT pin low (door locked)
Jump back to StartLoop
IonescuA
Jun 2 2009, 4:17 AM
Thanks a lot ExperimenterUK , i am trying to implement it right now , I really apreciate your help .
I was thinking of a way to make things more interesting , like considering that the door has a spring to keep it locked , I could add a sensor to detect whether the door is closed or being help open , and only when it is closed to automaticly close the door latch.
To this end I was thinking of a timer of something like 5 secs in witch the latch is kept open prior to the button being pressed , giving the person outside a limited time to open the door.
After the person sitting outside the door , opens the door , the system will wait for the sensor to indicate that the door is closed before closing the latch again. Was also trying to think of a smart way to connect the door bell but nothing comes to mind thus far.
So looking forward to seeing your suggestions or possible solutions. Thanks again and waiting on your answers.
I was thinking of a way to make things more interesting , like considering that the door has a spring to keep it locked , I could add a sensor to detect whether the door is closed or being help open , and only when it is closed to automaticly close the door latch.
To this end I was thinking of a timer of something like 5 secs in witch the latch is kept open prior to the button being pressed , giving the person outside a limited time to open the door.
After the person sitting outside the door , opens the door , the system will wait for the sensor to indicate that the door is closed before closing the latch again. Was also trying to think of a smart way to connect the door bell but nothing comes to mind thus far.
So looking forward to seeing your suggestions or possible solutions. Thanks again and waiting on your answers.
Ajay
Jun 2 2009, 6:48 AM
You might have came across the doors with magnetic locks.. did you?
they are same as you are trying to make. there is an access system outside and inside the door. outside normally a swipe card or keypad to for code and inside a switch to open the door. door is locked using a high power magnet, magnet deactivates if correct code is entered or if the door open switch is pressed from inside the room. and after the door is closed magnet activates again.
So in your case, are you trying to have any access system or just a simple door open switch on both sides (inside and outside)? you can make use of IR sensors to detect the position of door (close or open).
so pseudo code will be something like this..
button pressed.
open door..
wait for door open or 5 sec timeout..
if 5 sec timeout first then close the latch again, or if door is opened, wait for door close and then active the latch.
they are same as you are trying to make. there is an access system outside and inside the door. outside normally a swipe card or keypad to for code and inside a switch to open the door. door is locked using a high power magnet, magnet deactivates if correct code is entered or if the door open switch is pressed from inside the room. and after the door is closed magnet activates again.
So in your case, are you trying to have any access system or just a simple door open switch on both sides (inside and outside)? you can make use of IR sensors to detect the position of door (close or open).
so pseudo code will be something like this..
button pressed.
open door..
wait for door open or 5 sec timeout..
if 5 sec timeout first then close the latch again, or if door is opened, wait for door close and then active the latch.
IonescuA
Jun 3 2009, 2:03 PM
Thanks Ajay , magnetic locks seem perfect for what I had in mind.
However i am still new with working in this environments and I am working a bit slow having limited time to dedicate to this .So i am having some problems with making the relay activate as I want it to and also I am sometimes getting a warning that the CPU is too highly solicitated , will post what i have done so far , so you can give me some hints
I uploaded it all here
and btw could i introduce a motor to close and open the door in the simulations in ISIS ?
However i am still new with working in this environments and I am working a bit slow having limited time to dedicate to this .So i am having some problems with making the relay activate as I want it to and also I am sometimes getting a warning that the CPU is too highly solicitated , will post what i have done so far , so you can give me some hints
I uploaded it all here
and btw could i introduce a motor to close and open the door in the simulations in ISIS ?
DavesGarage
Jun 3 2009, 2:34 PM
A word of constructive criticism:
Try and add comments to your software, so it is easier to understand, not only for yourself, but for others that have to read it later...
Here is an annotated version of your code:
Hope this helps,
Try and add comments to your software, so it is easier to understand, not only for yourself, but for others that have to read it later...
Here is an annotated version of your code:
CODE:
#include <reg52.h>
// bit definitions...
sbit button1 = P1^0;
sbit button2 = P1^2;
sbit releu = P1^1;
sbit sonerie = P1^3;
// function prototypes...
void wait (const unsigned int DELAY);
// -----------------------------------------
// function: wait()
//
// parameters:
// DELAY - time in milliseconds to delay
// -----------------------------------------
void wait( const unsigned int DELAY )
{
unsigned int x, y;
for (x = 0; x <= DELAY; x++)
{
for (y = 0; y <= 120; y++);
}
}
// -----------------------------------------
// function: main()
//
// parameters:
// none
// -----------------------------------------
void main( void )
{
/* repeat forever... */
while(1)
{
/* check button1... */
if (button1 == 1)
{
/* activate relay... */
releu = 1;
wait(1000);
}
else
{
/* deactivate relay... */
releu = 0;
}
/* check button2... */
if (button2 == 1)
{
/* activate alarm... */
sonerie = 1;
}
else
{
/* deactivate alarm... */
sonerie = 0;
}
}
}
// bit definitions...
sbit button1 = P1^0;
sbit button2 = P1^2;
sbit releu = P1^1;
sbit sonerie = P1^3;
// function prototypes...
void wait (const unsigned int DELAY);
// -----------------------------------------
// function: wait()
//
// parameters:
// DELAY - time in milliseconds to delay
// -----------------------------------------
void wait( const unsigned int DELAY )
{
unsigned int x, y;
for (x = 0; x <= DELAY; x++)
{
for (y = 0; y <= 120; y++);
}
}
// -----------------------------------------
// function: main()
//
// parameters:
// none
// -----------------------------------------
void main( void )
{
/* repeat forever... */
while(1)
{
/* check button1... */
if (button1 == 1)
{
/* activate relay... */
releu = 1;
wait(1000);
}
else
{
/* deactivate relay... */
releu = 0;
}
/* check button2... */
if (button2 == 1)
{
/* activate alarm... */
sonerie = 1;
}
else
{
/* deactivate alarm... */
sonerie = 0;
}
}
}
Hope this helps,
IonescuA
Jun 3 2009, 2:45 PM
yea , sorry for the sloppy code writing
and thx Dave
Was actually in a hurry to see what u have to say about the ISIS simulation and how to manipulate the relay better (not sure I am activating it at all at this point).
Posting a pic to catch your attention

large here
and thx DaveWas actually in a hurry to see what u have to say about the ISIS simulation and how to manipulate the relay better (not sure I am activating it at all at this point).
Posting a pic to catch your attention

large here
DavesGarage
Jun 4 2009, 1:19 PM
Ah, I may have found your problem. Look closely at your relay. The driver IC (U2) is connected to the COMMON input to the relay. How is the relay actuated?
Perhaps if you connected the driver IC to the COIL(-) in the relay, and connected the other side of the coil to VCC, your relay would actuate?
Also, note that the ANODE side of your DIODE is connected to the COIL(-) side of the relay, and the CATHODE side of your DIODE is connected to the COIL(+) side of the relay. This DIODE is referred to as a SNUBBER DIODE, which means that it will "snub" (or remove) the large stored charge in the coil when it is released. Sometimes, this is referred to as "back EMF", and can be hazardous to your circuitry. A very good idea to have this DIODE in place.
Now, when you actuate the relay, not much will happen, because you have nothing connected to the COMMON pole, nor do you have anything connected to the NORMALLY-OPEN pole... so connect a voltage source to the COMMON pole, and connect your latch release to the NORMALLY-OPEN pole. Make sure to connect the other side of your latch to the common for your voltage source, whatever that might be.
Now when you activate your output from your micro controller, the driver should actuate the relay, and your door latch should move...
One final note: The relay may not be necessary, if the latch current is not too high. What I mean is that U2 may be able to drive your latch by itself... Double check the requirements for your latch, and see how much current it takes to work...
Hope this helps,
Perhaps if you connected the driver IC to the COIL(-) in the relay, and connected the other side of the coil to VCC, your relay would actuate?
Also, note that the ANODE side of your DIODE is connected to the COIL(-) side of the relay, and the CATHODE side of your DIODE is connected to the COIL(+) side of the relay. This DIODE is referred to as a SNUBBER DIODE, which means that it will "snub" (or remove) the large stored charge in the coil when it is released. Sometimes, this is referred to as "back EMF", and can be hazardous to your circuitry. A very good idea to have this DIODE in place.
Now, when you actuate the relay, not much will happen, because you have nothing connected to the COMMON pole, nor do you have anything connected to the NORMALLY-OPEN pole... so connect a voltage source to the COMMON pole, and connect your latch release to the NORMALLY-OPEN pole. Make sure to connect the other side of your latch to the common for your voltage source, whatever that might be.
Now when you activate your output from your micro controller, the driver should actuate the relay, and your door latch should move...
One final note: The relay may not be necessary, if the latch current is not too high. What I mean is that U2 may be able to drive your latch by itself... Double check the requirements for your latch, and see how much current it takes to work...
Hope this helps,