PDA

View Full Version : Electric Lock and Grab System Time (Help)



Goten
01-26-2006, 01:07 AM
·Hello,
······
···· I need some help with a system that i am developing,

1.-·I need to know that if it's posible to connect an electric or an electricmagnetic Lock to a BS2,·just on/off
2.- And If someone knows the code (algorithm) to grab the system time on Pbasic and Debug it.

As u see , the idea is to develop an access control.·http://forums.parallax.com/images/smilies/turn.gif

Best Regards
GoTeN

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Envio editado por (Goten) : 1/30/2006 2:27:10 AM GMT

Jon Williams
01-26-2006, 01:22 AM
Yes, you can control an electromagnet from the BASIC Stamp -- just don't connect it directly.· I've attached a schematic that shows a simple relay driver;·you should be able to adjust that circuit for your application.· And for more background, checkout this N&V article:

http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv6.pdf

The BASIC Stamp doesn't have "system time" like a PC; you'll need to connect an RTC (real time clock) chip for that.· There are several available, and we have code for them.· This thread gives a lot of detail about the popular DS1302:

http://forums.parallax.com/showthread.php?p=531080

And, finally, here's an article I wrote in N&V that shows how to create a digital lock program using a rotary encoder:

http://www.parallax.com/dl/docs/cols/nv/vol6/col/nv127.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-26-2006, 06:42 AM
Thanks for your answer Jon, but i was taking about the computer's system time, means that the basic stamp will be always connected to a pc.


and for the lock, i just need to know if it's posible to connect a 12V lock to a basic stamp, i know that i only can use 5V, but maybe some of you could have a diagram·of a·driver·or something. On parallax should have locks.


Best Regards
Goten

Jon Williams
01-26-2006, 06:49 AM
I misunderstood.· Question: If the BASIC Stamp is always connected to the PC, why don't you just make it a serial slave to the PC and let the PC handle all of the logic -- that Stamp can be there to handle your hard I/O.

On our RS-232 AppMod page we have a VB project attached those shows how you can connect the BASIC Stamp to a PC application.· It's not using the programming port, but that change is pretty easy to make if that's what you want to use.

http://www.parallax.com/detail.asp?product_id=29120

You cannot connect a 12-volt device directly; you'll need an interface -- like the one I've attached (sorry,·forgot to attach to my original post).· The schematic shows a relay; that's where you would connect your lock (spec that transistor to handle device's current properly).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-26-2006, 08:39 PM
So a Relay it's better than aTransistor for this.

thanx

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Chris Savage
01-26-2006, 11:21 PM
There are many possible solutions.· You could use a MOSFET or even a DC SSR.· If you have a transistor rated for driving the lock then it may work fine.· You will still need a clamping diode for·back EMF from an inductive load.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Goten
01-27-2006, 11:06 PM
Finally i decide to do the interface (attached).
But i have some doubt, for example how to connect the led A or B (second image)
and if the Relay it's ok (third image), i have 5 pins and i really don't know too much about, electronic... yes·neither electricity·nor informatic... but i'm learning...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Chris Savage
01-27-2006, 11:12 PM
That is not an LED, but rather a standard Diode.· If you see light from this you may have a problem.· =)· The black band represents the Cathode, which on the schematic is the side with the line, not the triangle.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Microman171
01-28-2006, 03:26 AM
mabey goten drew that themself and just forgot the symbol?? So mabey the symbol is a standard diode but is really a LED drawn wrong??

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = Window

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
0............................................0
0............................................0
0.(Microman171@hotmail.com)..0
0............................................0
0............................................0
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Goten
01-28-2006, 03:49 AM
in fact savage was right.



Another question, that's the correct order to connect a Transistor? Image attached



thanx for your help...


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Envio editado por (Goten) : 1/27/2006 8:54:07 PM GMT

Jon Williams
01-28-2006, 09:00 AM
Nope, I don't think that's correct -- at least based on the tech sheet at this link:

http://www.fairchildsemi.com/ds/MM%2FMMBT2222A.pdf

... if I'm reading the pinout correctly, your outer pins are reversed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-30-2006, 03:19 AM
well, Thanks to your help I am closely·to finish the project.

But something is not working....

Please give me a last hand.

an image is attached.. please check it... something must be worng.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Jon Williams
01-30-2006, 03:39 AM
Yes, something is wrong, but I'm not sure how to tell from your graphic. One thing you need is a common ground between the 12-volt system and the BOE if you're going to use the transistor to switch the relay.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Bean
01-30-2006, 03:43 AM
Jon,
On the drawing it says that the relay is 5V. I think he is only using the 12V for the magnetic lock.

The problem I see is that he doesn't have +5V going to the relay coil. I assume it would go to the upper right connection on his drawing. Hmmm, but then the diode would be in backwords...

Bean.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95

http://www.parallax.com/detail.asp?product_id=30012

"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015

