Shop OBEX P1 Docs P2 Docs Learn Events
Timer Questions — Parallax Forums

Timer Questions

ArchiverArchiver Posts: 46,084
edited 2003-06-02 00:49 in General Discussion
I'm used to PLC programming where you can use delay on or off timers
while the rest of the code is still executing, with the stamp and the
pause command everything stops, is there any way to run a timer while
code is still being executed, or would I have to use a external timer
like a 555 or 556 ?? Also could I use a real time clock to cause
daily events?? Thanks.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-06-01 19:47
    You could use a 555 or a real time clock (RTC) module. There is an
    application note on the Parallax web site about using the DS1302
    RTC. The problem with both of those solutions is that the basic
    stamp can't handle interupts so your code will have to poll either
    the timer or the RTC.

    --- In basicstamps@yahoogroups.com, "todd22827" <todd@s...> wrote:
    > I'm used to PLC programming where you can use delay on or off
    timers
    > while the rest of the code is still executing, with the stamp and
    the
    > pause command everything stops, is there any way to run a timer
    while
    > code is still being executed, or would I have to use a external
    timer
    > like a 555 or 556 ?? Also could I use a real time clock to cause
    > daily events?? Thanks.
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-01 20:45
    RTCs are easy to connnect and will give you infinitely more flexibility in
    your projects. Our web site has code for at least two (DS1302, PCF8583).

    -- Jon Williams
    -- Parallax


    In a message dated 6/1/2003 12:32:00 PM Central Standard Time,
    todd@s... writes:

    > I'm used to PLC programming where you can use delay on or off timers
    > while the rest of the code is still executing, with the stamp and the
    > pause command everything stops, is there any way to run a timer while
    > code is still being executed, or would I have to use a external timer
    > like a 555 or 556 ?? Also could I use a real time clock to cause
    > daily events?? Thanks.



    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-02 00:49
    Hi Todd,

    I use PLC's too, but I like Stamps better.
    The PLC timers are nice though.

    When I need a delay instead of doing a pause xxxx
    I will pause for 1 count, go look at the other things that need looking at
    and then come back the delay.

    This code waits for a process delay, while looking at two status inputs. If
    the inputs change the program jumps. If not a small delay happens, and starts
    over again.

    x = 0
    'PDD = a user delay setting
    Man_Fire_1:
    '
    if Plasma_Start = 1 then Plasma_Off 'Look for the start command to go
    away
    if Motion_In = 1 then Man_Fire_1 'Look for Machine Motion to go away
    X=X+1 'Wait for Pierce Delay
    pause 1
    if x < PDD then Man_Fire_1

    Next_Code_Section:

    This code is used for starting a Plasma Cutting Torch
    I look at the 2 signals (Plasma-Start & Motion_In)
    If they are still true then I
    Pause 1
    Increment the counter
    Test the counter to see if it has counted up high enough.
    If it has then it drops to the next code section.
    If not then it goes to the start of the section and checks
    everything again.

    This is crude timing but for things under a few seconds it is quite accurate.
    You can fine tune the value of PDD for better accuracy if needed.

    With this code you can watch stuff and wait at the same time.
    I like to call it Waiting Faster.

    Hope this helps.

    Alan Bradford
    Plasma Technologies





    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.