Shop OBEX P1 Docs P2 Docs Learn Events
Timing with the BS2 — Parallax Forums

Timing with the BS2

ArchiverArchiver Posts: 46,084
edited 2000-10-11 21:15 in General Discussion
I am working on a device that measures the deacceleration of balls as
they pass through light gates but I'm having a problem with the
timing
using the BS2. It times in 2us units so the maximum length of time is
0.131s. If anybody knows how I can time for longer periods to ms
accuracy please let me know. I tried using a loop with the pause
command for 1 ms but it then takes 0.3 ms to read the pause
instruction and 0.3 ms to read the instruction after it so it's no
good. Any help would be appreciated.

Andy

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-10 16:30
    Have a look at the PAK-VII. With the prescaler, you can select your tradeoff
    between accuracy and duration. The basic measurement is 16 bits of 5uS.
    However, you can divide that by 2, 4, 8, 16, 32, 64, 128, or 256 (that's
    10uS to 1.28mS). You use SHIFTIN and SHIFTOUT to talk to the PAK and it
    measure 8 channels at once.


    Regards,

    Al Williams
    AWC
    http://www.al-williams.com/awce/pak7.htm


    >
    Original Message
    > From: Andy Schwarz [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=dDOk2nJtlUVhuYYD1byNwhp1E-awKq4t_fglo-ad0tocTAgwAE33B5KN8ZBFpaXeU5GL7UckfzwoMTDHnxzXbI9u991G140p-g]phyaks@p...[/url
    > Sent: Tuesday, October 10, 2000 10:21 AM
    > To: basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Timing with the BS2
    >
    >
    > I am working on a device that measures the deacceleration of balls as
    > they pass through light gates but I'm having a problem with the
    > timing
    > using the BS2. It times in 2us units so the maximum length of time is
    > 0.131s. If anybody knows how I can time for longer periods to ms
    > accuracy please let me know. I tried using a loop with the pause
    > command for 1 ms but it then takes 0.3 ms to read the pause
    > instruction and 0.3 ms to read the instruction after it so it's no
    > good. Any help would be appreciated.
    >
    > Andy
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-10 16:52
    Andy,

    Check out http://www.phanderson.com/timer_1_2.html.

    Cheers,

    Steve
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-10 17:08
    >I am working on a device that measures the deacceleration of balls as
    >they pass through light gates but I'm having a problem with the
    >timing
    >using the BS2. It times in 2us units so the maximum length of time is
    >0.131s. If anybody knows how I can time for longer periods to ms
    >accuracy please let me know. I tried using a loop with the pause
    >command for 1 ms but it then takes 0.3 ms to read the pause
    >instruction and 0.3 ms to read the instruction after it so it's no
    >good. Any help would be appreciated.

    Hi Andy,

    A tight loop can count the time P0 stays high in units of .713 milliseconds
    on a BS2:

    x var word
    timer:
    x=0
    timer0: ' wait here until P0 goes high
    branch in0,[noparse][[/noparse]wait2start]
    timer1: ' 1426 loops per second, 7.013E-4 seconds per loop
    x=x+1
    if in0 then timer1 ' count until in0 goes low
    debug dec x**45960," milliseconds",cr ' ** converts to millisecs.
    goto timer

    True, there is uncertainty in the result due to the loop processing time.
    Here are links to external timer chips made for the stamp:

    http://home.earthlink.net/~parkiss/tm1summ.txt
    http://www.phanderson.com/timer_1_2.html
    http://www.al-williams.com/awce/pak7.htm

    I hope that helps
    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-11 00:42
    Thanks for your help. I think the pak7 solves all my problems.

    Andy
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-11 01:52
    Hi Andy,

    It is not possible to get faster time counting with a stamp that I know of.
    Try using an external counter, timebase generator, and a shift register to
    move data into the stamp from the counter.

    Chuck
    Original Message
    From: Andy Schwarz <phyaks@p...>
    To: basicstamps@egroups.com <basicstamps@egroups.com>
    Date: Tuesday, October 10, 2000 11:21 AM
    Subject: [noparse][[/noparse]basicstamps] Timing with the BS2


    >I am working on a device that measures the deacceleration of balls as
    >they pass through light gates but I'm having a problem with the
    >timing
    >using the BS2. It times in 2us units so the maximum length of time is
    >0.131s. If anybody knows how I can time for longer periods to ms
    >accuracy please let me know. I tried using a loop with the pause
    >command for 1 ms but it then takes 0.3 ms to read the pause
    >instruction and 0.3 ms to read the instruction after it so it's no
    >good. Any help would be appreciated.
    >
    >Andy
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-11 19:57
    Am I right in perceiving the TM-1 as the most precise timer with BS2SX?
    Also, I can't find a contact for purchase - anybody have Steve Parkis' email
    address to ask him?

    Tracy Allen wrote:

    > >I am working on a device that measures the deacceleration of balls as
    > >they pass through light gates but I'm having a problem with the
    > >timing
    > >using the BS2. It times in 2us units so the maximum length of time is
    > >0.131s. If anybody knows how I can time for longer periods to ms
    > >accuracy please let me know. I tried using a loop with the pause
    > >command for 1 ms but it then takes 0.3 ms to read the pause
    > >instruction and 0.3 ms to read the instruction after it so it's no
    > >good. Any help would be appreciated.
    >
    > Hi Andy,
    >
    > A tight loop can count the time P0 stays high in units of .713 milliseconds
    > on a BS2:
    >
    > x var word
    > timer:
    > x=0
    > timer0: ' wait here until P0 goes high
    > branch in0,[noparse][[/noparse]wait2start]
    > timer1: ' 1426 loops per second, 7.013E-4 seconds per loop
    > x=x+1
    > if in0 then timer1 ' count until in0 goes low
    > debug dec x**45960," milliseconds",cr ' ** converts to millisecs.
    > goto timer
    >
    > True, there is uncertainty in the result due to the loop processing time.
    > Here are links to external timer chips made for the stamp:
    >
    > http://home.earthlink.net/~parkiss/tm1summ.txt
    > http://www.phanderson.com/timer_1_2.html
    > http://www.al-williams.com/awce/pak7.htm
    >
    > I hope that helps
    > -- Tracy Allen
    > electronically monitored ecosystems
    > http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-11 21:15
    >Am I right in perceiving the TM-1 as the most precise timer with BS2SX?
    >Also, I can't find a contact for purchase - anybody have Steve Parkis'
    email
    >address to ask him?
    >> http://home.earthlink.net/~parkiss/tm1summ.txt

    Timing resolution to 1 microsecond in 71.5 or more minutes.

    mailto:parkiss@e...

    Steve is active on this list. The last time I talked with him, he was
    heading off with a backpack to the Grand Canyon. So you might not get an
    immediate reply!

    Steve provides the Scenix source code for the TM-1 there on his site:
    http://home.earthlink.net/~parkiss/tm1sxcod.txt
    If you have an SX-key or an SX-blitz from Parallax you can burn your own
    chip.

    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
Sign In or Register to comment.