Input Question
staffshome
Posts: 28
Hello all,
use code below in my program.
IF modein = 1 THEN····························· 'latched switch, resets to 1 on power up
GOSUB Economy
ELSE
GOSUB Sport
ENDIF
I look at this input repeatedly & only want action on change of state,is there a way to do this.
thought maybe get scratchpad byte & current status but not sure how to do it
regards Adrian
·
use code below in my program.
IF modein = 1 THEN····························· 'latched switch, resets to 1 on power up
GOSUB Economy
ELSE
GOSUB Sport
ENDIF
I look at this input repeatedly & only want action on change of state,is there a way to do this.
thought maybe get scratchpad byte & current status but not sure how to do it
regards Adrian
·
Comments
The logic statements involving XOR=^ and AND=& detect the change of state.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks for your reply,will giveit a go in my prog
Regards Adrian
tried your code & appears to work same as my original ??.
I could be i didn't explain what i need correctly.
my program runs the code shown as part of a main loop & each time it loops back if for example:·modein =1
it runs the sub routine if the next time loop runs if modein unchanged sub runs again (each sub drives·same digi-pot·with with different ramping rates so if sub repeats endlessly the solenoid driven from the pot cycles & this is showing up as a pressure pulse in solenoid hydraulic circuit. So really need sub not to run again until modein changes state.
How that is a bit clearer.
regards Adrian
modein1 = modein ' initialize prior state
is NOT part of your main loop. On the other hand the update statement,
modein1 = modein0 ' update the prior state
does have to be in your main loop.
The logic function can be chosen to do what you want:
If you stilll have trouble with it, post your distilled code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com