multiple inputs
Hi,
I need to create a simple circuit that can receive 6 inputs and for each one, light a load for a number of seconds and turn off.
Doing this in a linear fashion is simple. But I don't know how to keep listening to the other buttons while one is executing the "turn load on - wait - turn load off" sequence.
All inputs are controlled by one stamp but the displays are not related and need to be readily reactive unless the light is on.
Is there a listener object that can constantly monitor the inputs regardless if a load is on or not?
Can anybody suggest a way to program this?
Appreciate any help I can get.
Thanks.
SY.
I need to create a simple circuit that can receive 6 inputs and for each one, light a load for a number of seconds and turn off.
Doing this in a linear fashion is simple. But I don't know how to keep listening to the other buttons while one is executing the "turn load on - wait - turn load off" sequence.
All inputs are controlled by one stamp but the displays are not related and need to be readily reactive unless the light is on.
Is there a listener object that can constantly monitor the inputs regardless if a load is on or not?
Can anybody suggest a way to program this?
Appreciate any help I can get.
Thanks.
SY.
Comments
I think the "inPins(i)" thing will work. I don't have a current PBasic manual handy to make sure.
·
Use a real time clock. Buy and install an RTC
·
‘ Declare variables.
T1
T2
T3
T4
T5
T6
Declare I/O
6 inputs
6 outputs
·
·
Main:
·
Switch 1:
If input 1 is not active THEN Switch2
Else read and store the RTC to switch 1s timer to variable T1····‘(This portion is skipped if the·associated input is not active)································
Activate associated output····························································· ‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light1······························································· ‘(This portion is skipped if the·associated input is not active)
·
Switch 2:
If input 2 is not active THEN Switch3
Else read and store the RTC to switch 2s timer variable T2······· ‘(This portion is skipped if the·associated input is not active)·································
Activate associated output······························································‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light2································································‘(This portion is skipped if the·associated input is not active)
·
Switch 3:
If input 3 is not active THEN Switch4
Else read and store the RTC to switch 3s timer variable T3········ ‘(This portion is skipped if the·associated input is not active)································
Activate associated output····························································· ‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light3······························································· ‘(This portion is skipped if the·associated input is not active)
·
Switch 4:
If input 4 is not active THEN Switch5
Else read and store the RTC to switch 4s timer variable T4·········‘(This portion is skipped if the·associated input is not active)································
Activate associated output····························································· ‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light4······························································· ‘(This portion is skipped if the·associated input is not active)
·
Switch 5:
If input 5 is not active THEN Switch6
Else read and store the RTC to switch 5s timer variable T5·········‘(This portion is skipped if the·associated input is not active)································
Activate associated output······························································ ‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light5································································ ‘(This portion is skipped if the·associated input is not active)
·
Switch 6:
If input 6 is not active THEN Main
Else read and store the RTC to switch 6s timer variable T6··········‘(This portion is skipped if the·associated input is not active)·······························
Activate associated output······························································· ‘(This portion is skipped if the·associated input is not active)
GOSUB subroutine Light1································································· ‘(This portion is skipped if the·associated input is not active)
·
GOTO Main
·
Light1:
IF T1 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Light2:
IF T2 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Light3:
IF T3 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Light4:
IF T4 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Light5:
IF T5 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Light6:
IF T6 + (desired on time delay) <= current RTC reading THEN de-activate associated output ·
Return
·
Note that successive inputs prior to the “timer” expiring will re-initiate the timer.
Using this method will allow the inputs to be independent of each other.
Look at the RTC documentation for the proper method of reading the RTC and size requirements for the variable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
(Frequently heard from other's)
Tommy, I know it wasn't designed to·x, but can you make it·do x·anyway?
·
I have been attempting to program Mike's code but its seems to get stuck on the first for..loop rather than go through the rest of the commands. I'm a·beginner programmer in basic so I keep getting errors such as "expects ":" or end of line" when·I keep the "i" after the NEXT. According to the manual·NEXT incerments my value and returns to the top of the loop, which explains why it gets stuck on the first loop. How can I continue to excute the code rather than go back to the top? the first thing that comes to mind is a·different·sub,·am·I right?
Also tried using count like the example - count var byte[noparse][[/noparse]maxInp] - but got errors as well.
I'm using the BS2 (if it makes a difference in the code).
Hope you can help.
Thanks.
SY
Mike is in 'Propellerland" - and doing some amazing things, I might add! No negative implication at all - it's all good!
Here is the code in "STAMP PBasic" - it should help you get going
Post Edited (Paul Sr.) : 11/17/2006 5:37:55 PM GMT
Sy
There are ways to make the time for the code more exactly predictable, and ways using external clock to sychronize to clock time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Its working!
Very grateful.
Sharon (SY).