Searching \ for '[PIC] Single-button combination lock project' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Single-button combination lock project'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Single-button combination lock project'
1999\04\06@171459 by Maris

picon face
  I would like to make a PIC single-button "combination lock" for my
workshop door. This is not a high-security situation (the door is normally
unlocked), I just want to do it for fun and to learn something.
  The way the lock would work is that you would push the button in some
rhythm such as that of "shave and a haircut, two bits". This is only an
example, any rhythm could be used. This and only this would activate the
solenoid lock.
  One problem is that it would have to tolerate some human variation in
the rhythm, such as 5 or 10%.  It should reset immediately if a bad rhythm
is entered and it should time out if the rhythm is not completed. A
desirable added function would be if the lock could operate in a "learn"
mode where you would enter the rhythm manually with the push button and it
would learn it. Accompanying beeps or notes would be a plus.
  Any guidance, thoughts, directions or code snippets would be appreciated.

Thanks,
Maris

1999\04\06@221015 by Harold Hallikainen

picon face
       There is a similar single button combination lock in the Ideas For
Design of a recent EDN.  That was done entirely in hardware, however.
       This sounds like it'd ideally be a Morse Code receiver.  Just key in
your password to open the door.  This could also be a little like bar
code decoding in that we need to judge the width of a pulse in relation
to the width of other pulses in the stream.  Years and years ago I wrote
some 6800 code to save and load files from a tape drive called a "stringy
floppy."  On recording I sent a transition some time period after the
previous transition.  I think a 0 was one time period and a 1 was 2 time
periods.  I established a threshold that was sqrt(T0*T1) where T0 is the
time of a zero "pulse" and T1 was the time of a 1 "pulse" (pulses in
quotes since I timed between a positive edge and the succeeding negative
edge for one bit, and the negative and the next positive for the next
bit).  The duration of each zero and one bit were stored and used to
recalculate the threshold.
       So, in Morse code, a dah is three times the duration of a dit.  I'd
probably force the password to start with a dit so you can get an idea
the speed of the doorbell operator.  Then set a threshold based on this
duration and sort the dits and dahs to figure out the characters being
sent.  As they are being received, the threshold can be adjusted for
operators who speed up or slow down.


Harold



___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1999\04\07@014806 by w. v. ooijen / f. hanneman

