Shop OBEX P1 Docs P2 Docs Learn Events
Alarm System Project Help — Parallax Forums

Alarm System Project Help

ArchiverArchiver Posts: 46,084
edited 2001-03-28 23:43 in General Discussion
My problem is that i have 6.15 volts going in to an I/O pin when the sensor
pin ejects while being detached from an item. The Stamp sees the change
sometimes and other times it doesnt. but when sensor1 is detached, then the
data for sensor 4 is display, and when sensor 8 is detached the info for
sensor 6 is displayed. I cant figure out what it is....was maybe thinking
that the 6.15 volts needs to be dropped to 5 volts. I am using the COUNT
command to read the port. is this code correct? Or shoudl I use a different
method to smaple the voltage on the line?

I get a completely different result when I test only the first sensor alone.
Everything seems to be ok. Im frustrated with this thing. :-}

Thanks.
So, here is my code...

LETTER VAR BYTE
SENS1 VAR BYTE
SENS2 VAR BYTE
SENS3 VAR BYTE
SENS4 VAR BYTE
SENS5 VAR BYTE
SENS6 VAR BYTE
SENS7 VAR BYTE
SENS8 VAR BYTE

IN CON 0
OUT CON 1
GREEN CON 8
RED CON 9
ALRM CON 10

DIR0=IN
DIR1=IN
DIR2=IN
DIR3=IN
DIR4=IN
DIR5=IN
DIR6=IN
DIR7=IN
DIR8=OUT
DIR9=OUT
DIR10=OUT
DIR11=OUT
DIR12=OUT
DIR13=OUT
DIR14=OUT
DIR15=OUT

TOP:
SEROUT 16, 84, 10, [noparse][[/noparse]"OK"]
GOSUB RECEIVE

IF (LETTER="G") THEN TEST1
GOTO ERROR

TEST1:
LOW ALRM
LOW RED
HIGH GREEN

COUNT 1, 5, SENS1
IF (SENS1=0) THEN TEST2
SEROUT 16, 84, 10, [noparse][[/noparse]"11111110"]
GOTO ALARM

TEST2:
COUNT 2, 5, SENS2
IF (SENS2=0) THEN TEST3
SEROUT 16, 84, 10, [noparse][[/noparse]"11111101"]
GOTO ALARM


TEST3:
COUNT 3, 5, SENS3
IF (SENS3=0) THEN TEST4
SEROUT 16, 84, 10, [noparse][[/noparse]"11111011"]
GOTO ALARM


TEST4:
COUNT 4, 5, SENS4
IF (SENS4=0) THEN TEST5
SEROUT 16, 84, 10, [noparse][[/noparse]"11110111"]
GOTO ALARM

TEST5:
COUNT 5, 5, SENS5
IF (SENS5=0) THEN TEST6
SEROUT 16, 84, 10, [noparse][[/noparse]"11101111"]
GOTO ALARM

TEST6:
COUNT 6, 5, SENS6
IF (SENS6=0) THEN TEST7
SEROUT 16, 84, 10, [noparse][[/noparse]"11011111"]
GOTO ALARM

TEST7:
COUNT 7, 5, SENS7
IF (SENS7=0) THEN TEST8
SEROUT 16, 84, 10, [noparse][[/noparse]"10111111"]
GOTO ALARM

TEST8:
COUNT 8, 5, SENS8
IF (SENS8=0) THEN TEST1
SEROUT 16, 84, 10, [noparse][[/noparse]"01111111"]
GOTO ALARM

RECEIVE:
SERIN 16, 84, 60000, RECEIVE, [noparse][[/noparse]LETTER]
RETURN

ALARM:
HIGH ALRM
LOW GREEN
HIGH RED
GOSUB RECEIVE

IF (LETTER="S") THEN STP
GOTO ERROR

STP:
LOW ALRM
GOTO STP

ERROR:
LOW GREEN
HIGH RED
GOTO TOP



