PDA

View Full Version : Relay control timer



Fklaas
02-19-2005, 04:40 AM
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

Newzed
02-19-2005, 05:09 AM
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 (http://hometown.aol.com/newzed/index.html)
и

Fklaas
02-19-2005, 05:12 AM
I tried that, Pause stops the whole program? and the timing is wrong

Newzed
02-19-2005, 05:12 AM
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 (http://hometown.aol.com/newzed/index.html)
и

Fklaas
02-19-2005, 05:16 AM
Relay is a LAA110 solid state relay, do I still need the uln2003a ?

Newzed
02-19-2005, 05:19 AM
You didn't say you were using SSR's. Forget what I said.

Paul Baker
02-19-2005, 05:22 AM
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

Fklaas
02-19-2005, 05:28 AM
---------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?

allanlane5
02-19-2005, 05:35 AM
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 Baker
02-19-2005, 05:38 AM
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 Baker
02-19-2005, 05:41 AM
thanks for the correction allan.

Fklaas
02-19-2005, 06:26 AM
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 Baker
02-19-2005, 06:29 AM
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.

Fklaas
02-19-2005, 06:31 AM
No Led's light at all..?

Paul Baker
02-19-2005, 06:32 AM
Look at prior post, you shouldnt assign the time delay to the pin, you toggle the led's value

Bruce Bates
02-19-2005, 06:58 AM
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 Baker
02-19-2005, 07:05 AM
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)

Fklaas
02-19-2005, 07:41 AM
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 Jong
02-19-2005, 07:47 AM
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 http://forums.parallax.com/images/smilies/smile.gif.

Klaus

Fklaas
02-19-2005, 08:12 AM
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

Fklaas
02-19-2005, 09:14 AM
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