picon face
I have made a few assignments for the children of the local "young
enginers" group.
One assignment culminates in such a one-button code lock.
The code is below. It is in JAL, my very own programming language.
The compiler is available for free, so you can translate it to 16x84
assembler or hex
(I'm working on SX support). see http://www.xs4all.nl/~wf/wouter/pic/jal
When you use another chip you can use it as starting point.

include 16c84_10
include jlib

pin_a0_direction = output
pin_a1_direction = input

procedure lees_code( byte out x ) is
  for 8 loop

     var byte n = 0
     while pin_a1 == high loop
        delay_1mS( 5 )
        n = n + 1
        if n == 255 then
           x = 0
           return
        end if
     end loop

     delay_1ms( 200 )
     x = x << 1
     if pin_a1 == low then
        x = x + 1
     end if

     while pin_a1 == low loop
     end loop

  end loop
end procedure

var byte code
forever loop
  pin_a0 = high
  if pin_a1 == low then
     lees_code( code )
     if code == 0b_0000_1111 then
        pin_a0 = low
        delay_1s( 5 )
     else
        delay_1s( 10 )
     end if
  end if
end loop

1999\04\07@091515 by Barry King

flavicon
face
I agree with Harold that a Morse-Code detector would be a desirable
way to do this, it makes it easyto remember a non-trivial rhythm.
There is actually lots of good code around to do this, on the various
Ham Radio web sites, since many folks have done Morse code
reciever/sender programs, you should be able to find something to
adapt.

My Dad and I did a home control system which is controlled via voice
output for prompts and data out (via PC based speech
synthesizer and several speakers in the house) and morse-code in (via
buttons near each thermostat).  All the buttons were just parallelled
for simplicity.

The algorithm is pretty simple, it assumes a dot length to start
with, and figures that any press shorter that twice the dot width is
a dot, anything longer than twice the dot width is a dash.  The first
version set the dot width every time a dot was recognized.  Later, we
switched to a running average of the last few dots.

Similarly, you have to recognize when a space between presses is long
enough that the sender means it to be the end of the symbol.  Ideally
is one dash-time (three dot times), but it has to adapt too.

In practice, we found that with the push button you could only
send slowly anyhow, and most of the commands were single morse
letters ("T" for temperature report, e.g.) so the timing was not too
critical, it worked OK.

Now where in the electronic landfill did I put that surplus
solenoid door strike?

-Barry.

------------
Barry King, KA1NLH
Engineering Manager
NRG Systems "Measuring the Wind's Energy"
Hinesburg, Vermont, USA
spam_OUTbarryTakeThisOuTspamnrgsystems.com
"The witty saying has been deleted due to limited EPROM space"

1999\04\07@143250 by Roland Andrag

flavicon
face
Maris,

I have been thinking of the same thing - in this case to enable the fuel
pump in my car - push button once, car will go 3 minutes and then not again
until you tap the correct code. Couple that with the fuel guage showing
empty and you my trick a thief (hijacker?) into thinking the tank is empty.
I have not gotten round to it yet (won't for a while), but I would suggest
that you first implement it on a PC using your favourite high level
language.  That should teach you the in's and out's.

I have done something similar on a PC to figure out the timing of music
(can't remember at the moment why I would have wanted to do that).
Basically, tap in the rythm, PC tells you 8th note, 16th note etc. I had
limited success, partly due to the variability involved.  A good start is
probably expressing the tap durations as fractions of the duration of the
longest tap in the sequence, and limiting yourself to two or three lengths
of taps (say whole, half and quarter notes).  That way the longest (or
first) tap acts as a reference. Better still, make the first tap a half
note, and use only whole and quarter notes in the rest of the sequence.
That way, you measure the first tap, and then just decide if the subsequent
taps are longer or shorter than the first one.  Might make for a strange
rythm though :-).

Come to think of it, the half note could be any note in the sequence, since
you can just wait for it and evaluate the sequence after it (the whole
sequence) is entered.  Other half notes in the sequence could just be
wildcards - their duration doesn't matter, as long as they are present.  Tap
duration should be measured from the beginning of the tap to the beginning
of the next tap, ie. including the spaces. Thus you could just look at
falling edges if your normally open switch leaves the pin input high. Also
debounce the switches etc.

For learn mode, you'd have to tap in the rythm and tell it which tap acts as
the reference (the pic could find a tap that has more or less half of the
other taps longer than itself, and half the taps shorter).  It would have to
decide which taps are wildcards (have the same duration as the reference
tap).  This sort of thing is a lot easier if you can do divides - fractions
close to one would indicate wildcards if you divided an arbitrary duration
by the 'reference' duration.

Have fun
Roland
{Original Message removed}

1999\04\07@144951 by Ron Fial

flavicon
face
Why not just use morse code?  Anybody could learn 2 or 3 letters, and morse code
decode with a PIC is not hard, you only have to deal with ratios, and assume th
e first press is a dot or a dash, because the lock 'knows' what letter to expect
first.

  di di di di   pause    di dit

Regards,
 Ron Fial

At 07:27 PM 4/7/99 +0200, you wrote:
>>   I would like to make a PIC single-button "combination lock" for my
>>workshop door. This is not a high-security situation (the door is normally
>>unlocked), I just want to do it for fun and to learn something.
>>   The way the lock would work is that you would push the button in some
>>rhythm such as that of "shave and a haircut, two bits". This is only an
>>example, any rhythm could be used. This and only this would activate the
>>solenoid lock.

1999\04\07@152507 by Roland Andrag

flavicon
face
>Why not just use morse code?  Anybody could learn 2 or 3 letters, and morse
code decode with a

Because then you couldn't hum your favourite tune to it...

Cheers
Roland

1999\04\07@205724 by Wagner Lipnharski

picon face
What you need is just program the PIC to measure the timming of the
first time the switch is pressed, set it as a default short time, as for
example code Time=1.  It doesn't need to be exactly "time", just a
counter counting loops while you hold the switch pressed.

The next switch pressings would represent another timmings that would be
divided by this first counter as reference, and so on.

For example:  If the first press, make the PIC counter to 20, the second
(you hold twice longer) would be 40 and the third (also twice longer)
would be again 40, your pressing button relation would be:
1st: 1  (20/20)
2nd: 2  (40/20)
3rd: 2  (40/20)

So your inputed code is  "122".

You can do it in any digits size and lengths, and also used to "program"
the unit.

The only tricky is that the first button press should be the shortest
one, to be used as a divisor for the rest...

Wagner.


Ron Fial wrote:
>
> Why not just use morse code?  Anybody could learn 2 or 3 letters, and morse co
de decode with a PIC is not hard, you only have to deal with ratios, and assume
the first press is a dot or a dash, because the lock 'knows' what letter to expe
ct first.
>
>    di di di di   pause    di dit

1999\04\07@210402 by Wagner Lipnharski

picon face
... sorry by the double post... I forgot to say that my previous message
and suggestion allows different speeds of input, since the PIC would
"lock" and use the first button press and the "reference", so different
persons could use it without any problem.  To allow a nice margin of
error, just use the rounding method before division.
Wagner

1999\04\08@102953 by Lawrence Lile

flavicon
face
You can get an electronic door strike for US$21.95 from
http://www.homecontrols.com   or 1-800-266-8765
I've been thinking along the same lines but the one button approach is
really intrigueing.


{Original Message removed}

1999\04\08@110159 by Wagner Lipnharski

picon face
It turns to be more interesting if you take a look at the Dallas iButton
technology at http://www.dalsemi.com/SiteMap/index.html or
http://www.ibutton.com/ using a single wire... used at car keys
(already), door openers and more... really interesting.

Lawrence Lile wrote:
> I've been thinking along the same lines but the one button approach is
> really intrigueing.

1999\04\08@114244 by Ralph Landry

flavicon
face
Another single button proximity detector that can work through wood,
glass, metal etc can be found at http://www.qprox.com and look for the QT110.
It looks like a very interesting 8 pin part that can be used for alot of
different apps.

-Ralph
.....rlandryKILLspamspam@spam@haywood.main.nc.us
"If they call it Tourist Season why can't we shoot 'em?"
ICQ# 19545315

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...