PDA

View Full Version : latch circuit?

wiresalot
03-18-2010, 06:01 AM
Is there away to create a latch/unlatch circuit in my program?

15 would = latch
and say 12 would = unlatch

' {\$STAMP BS2}
' {\$PBASIC 2.5}
value VAR Word

Main:
DO
HIGH 14
HIGH 2
PAUSE 100
RCTIME 2, 1, value ' measure rctime
DEBUG DEC value, CR
IF (value = 1 ) THEN ' evaluate duration
DEBUG "alarm " : HIGH 15
ELSEIF (value = 0) THEN
DEBUG "trouble" : LOW 14 :PAUSE 100: HIGH 14 :PAUSE 100 : LOW 14
ELSE
DEBUG "normal "
ENDIF
DEBUG CR, CR
PAUSE 100
LOW 15
LOOP

thanks,

wiresalot

silverback
03-18-2010, 06:30 AM
Are you talking about a latch as in Flip Flop? or a latch that would keep the circuit in a state until a button or interupt hit a level?

If it was a flip flop latch I think you could make a simple addition to the program that would put 12 in the opposite state of 15. (if 15 =1 then 12 =0, if 15= 0 then 12 = 1)

If you need a latch to keep 15 high until 12 "unlatched" the circuit, if 15 goes high, you could drop to a sub-routine that keeps 15 high until it see a state change on 12. I used a subrountine like that on a self-calibrating bot once. 12 could be triggered by anything a button, a count-down, it's own RCTime calculation.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If you convince yourself that something is impossible before you even try; you are sure to prove yourself right.

Mike Green
03-18-2010, 06:31 AM
What do you mean by "a latch/unlatch circuit"? What do you want your program to do?

The output register (OUTS) is a latch if that's what you really need.