Shop OBEX P1 Docs P2 Docs Learn Events
bonehead pbasic 2.5 question — Parallax Forums

bonehead pbasic 2.5 question

TaylortronicTaylortronic Posts: 20
edited 2005-11-01 15:59 in BASIC Stamp
hello, stamp programmers,

i am currently working on a datalogging/relay control project that performs logging operations every minute.· this time-based reporting has me just a little hung up.· i am new at the pbasic·but i'm sure there is a more elegant way to launch a subprogram when the minute changes than the clunky method that i'm using.
right now, my program uses a variable that is defined as minutes and another called minutewatcher.· minutewatcher·= minutes+1.· i've also inserted an "IF minutewatcher = minutes THEN..." exit out of the loop that the program runs through the duration of the current minute.· the minutes variable catches up to the minutewatcher variable when the minute changes and then after the datalogging subprogram minutewatcher is refreshed as minutes + 1 and returns to the original loop.
i am absolutely convinced that this is caveman programming.· it costs me a variable, and it's linear (only checks the minutes at one point in the loop instead of consistently while monitoring sensors) and i'm sure there is a cooler way to go.· does anybody know a command or technique to launch a subprogram when a time variable changes?

looking for an emoticon that checks his watch,
taylortronic

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-29 17:26
    It's easier to help when you post the actual code versus a description of it -- you might be off be less than you think but that's difficult to determine without seeing your working code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-10-30 00:14
    Hi Taylortronic,

    I think you are on the right track, too. It may be that you don''t need to use a whole byte for this, when one bit would do. One bit can track it, as it rolls from even to odd to even.....

    minuteRollBit VAR Bit
    '...
    top:
    DO 
       GOSUB check_watch
    LOOP WHILE minute.bit0=minuteRollBit
    minuteRollBit=minute
    process_Data:
       ' ...
    GOTO top
    



    I don't understand what your are getting at with this statement, "and it's linear (only checks the minutes at one point in the loop instead of consistently while monitoring sensors)".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • TaylortronicTaylortronic Posts: 20
    edited 2005-11-01 15:59
    thanks, guys. i'll be sure to include code next time i'm in a bind. i was thinking that there might be a function that watched the clock while running a subprogram. i guess that's a tall order for a microprocessor - but that's what i meant about "only checking the watch at one point in the loop". i guess the processor is fast enough to where it doesn't make any difference.
    anyway, if this is the technique you guys would use, i'm certain it's the right way to go.
    once again, this forum has made the path clear for me and i really appreciate it.
    sincerely,
    taylortronic
Sign In or Register to comment.