Shop OBEX P1 Docs P2 Docs Learn Events
latch circuit? — Parallax Forums

latch circuit?

wiresalotwiresalot Posts: 40
edited 2010-03-17 23:31 in BASIC Stamp
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

Comments

  • silverbacksilverback Posts: 40
    edited 2010-03-17 23:30
    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 GreenMike Green Posts: 23,101
    edited 2010-03-17 23:31
    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.
Sign In or Register to comment.