Shop online without a credit card
http://www.rocketcash.com
RocketCash, a NetZero subsidiary

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-03-28 23:43
    If you want to read the state of a pin, COUNT isn't the proper command.

    Make the pin an input using the INPUT command and use "if then" logic to
    test the state. Check out the stamp manual....

    I'm not sure how the external circuitry is hooked up to the stamp, but a
    possible pitfall might be that when you expect the state to be '0' it is not
    GROUNDED (as it should be) and is actually floating. If its floating, you
    may get unexpected results (e.g. from parasitic capacitance on a
    breadboard).


    --Craig



    Original Message
    From: wtterrell [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=pzlRvxX05q6cVeM0fb8YziMlAtedKc7u7W1wOmvOai5W4ygiUjrLW7UgA1PS0Y9DIF6SvuXuQSuvaE_GYw]wtterrell@n...[/url
    Sent: Wednesday, March 28, 2001 9:30 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Alarm System Project Help


    My problem is that i have 6.15 volts going in to an I/O pin when the sensor
    pin ejects while being detached from an item. The Stamp sees the change
    sometimes and other times it doesnt. but when sensor1 is detached, then the
    data for sensor 4 is display, and when sensor 8 is detached the info for
    sensor 6 is displayed. I cant figure out what it is....was maybe thinking
    that the 6.15 volts needs to be dropped to 5 volts. I am using the COUNT
    command to read the port. is this code correct? Or shoudl I use a different
    method to smaple the voltage on the line?

    I get a completely different result when I test only the first sensor alone.
    Everything seems to be ok. Im frustrated with this thing. :-}

    Thanks.
    So, here is my code...

    LETTER VAR BYTE
    SENS1 VAR BYTE
    SENS2 VAR BYTE
    SENS3 VAR BYTE
    SENS4 VAR BYTE
    SENS5 VAR BYTE
    SENS6 VAR BYTE
    SENS7 VAR BYTE
    SENS8 VAR BYTE

    IN CON 0
    OUT CON 1
    GREEN CON 8
    RED CON 9
    ALRM CON 10

    DIR0=IN
    DIR1=IN
    DIR2=IN
    DIR3=IN
    DIR4=IN
    DIR5=IN
    DIR6=IN
    DIR7=IN
    DIR8=OUT
    DIR9=OUT
    DIR10=OUT
    DIR11=OUT
    DIR12=OUT
    DIR13=OUT
    DIR14=OUT
    DIR15=OUT

    TOP:
    SEROUT 16, 84, 10, [noparse][[/noparse]"OK"]
    GOSUB RECEIVE

    IF (LETTER="G") THEN TEST1
    GOTO ERROR

    TEST1:
    LOW ALRM
    LOW RED
    HIGH GREEN

    COUNT 1, 5, SENS1
    IF (SENS1=0) THEN TEST2
    SEROUT 16, 84, 10, [noparse][[/noparse]"11111110"]
    GOTO ALARM

    TEST2:
    COUNT 2, 5, SENS2
    IF (SENS2=0) THEN TEST3
    SEROUT 16, 84, 10, [noparse][[/noparse]"11111101"]
    GOTO ALARM


    TEST3:
    COUNT 3, 5, SENS3
    IF (SENS3=0) THEN TEST4
    SEROUT 16, 84, 10, [noparse][[/noparse]"11111011"]
    GOTO ALARM


    TEST4:
    COUNT 4, 5, SENS4
    IF (SENS4=0) THEN TEST5
    SEROUT 16, 84, 10, [noparse][[/noparse]"11110111"]
    GOTO ALARM

    TEST5:
    COUNT 5, 5, SENS5
    IF (SENS5=0) THEN TEST6
    SEROUT 16, 84, 10, [noparse][[/noparse]"11101111"]
    GOTO ALARM

    TEST6:
    COUNT 6, 5, SENS6
    IF (SENS6=0) THEN TEST7
    SEROUT 16, 84, 10, [noparse][[/noparse]"11011111"]
    GOTO ALARM

    TEST7:
    COUNT 7, 5, SENS7
    IF (SENS7=0) THEN TEST8
    SEROUT 16, 84, 10, [noparse][[/noparse]"10111111"]
    GOTO ALARM

    TEST8:
    COUNT 8, 5, SENS8
    IF (SENS8=0) THEN TEST1
    SEROUT 16, 84, 10, [noparse][[/noparse]"01111111"]
    GOTO ALARM

    RECEIVE:
    SERIN 16, 84, 60000, RECEIVE, [noparse][[/noparse]LETTER]
    RETURN

    ALARM:
    HIGH ALRM
    LOW GREEN
    HIGH RED
    GOSUB RECEIVE

    IF (LETTER="S") THEN STP
    GOTO ERROR

    STP:
    LOW ALRM
    GOTO STP

    ERROR:
    LOW GREEN
    HIGH RED
    GOTO TOP



    Shop online without a credit card
    http://www.rocketcash.com
    RocketCash, a NetZero subsidiary



    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sign In or Register to comment.