Product web site: www.sxvm.com (http://www.sxvm.com)

"Ability may get you to the top, but it takes character to keep you there."
·

Jon Williams
01-30-2006, 04:07 AM
Goten,

Since you're using a 5v relay I've whipped up a quick schematic for you.· How much current does your relay require to activate?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-30-2006, 10:26 AM
it's supposed that the Basic could pulse out 5V, then the transistor amplify, after that the relay act like a switch, but i don't know·where to·connect the transistor, which its the correct pin of the relay, where· i have to connect the diodo, the idea of the diodo it's to unload the circuit after it works.

The circuit idea is afetr the a sensor works, it open the lock. my problem is that the lock works with 12V, and i only could have 5 from the Basic.


It's possible to connect just a Transistor between the basic and the lock?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Jon Williams
01-30-2006, 10:53 AM
A transistor does not magically convert 5 volts to 12 volts, you need to have the 12 volts available in your system.· I've redrawn an earlier schematic to show you how to connect your solenoid directly to the transistor -- this is the easiest and cleanest implemention.· Note that you have to connect ground of the 12-volt supply to ground (Vss) of the BASIC Stamp for this to work.

Also, you might want to read this article: http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv6.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-30-2006, 11:30 AM
Thanx for your help.

The Solenoid of the schematic it is the lock.

but where should i put the diodo, between + and - of the lock?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Jon Williams
01-30-2006, 11:41 AM
Assuming your lock is solenoid activated, YES, and you must make sure the polarity is correct. When power is removed from inductive devices, the collapsing field around the coil induces a current that can harm things; the diode is there to protect your circuit.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-30-2006, 10:24 PM
i read the article nv6, and try the follow algorithm:


loop:
· low 7······ ' Pin 7 low to latch door
' (relay open)
· serin 0,N2400,("OK")·· ' Watch serial input
' until "OK" rec'd.
· high 7······ ' Pin 7 high to unlatch do
' (relay closed).
· pause 5000······ ' Wait 5 seconds.
goto loop······ ' Latch door and resume
' watching serial input.


but i have problems using "N2400" it's an undefined symbol. i'm using a bs2



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Bruce Bates
01-30-2006, 11:04 PM
Goten -

There are a number of problems with your program. As far as the undefined symbol is concerned, you neglected to put the following coding in your program, which defines that symbol using conditional compilation, depending on the type of Stamp you are using:

/code

#SELECT $STAMP
#CASE BS2, BS2E
T2400 CON 396 ' reader baud rate
TmAdj CON $100 ' x 1.0 (time adjust)
FrAdj CON $100 ' x 1.0 (freq adjust)
#CASE BS2SX
T2400 CON 1021
TmAdj CON $280 ' x 2.5
FrAdj CON $066 ' x 0.4
#CASE BS2P
T2400 CON 1021
TmAdj CON $3C5 ' x 3.77
FrAdj CON $044 ' x 0.265
#CASE BS2PE
T2400 CON 396
TmAdj CON $100 ' x 1.0
FrAdj CON $0AA ' x 0.665
#ENDSELECT

code/

Second, you can't read into a constant, as you have done here (below), and I suspect this is supposed to be a WAIT parameter, in any case:

serin 0,N2400,("OK") ' Watch serial input

It should probably have read as follows, if you are hoping to WAIT for an OK to be transmitted:

SERIN 0, N2400, (WAIT "OK")

The next problem that you have is that after a period of time when "OK" has not been seen, the SERIN statement will time out, and you've made no provision for that. I would suggest you read about the SERIN command in the PBASIC Stamp Manual, or from the PBASIC Help File before you go much further in this hit and miss process. It's really quite simple, if you take a few moments to read and understand it, honestly.

Regards,

Bruce Bates

Post Edited (Bruce Bates) : 1/30/2006 3:20:57 PM GMT

Jon Williams
01-30-2006, 11:35 PM
The problem is that you're trying to use BS1 code in a BS2 program.· You might want to slow down a bit and give our "What's A Microcontroller?" text a read -- it will help you get the BS2 fundamentals down pat.· Also, we don't recommend using the word "Loop" as a label since it is a keyword in PBASIC 2.5.


Goten said...
i read the article nv6, and try the follow algorithm:


loop:
· low 7······ ' Pin 7 low to latch door
' (relay open)
· serin 0,N2400,("OK")·· ' Watch serial input
' until "OK" rec'd.
· high 7······ ' Pin 7 high to unlatch do
' (relay closed).
· pause 5000······ ' Wait 5 seconds.
goto loop······ ' Latch door and resume
' watching serial input.


but i have problems using "N2400" it's an undefined symbol. i'm using a bs2



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Goten
01-31-2006, 02:15 AM
well i just want to use the circuit.. i guess i only a "high" or "low" for that, tell me if i'm wrong.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten

Goten
02-03-2006, 05:41 AM
IT· WOOORKS!!! IT WOOORKSs!
tomorrow i'll post somepicutresS!!!! tyhanx to everybody!!!
thanx Parallax!!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile

Goten