Shop OBEX P1 Docs P2 Docs Learn Events
Relay control timer — Parallax Forums

Relay control timer

FklaasFklaas Posts: 15
edited 2005-02-19 01:14 in BASIC Stamp
I need to control some relays with timer A" solinoid runs for 2sec. B" solinoid runs for 1Sec. C" solinoid runs for 2 Sec. Like this

A,on
A,off

B,on---B,off

C,on
c,off

goto main;

would be really coool to add more with fully start and stop points!

Thanks, Frank

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-02-18 21:09
    Simple.

    A On····················· 'actually HIGH "PIN driving relay"
    PAUSE 2000
    A off

    B On
    PAUSE 2000
    B off

    and so on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester?

    http://hometown.aol.com/newzed/index.html
    ·
  • FklaasFklaas Posts: 15
    edited 2005-02-18 21:12
    I tried that, Pause stops the whole program? and the timing is wrong
  • NewzedNewzed Posts: 2,503
    edited 2005-02-18 21:12
    Remember, you can't drive a relay directly from the Stamp pins.· You drive a Darlington - ULN2003 or ULN2803 - which in turn drives the relay.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester?

    http://hometown.aol.com/newzed/index.html
    ·
  • FklaasFklaas Posts: 15
    edited 2005-02-18 21:16
    Relay is a LAA110 solid state relay, do I still need the uln2003a ?
  • NewzedNewzed Posts: 2,503
    edited 2005-02-18 21:19
    You didn't say you were using SSR's. Forget what I said.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 21:22
    not nessesarily, read the specs on the SSR and what the input drive current requirements are, I believe the stamps total output current is 80mA, so add all the pins current (3 times the LAA110 drive current + whatever else is connected) and this must be < 80ma.

    Is your timing diagram static or does the time of activation between different solenoids vary?

    Post Edited (Paul Baker) : 2/18/2005 9:26:25 PM GMT
  • FklaasFklaas Posts: 15
    edited 2005-02-18 21:28

    A,on
    A,off

    B,on---B,off

    C,on
    c,off
    Time
    >
    then start over

    Am using led's until I get program right. I need some kind of timer I think?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-02-18 21:35
    Actually, the BS2's output PER PIN is 20 mA, and PER CHIP is 50 mA MAX. The on-module regulator can provide out Vdd 80 mA MAX -- but you probably shouldn't count on it.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 21:38
    Not required,

    TSA_ON = time from start to A on
    TAB_ON = time from A on to B on
    TBB_OFF = time from B on to B off
    TBA_OFF = time from B off to A off
    TAC_ON = time from A off to C on
    TCC_OFF = time from C on to C off
    TCE_OFF = time from C off to end

    ILOOP:
    PAUSE TSA_ON
    A ON
    PAUSE TAB_ON
    B ON
    PAUSE TBB_OFF
    B OFF
    PAUSE TBA_OFF
    A OFF
    PAUSE TAC_ON
    C ON
    PAUSE TCC_OFF
    C OFF
    PAUSE TCE_OFF
    GOTO ILOOP
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 21:41
    thanks for the correction allan.
  • FklaasFklaas Posts: 15
    edited 2005-02-18 22:26
    Help fix this code please...



    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}


    TSA_ON CON 40 'time from start TO A ON
    TAB_ON CON 30 'time from A ON TO B ON
    TBB_OFF CON 40 'time from B ON TO B off
    TBA_OFF CON 60 'time from B off TO A off
    TAC_ON CON 60 'time from A off TO C ON
    TCC_OFF CON 80 'time from C ON TO C off
    TCE_OFF CON 80 'time from C off TO END

    A VAR OUT1
    B VAR OUT3
    C VAR OUT5


    ILOOP:
    PAUSE TSA_ON
    A = TSA_ON
    PAUSE TAB_ON
    B = TAB_ON
    PAUSE TBB_OFF
    B = TBB_OFF
    PAUSE TBA_OFF
    A = TBA_OFF
    PAUSE TAC_ON
    C =TAC_ON
    PAUSE TCC_OFF
    C = TCC_OFF
    PAUSE TCE_OFF
    GOTO ILOOP
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 22:29
    can you provide an explanation of what is not functionining correctly? Ok I think I understand, no you need to make a definition of what pin each solenoid is connected to, when you turn a solenoid on, you make that bit a 1, when you turn it off you make that bit 0.
  • FklaasFklaas Posts: 15
    edited 2005-02-18 22:31
    No Led's light at all..?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 22:32
    Look at prior post, you shouldnt assign the time delay to the pin, you toggle the led's value
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-02-18 22:58
    Frank -

    This is what you need to do in detail:

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    TSA_ON CON 40 'time from start TO A ON
    TAB_ON CON 30 'time from A ON TO B ON
    TBB_OFF CON 40 'time from B ON TO B off
    TBA_OFF CON 60 'time from B off TO A off
    TAC_ON CON 60 'time from A off TO C ON
    TCC_OFF CON 80 'time from C ON TO C off
    TCE_OFF CON 80 'time from C off TO END

    OUTPUT 1 : OUTPUT 3 : OUTPUT 5 'Set port 1, 3, 5 to output status
    A PIN 1 : B PIN 3 : C PIN 5 'Allocate names to pin ports

    ON CON 1 'Define HIGH state as a constant name
    OFF CON 0 'Define LOW state as a constant name

    ILOOP:

    PAUSE TSA_ON
    A = ON 'Set pin port 1 HIGH
    PAUSE TAB_ON
    B = ON 'Set pin port 3 HIGH
    PAUSE TBB_OFF
    B = OFF 'Set pin port 3 LOW
    PAUSE TBA_OFF
    A = OFF 'Set pin port 1 LOW
    PAUSE TAC_ON
    C = ON 'Set pin port 5 HIGH
    PAUSE TCC_OFF
    C = OFF 'Set pin port 6 LOW
    PAUSE TCE_OFF

    GO TO ILOOP 'Return to beginning

    END

    Regards,

    Bruce Bates
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-02-18 23:05
    Thanks bruce, my knowledge of PBASIC is theroretical (I last programmed in BASIC 15 years ago) so I'm not able to provide exact advice on syntax and usage (especially on IO). I think I'll leave neo's questions asking "how do I write X" to others (I can easily pseudocode for someone who already knows PBASIC and can translate the syntax)
  • FklaasFklaas Posts: 15
    edited 2005-02-18 23:41
    I get one error so far on line marked with ****** error is symbol is allready defined..?

    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    TSA_ON CON 40 'time from start TO A ON
    TAB_ON CON 30 'time from A ON TO B ON
    TBB_OFF CON 40 'time from B ON TO B off
    TBA_OFF CON 60 'time from B off TO A off
    TAC_ON CON 60 'time from A off TO C ON
    TCC_OFF CON 80 'time from C ON TO C off
    TCE_OFF CON 80 'time from C off TO END

    OUTPUT 1 : OUTPUT 3 : OUTPUT 5 'Set port 1, 3, 5 to output status
    A PIN 1 : B PIN 3 : C PIN 5 'Allocate names to pin ports

    ******ON CON 1 'Define HIGH state as a constant name
    OFF CON 0 'Define LOW state as a constant name

    ILOOP:

    PAUSE TSA_ON
    A = ON 'Set pin port 1 HIGH
    PAUSE TAB_ON
    B = ON 'Set pin port 3 HIGH
    PAUSE TBB_OFF
    B = OFF 'Set pin port 3 LOW
    PAUSE TBA_OFF
    A = OFF 'Set pin port 1 LOW
    PAUSE TAC_ON
    C = ON 'Set pin port 5 HIGH
    PAUSE TCC_OFF
    C = OFF 'Set pin port 6 LOW
    PAUSE TCE_OFF

    GO TO ILOOP 'Return to beginning

    END
  • K de JongK de Jong Posts: 154
    edited 2005-02-18 23:47
    Hi FKlaas,

    Did you put in the underscores in the codefragment below ??

    TAC_ON CON 60 'time from A off TO C ON
    TCC_OFF CON 80 'time from C ON TO C off

    If you did not you will get the reported error smile.gif.

    Klaus
  • FklaasFklaas Posts: 15
    edited 2005-02-19 00:12
    program is exactly as posted last without *'s I think the prob is pause as I have tried this for days and when pause starts in middle of program all out's go low ? But I am a Newb
  • FklaasFklaas Posts: 15
    edited 2005-02-19 01:14
    Got it working check out the Changes in code. Thank you guys for all your help Couldn't have done it with out you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    ' {$PORT COM3}

    TSA_ON CON 200 'time from start TO A ON
    TAB_ON CON 300 'time from A ON TO B ON
    TBB_OFF CON 400 'time from B ON TO B off
    TBA_OFF CON 600 'time from B off TO A off
    TAC_ON CON 600 'time from A off TO C ON
    TCC_OFF CON 800 'time from C ON TO C off
    TCE_OFF CON 900 'time from C off TO END


    DIR1 = %0 'fk make LED pin an output
    DIR3 = %0 'fk make LED pin an output
    DIR5 = %0 'fk make LED pin an output


    OUTPUT 1 : OUTPUT 3 : OUTPUT 5 'Set port 1, 3, 5 to output status
    A PIN 1 : B PIN 3 : C PIN 5 'Allocate names to pin ports



    'ON CON 1 'Define HIGH state as a constant name
    'OFF CON 0 'Define LOW state as a constant name

    ILOOP:

    PAUSE TSA_ON
    A = 1 'Set pin port 1 HIGH
    PAUSE TAB_ON
    B = 1 'Set pin port 3 HIGH
    PAUSE TBB_OFF
    B = 0 'Set pin port 3 LOW
    PAUSE TBA_OFF
    A = 0 'Set pin port 1 LOW
    PAUSE TAC_ON
    C = 1 'Set pin port 5 HIGH
    PAUSE TCC_OFF
    C = 0 'Set pin port 6 LOW
    PAUSE TCE_OFF

    GOTO ILOOP 'Return to beginning

    END
Sign In or Register to comment.