Shop OBEX P1 Docs P2 Docs Learn Events
Timing — Parallax Forums

Timing

ArchiverArchiver Posts: 46,084
edited 2004-07-07 21:53 in General Discussion
Hello everyone [noparse]:)[/noparse]

Is the basic stamps clock readable in any way ? For instance what I really
want to do I would do like this in Qbasic.

Oldtime = TIMER
Clock:
a$=inkey$
if a$ = "" then Clock
print "Time =";timer-oldtime


The actual application is this. I have a stepper motor connected to the
shaft of a motion picture camera (Motion picture camera's have a
semicircular shutter so one rotation of the shaft is one frame). The
stepper motor is a Milford Instruments Bipolar stepper Driver set.

The stamp sets the rate at which the motor moves IE:-

200 steps at 2MS = 1 Frame at 1/5 sec

(the motor takes 400ms to turn but the shutter is only open for 200ms)

Now that's easy to calculate [noparse]:)[/noparse]

But I also have a "B" setting and a "T" setting .. On the "B" setting the
shutter opens until you let go of the button and the "T" setting the shutter
opens on the first press of the button and closes on the second. What I
want to do is time this event. Any ideas ?

Justin Pentecost

Focus Puller CML Listpig and Stamp Idiot
LONDON

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-08-06 13:45
    Justin:

    No, there isn't an internal clock in the Stamp as there is in PCs. You can
    synthesize a clock in PBASIC, but this becomes a bit tricky because you must
    make sure that the timing through all execution paths is the same.

    Another option -- depending on your resolution requirements -- is to use a
    BS2p and one of the Dallas 1-Wire clocks that return time in seconds plus
    1/256 of a second.

    The BS2p is fast and has a lot of other neat features, including the ability
    to interface very easily with parallel LCDs and I2C devices.

    -- Jon Williams
    -- Dallas, TX
    -- AKA Jon McPhalen
    -- Actor who appreciates good focus-pullers



    In a message dated 8/6/01 7:34:02 AM Central Daylight Time, justin@k...
    writes:


    > Hello everyone [noparse]:)[/noparse]
    >
    > Is the basic stamps clock readable in any way ? For instance what I really
    > want to do I would do like this in Qbasic.
    >
    > Oldtime = TIMER
    > Clock:
    > a$=inkey$
    > if a$ = "" then Clock
    > print "Time =";timer-oldtime
    >
    >
    > The actual application is this. I have a stepper motor connected to the
    > shaft of a motion picture camera (Motion picture camera's have a
    > semicircular shutter so one rotation of the shaft is one frame). The
    > stepper motor is a Milford Instruments Bipolar stepper Driver set.
    >
    > The stamp sets the rate at which the motor moves IE:-
    >
    > 200 steps at 2MS = 1 Frame at 1/5 sec
    >
    > (the motor takes 400ms to turn but the shutter is only open for 200ms)
    >
    > Now that's easy to calculate [noparse]:)[/noparse]
    >
    > But I also have a "B" setting and a "T" setting .. On the "B" setting the
    > shutter opens until you let go of the button and the "T" setting the shutter
    > opens on the first press of the button and closes on the second. What I
    > want to do is time this event. Any ideas ?
    >
    > Justin Pentecost
    >
    > Focus Puller CML Listpig and Stamp Idiot
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2001-08-06 14:09
    There are at least three chips out there that will add a clock in addition
    to the 1-wire:

    The Pocketwatch B
    http://www.parallaxinc.com/html_files/products/BS_Accessories/solutions3_bri
    ef.asp

    Parkis' Time Machine (not sure if you can really keep time with it or not)
    http://home.earthlink.net/~parkiss/

    Time Keeper http://www.high-techgarage.com/products/

    Also, if you need pulse measurement, a PAK-VII can keep a realtime clock
    (until the power is off) but if you just need a clock, one of the other
    devices is probably easier. The PAK-VII clock example is in
    http://www.al-williams.com/awce/doclib.htm

    Regards,

    Al Williams
    AWC
    * Easy RS232 prototyping:
    http://www.al-williams.com/awce/rs1.htm
  • ArchiverArchiver Posts: 46,084
    edited 2001-08-06 17:19
    Hi Justin,

    The stamp is deterministic, meaning that there are no interrupts or
    hidden processes that can change the timing of a loop. It sounds like
    your application the stamp will not have anything else to do while it
    times the shutter. The following loop measures the time that P0 on
    the stamp stays high. The loop executes ~1426 times per second (on
    the original BS2). The debug statement converts the time into
    milliseconds for display.


    ' snippet measures the time P0 stays high.
    xc var word
    loop2: ' 1426 loops per second, 7.013E-4 seconds per loop
    xc=xc+1
    if in0 then loop2 ' count until in0 goes low
    debug dec xc**45960,cr ' ** converts the count to straight milliseconds

    More on timing loops at:
    http://www.emesystems.com/BS2speed.htm

    -- Tracy


    >I have a stepper motor connected to the
    >shaft of a motion picture camera (Motion picture camera's have a
    >semicircular shutter so one rotation of the shaft is one frame). The
    >stepper motor is a Milford Instruments Bipolar stepper Driver set.
    >
    >The stamp sets the rate at which the motor moves IE:-
    >
    >200 steps at 2MS = 1 Frame at 1/5 sec
    >
    >(the motor takes 400ms to turn but the shutter is only open for 200ms)
    >
    >Now that's easy to calculate [noparse]:)[/noparse]
    >
    >But I also have a "B" setting and a "T" setting .. On the "B" setting the
    >shutter opens until you let go of the button and the "T" setting the shutter
    >opens on the first press of the button and closes on the second. What I
    >want to do is time this event. Any ideas ?
  • ArchiverArchiver Posts: 46,084
    edited 2001-08-06 23:03
    Hi Justin,

    I use the Pocket Watch in a central heating control. It's easy to use,
    because you can read a real clock.
    Another way is to use a 4060 IC with a quartz. This gives you a 2 Hz clock
    that you can manage with the Stamp. The only thing is to read the state of
    the clock at least 4 times per second. This point depends on the rest of the
    program.
    Let me know if you want to have more information about that.

    Best regards,

    Phil.

    Original Message
    Subject: [noparse][[/noparse]basicstamps] Timing
    > Is the basic stamps clock readable in any way ? For instance what I
    really
    > want to do I would do like this in Qbasic.
    >
    > Oldtime = TIMER
    > Clock:
    > a$=inkey$
    > if a$ = "" then Clock
    > print "Time =";timer-oldtime
    >
    >
    > The actual application is this. I have a stepper motor connected to the
    > shaft of a motion picture camera (Motion picture camera's have a
    > semicircular shutter so one rotation of the shaft is one frame). The
    > stepper motor is a Milford Instruments Bipolar stepper Driver set.
    >
    > The stamp sets the rate at which the motor moves IE:-
    >
    > 200 steps at 2MS = 1 Frame at 1/5 sec
    >
    > (the motor takes 400ms to turn but the shutter is only open for 200ms)
    >
    > Now that's easy to calculate [noparse]:)[/noparse]
    >
    > But I also have a "B" setting and a "T" setting .. On the "B" setting
    the
    > shutter opens until you let go of the button and the "T" setting the
    shutter
    > opens on the first press of the button and closes on the second. What I
    > want to do is time this event. Any ideas ?
    >
    > Justin Pentecost
    >
    > Focus Puller CML Listpig and Stamp Idiot <<<<<< you said that...
    :-)
    > LONDON
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-12 18:06
    Perhaps this is a foolish question. I am looking at the specs. of a small
    transmitter which lists the max modulation frequency as 4KHz. How would
    this translate into a data rate?

    Thanks,
    Matt
    ---
    [noparse][[/noparse]This E-mail scanned for viruses by Declude Virus]
  • ArchiverArchiver Posts: 46,084
    edited 2003-01-10 19:15
    I am using a 2sx that counts(for-next loop) to 25 min and then fades
    out a light. The unit is powered by battery(4AA). In the shop it
    counts fine on the demo board(nx-1000) but on stage it reaches 41
    min. Any ideas?
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-07 21:53
    If my memory serves me right I can only do a ten min pause,so without
    adding a time source of some sort,I will just have to back up the
    pauses so I can do multiples to get to the time I need.So that being
    said I don't want the delay while one pause is running into another,so
    can I put a cap in that line to that output so it won't do that.Yes I
    also realize it will do nothing else while counting that pause.

    Stan
Sign In or Register to comment.