Shop OBEX P1 Docs P2 Docs Learn Events
monitoring change over time. — Parallax Forums

monitoring change over time.

press9761press9761 Posts: 6
edited 2005-10-28 17:05 in BASIC Stamp
I am having a hard time here. I am trying to monitor R/C time changes over a period of time and I can't seem to find an command in PBASIC to do so.

this is what I mean.

when R/C time is grater then 500 (lets say)
watch for 2 minutes
if during the 2 minutes it has stayed above 500
do X

I know how to tell the basic stamp2 to check r/c time but not how to monitor in over a certain continues length of time.

anyone know how to do this.

thanks!

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-10-28 09:07
    press9761 -

    In pseudo-code it might look like this:
    /code

    '{$PBASIC 2.5}

    pause_time var byte
    value var byte
    under_limit var bit
    time con 15 'Set time to 15 seconds (calculate as appropriate)

    Start:
    under_limit = 0
    end_time = 0
    pause_time = time

    Field_Value:

    DO

    · RCTIME value
    · IF value < 500 then under_limit=1
    · pause pause_time
    · end_time = end_time + pause_time

    Loop until end_time >= 120

    IF under-limit = 0 then end_okay

    DEBUG "Under limit occurred"
    STOP

    end_okay:

    DEBUG "Limits okay"

    END
    code/

    Unchecked for syntax errors, and before 1st cup of morining java smile.gif

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 10/28/2005 9:10:17 AM GMT
  • metron9metron9 Posts: 1,100
    edited 2005-10-28 17:05
    You could set up a second R/C timer, charge it up for a 2 minute timer.


    main:

    If rctime1>500 then
    charge rctime2 for a 2 minute timer
    loop:
    if rctime1 < 500 then setunderlimitflag and goto exit
    if rctime2 has run out then goto exit
    goto loop
    exit:
    endif

    if setunderlimitflag is set then
    do something....
    else
    do something else
    endif

    goto main
Sign In or Register to comment.