Entire Forum This board This topic Members Entire Site
 Pages: [1]
 Author Topic: Automated Staircase led lights with 16f 628a  (Read 2548 times) 0 Members and 1 Guest are viewing this topic.
setiorion007
Newbie

Offline

Posts: 19

Thank You
-Given: 8

 « on: February 24, 2012, 02:55:13 02:55 »

Hello guys

I am learning Proton pic-basic & have found it very difficult on how to  make a automated staircase led lights with 16f628a

I have found a video on youtube but i don`t know how to implement the functions on the 16f628a

here is the link for the video

http://youtu.be/uGqE6fnI8I0

I would appreciate if any one could help me with an idea on how to implement ( code sample would help)

 Logged
jeanninemtv
Senior Member

Offline

Posts: 315

Thank You
-Given: 57

 « Reply #1 on: February 24, 2012, 03:50:14 03:50 »

what about create a finite state machine?  a loop with all the states and each condition that trigger that state ...

something like this (i'm little busy but i think that can give you a little idea)
( but do your fsm scheme first to get all the possible cases and transitions ... )

Device 16F648A
Xtal 20
TRISA = \$03
TRISB = \$00

Symbol sensor1 TRISA.0
Symbol sensor2 TRISA.1

Dim ep As Byte ; etat present
Dim ea As Byte ; etat anterieur

state_on_reset:

ep=0
ea=0

PORTB=0
PORTA=3

state0:

PORTB=0

ep=0
ea=0
loop:

If sensor1=0 Then
ep=1
ea=0
Else
GoTo cycle
EndIf

If ep=1 Then
ep=2
ea=1
PORTB=1
GoTo cycle
EndIf

If ep=2 Then
ep=3
ea=2
PORTB=3
GoTo cycle
EndIf

cycle:

DelayMS 100

GoTo loop
 « Last Edit: February 24, 2012, 04:08:03 04:08 by jeanninemtv » Logged
setiorion007
Newbie

Offline

Posts: 19

Thank You
-Given: 8

 « Reply #2 on: February 24, 2012, 09:41:35 21:41 »

Thank you for the code

I will have to learn how to do finite state machine

i will make use of your code & try  building it next week

If u have some more ideas i would appreciate that
 Logged
jeanninemtv
Senior Member

Offline

Posts: 315

Thank You
-Given: 57

 « Reply #3 on: February 25, 2012, 09:45:08 09:45 »

mmm as i can see, your system dont need so much nanoseconds precision, so you can use the internal 628/648 crystal.

btw are you simulating this on isis???
 Logged
thetrueman
Junior Member

Offline

Posts: 69

Thank You
-Given: 24

 « Reply #4 on: March 03, 2012, 10:49:26 10:49 »

Hi, I saw youtube video, but there is one flaw as, if we see video, there is one man comes from right and one from left. Now the sensors has counted two persons.

But if both got out parallel in front of any sensor then sensor will assume only one person has been out and still one person is on the stairs and controller will wait to switch off lights untill person counting is zero but there is no person available. Is it right flaw? Thanks.
 Logged
jeanninemtv
Senior Member

Offline

Posts: 315

Thank You
-Given: 57

 « Reply #5 on: March 17, 2012, 11:24:47 11:24 »

if both got parallel ... then both inputs activatet and the system will illuminate all the lights ^^ :p   kinda silly solution ..
 Logged
Elmer
Junior Member

Offline

Posts: 43

Thank You
-Given: 13

 « Reply #6 on: March 17, 2012, 01:04:33 13:04 »

I'd consider using PIR sensors covering the stairway (you get modules at many online electronics stores). Counting people in/out just doesn't seem like a very good idea, as previously pointed out by others.
 Logged

peace in the valley
thetrueman
Junior Member

Offline

Posts: 69

Thank You
-Given: 24

 « Reply #7 on: March 17, 2012, 01:54:11 13:54 »

if both got parallel ... then both inputs activatet and the system will illuminate all the lights ^^ :p   kinda silly solution ..

I mean not sensors in parallel. I was meant that if both persons got out side by side at once from any one side then sensor will count one person but actually two person has been out. So there is flaw in system...
 Logged
Elmer
Junior Member

Offline

Posts: 43

Thank You
-Given: 13

 « Reply #8 on: March 18, 2012, 04:11:25 04:11 »

So there is flaw in system
Flaw is trying to count that way in the first place. Use PIR sensor(s) for detecting those people, same as your burglary-alarm does. It's mass produced so it's cheap too
 Logged

peace in the valley
CocaCola
Senior Member

Offline

Posts: 447

Thank You
-Given: 128