Shop OBEX P1 Docs P2 Docs Learn Events
One shot event coding/capability — Parallax Forums

One shot event coding/capability

PCB4UPCB4U Posts: 14
edited 2007-07-01 16:40 in BASIC Stamp
Hi Folks

I'd like to use the STAMP to monitor 6 discretes. At any time, a one shot may occur at any of the 6 inputs and I'd like to set an ouptut to be HI until I do a manual reset. I'm concerned the STAMP will set the output LO once the one shot is gone.

My original circuit has a latching relay but the idea of a relay being on for days led me to go to the STAMP.

...or is there a way to go via chips that once the one shot is seen and returns LO, a HI is set and stays that way until I do a manual reset?

Thanks for any ideas
Jay
·

Comments

  • PCB4UPCB4U Posts: 14
    edited 2007-06-30 15:49
    MODIFIED SENTENCE 2

    ...................... At any time, a one shot may occur at any of the 6 inputs and I'd like to set the appropriate ouptut (6) to be HI until I do a manual reset.

    Thanks
    Jay
  • D FaustD Faust Posts: 608
    edited 2007-06-30 16:03
    Couldn't you write a code that said:
    If IN0 = 1 THEN
    HIGH (Output)
    etc...
    IF IN1 = 1 THEN 'Button pressed
    LOW (Output)
    etc...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-06-30 16:17
    You could use 6 -·555 timers or 3 3- 556 in this fashion:


    HIGH 1
    INPUT 2
    buttoncount VAR Byte
    waitcount·· VAR Word
    DO
    · DO WHILE IN2=0
    ··· PAUSE 10 'delay for testing - not necessary
    ··· DEBUG HOME,?buttoncount,?waitcount
    ··· waitcount=waitcount+1
    · LOOP
    · buttoncount=buttoncount+1
    · DEBUG HOME,?buttoncount
    · PAUSE 500
    · PULSOUT 1,10 'reset latch
    LOOP
    attachment.php?attachmentid=46961

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR
  • FranklinFranklin Posts: 4,747
    edited 2007-06-30 16:26
    PCB4U, if you click the pencil on the right top of your messages you can edit them. (took me a while to figure that one out)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PCB4UPCB4U Posts: 14
    edited 2007-06-30 16:32
    Thanks for the input.

    So if I understand it...your idea is to use a 555 as a latch for an input to the STAMP which when triggered will stay HI until a manual reset.

    The PAUSE is good if I understand the code in that it allows a dead time (settling time I think the phrase is) before setting the oputput HI

    I would have to nest some code since I will be monitoring 6 inputs...right?
    .
    .
    .
    But couldn't I just the use the 555 as a latch for each of the 6 discetes and let the 555 drive a LED and not use a STAMP?
  • PCB4UPCB4U Posts: 14
    edited 2007-06-30 16:35
    ...oopssssss

    But the PAUSE is needed...maybe I could use another time to create a 15 second delay than hit the 555 circuit you drew up
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-06-30 16:36
    Lets say your inputs are on P0 to P5 (with P6-P7 tied low to Vss).· You can read the entire byte as INL. Let's put your reset switch on P8 and your LED on P15.

    
    
    LoOW 15    ' set output as cleared initiallyDO
      IF INL <> 0 THEN HIGH 15    '  If any switch is pressed, set output high
    
      IF IN8 = 1 THEN LOW 15      '  if reset button pressed, clear output
    LOOP
    

    Be sure your input switches have pull-up resistors to Vss, and when activated it·makes connection to Vdd (active-high configuration)

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-06-30 16:39
    Yes, you could bypass a stamp and use a manual reset button and the 555's will preserve the state indefinitely until reset (or you kill power). Just to be clear pin 4 resets when it goes low therefore you could reset multiple 555's simultaneously with 1 button.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR
  • PCB4UPCB4U Posts: 14
    edited 2007-06-30 16:41
    Martin

    Thats interesting. I need 6 LEDs to show which input created the one shot. How woudl INL·work to set the appropriate output HI?
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-06-30 16:43
    Sorry, just saw you needed to control 6 LEDs.· If the 6 LEDs are on P8 to P15, a simple way would to control them at once with OUTH, then just sit in a loop until the reset button on the Stamp's board is pressed

    
    
    
    
    OUTH = $FF      ' Set P8-P15 as outputs
     
    DO
      IF INL <> 0 THEN         ' if any button pressed,
          OUTH = INL           ' set appropriate output
          DO                   ' sit in loop until reset
          LOOP
      ENDIF
    LOOP
    

    -Martin
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-06-30 20:07
    Here is a simple one that scans inputs p0 to p6 and sets and holds the state of the most recently pressed input. So if input even p3 happens then the LED on p11 turns on. But if then p1 event happens, the LED on p11 will go out and the LED on P1 will come on. If you make p6 high, that will reset all the LEDs to off.

    DIRH = $3F   ' make p8 to p13 outputs
    
    DO
       IF INL & $7F THEN OUTH = INL   ' <-- latches most recent event, resets on p6 high
    LOOP
    



    Here is a variation that turns on LEDs for all events that happen, that is, if event on p3 happens and then the event on p1, then both LEDs will come on and stay on.

    DIRH = $3F   ' make p8 to p13 outputs
    
    DO
       IF INL & $7F THEN OUTH = INL | OUTH   '<-- latches all events, resets on p6 high
    LOOP
    



    The code that Martin posted latches the first event that happens, and then locks out all others. (Typo, the OUTH=$FF should be DIRH=$FF).

    It all depends in detail on what needs to happen.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • PCB4UPCB4U Posts: 14
    edited 2007-06-30 21:15
    Tracey

    Thanks much for the input.

    My requirements are nested and maybe you can help me along with this. Not only is a scan of 6 signals required but I must determine a 7th signal for a·TRUE/FALSE state after which· I can set the appropriate output to power down a circuit if the 7th signal is deemed TRUE. If the 7th signal is deemed FALSE (all is well), return to scanning the 6 discretes.

    The 7th signal needs to be analyzed after·a 15·second delay·to determine its true state (need settling time).


    Hi Level Flow

    GIVEN: Only one discrete will be active·during any time interval. There will be no case where 2 or more discretes will be active at the same time.


    1. Scan 6 inputs to determine which one is·active (TRUE). If none are TRUE, loop back and continually scan the 6 discretes until a·TRUE is detected. A 100ms delay needs to be incorporated as it scans from one input to the next input. I just discoverd some settling time problems (relays)

    2. When·a·TRUE is detected in the 6 discretes,·we now know which circuit is active. Store which input pin detected the TRUE.

    3. Now jump to another procedure to validate the 7th Signal

    4. In the new procedure for the 7th signal, first allow a 15·second delay·for the signal to settle before verifying its TRUE or FALSE state

    5. If the 7th signal is TRUE, output the applicable output pin associated with the 6 discrete input signals as determined by the data stored in (2) above·(e.g. IN1 = OUT8, IN2 = OUT9, etc).

    6. If the 7th signal is FALSE,·return to (1) above and start scanning the 6 discetes again.

    I'm a pretty poor programmer so any help by·yourself and all in the forum is indeed welcome.

    I did use the Stamp chip a few years back to convert some RS232 data·so I could switch differnet relays to control differnt circuits based on the RS232 stream. I do recall the nightmare· smile.gif

    Thanks to all
    Jay






    ·······
    ·······
    ····
    ···

    Post Edited (PCB4U) : 6/30/2007 9:20:45 PM GMT
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-07-01 05:12
    Something like this?

    holder VAR byte
    DIRH = $3F   ' make p8 to p13 outputs
    DIRL = 0   ' p0 to p5 for discrete inputs, p6 for the 7th signal
    
    scanning:
      DO : LOOP UNTIL INL   ' wait for input
      holder = INL & $3F     ' got it
      PAUSE 100   ' for debouncing, wait 100 milliseconds
      IF INL <> holder THEN scanning   ' check if the signal is still there, if no, go back, if yes, continue
    continue:   
      PAUSE 15000    ' wait for 7th signal
      IF IN6=0 THEN scanning   ' test it, if zero, go back to scanning
    makedo:
      OUTH = holder   ' test is okay, set the LED.
      STOP   ' wait for Stamp reset
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • PCB4UPCB4U Posts: 14
    edited 2007-07-01 05:50
    Tracey

    In the statement
    DO·:·LOOP·UNTIL·INL···'·wait·for·input

    Does the INL statement·take a snapshot at p0 thru p5 at one time (looks at low byte...in this case every 100ms)?

    I really appreciate your assistance and patience

    Jay
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-07-01 06:02
    DO : LOOP UNTIL INL ' wait for input

    That loops very fast, on the order of 1000 times per second, and each time it takes a snapshot of all of the inputs and drops out of the loop if any of them goes high. Subsequently, the program has a 100 millisecond delay and then tests the inputs again to be sure the same one is still active.

    You might want to include only pins p0 to p5 in the test, and also a little delay between samples, like this:

    DO : PAUSE 9 : LOOP UNTIL INL & $3F ' wait for input on p0 to p5, sample interval about 10 milliseconds

    Note that
    ... UNTIL INL & $3F
    is shorthand for
    ... UNTIL INL & $3F > 0
    It does not need the > 0, because any nonzero value evaluates as "TRUE".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • PCB4UPCB4U Posts: 14
    edited 2007-07-01 07:13
    Tracey

    How will INL associate·to INH?

    In the schematic attached, I'd like the input/output relationship (keeps flow logical) as follows:

    IN····· OUTPUT SET
    p0
    >p15
    p1
    >p14
    p2
    >p13
    p3
    >p12
    p4
    >p11
    p5
    >p10

    Thanks once again
    Jay
  • D FaustD Faust Posts: 608
    edited 2007-07-01 10:31
    Couldn't you use the BUTTON command to test have long the signal is "on" for?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • PCB4UPCB4U Posts: 14
    edited 2007-07-01 13:19
    The amount of time the discrete goes TRUE isn't a problem...its just the detection/capture of a discrete going TRUE
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-07-01 16:40
    Explain more what you mean by this:

    >> A 100ms delay needs to be incorporated as it scans from one input to the next input. I just discoverd some settling time problems (relays)

    Especially the settling time problems (relays). I thought you were talking about contact bounce, no?

    Here is the program again with small changes. The OUTH is associated with INH in the next to last line of the program, after the label "makeDo". I changed it to match what you have in your schematic. We had been associating output p8 with p0, p9 with p1 and so on. But in your schematic you have p15 with p0, p14 with p1 and so on, so the program employs the REV instruction to reverse the order of the logical bits.

    holder VAR byte
    DIRH = $FC   ' make p15 to p10 outputs <-- note change in pins
    DIRL = 0   ' p0 to p5 for discrete inputs, p6 for the pressure signal
    
    scanning:
      DO
         holder = INL & $3F     ' got inputs
      LOOP UNTIL holder   ' wait for input on p0 to p5
      PAUSE 100   ' for debouncing, wait 100 milliseconds
      IF INL & 3F <> holder THEN scanning   ' if the signal is not still there, go back to scanning
    continue:   
      PAUSE 15000    ' wait for 7th signal
      IF IN6=0 THEN scanning   ' i pressure is not good, go back to scanning
    makedo:
      OUTH = holder REV 8  ' set the LED, bits reversed to match schematic
      STOP   ' wait for Stamp reset
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.