Shop OBEX P1 Docs P2 Docs Learn Events
Velocity timer project, check my work please! — Parallax Forums

Velocity timer project, check my work please!

ArchiverArchiver Posts: 46,084
edited 2002-06-25 09:01 in General Discussion
Hi All,

First time poster, and I just got a 2sx. Not to mention my programming is
limited and 15 years outdated. Here come the questions! ;-)

I am trying to use the stamp to determine the muzzle velocity of a Coil Gun.
As it seems that the stamp doesn't have any timer functions (I searched the
archives, and that was the gist of it) and I don't have a clock chip handy,
and I didn't feel like mucking with a 555, I decided to try using the
"pulsin" command. I put an ir gate across the barrel of the gun, (which is
made of clear plastic) which triggers a transistor high when the gate is
interrupted. This makes a pulse for as long as the projectile blocks the
gate. I figured since I know the length of the projectile, I could calculate
the projectile speed from the pulse length produced. The code I used was:

Time Var Word

Again:
pulsin 1, 1, Time
if Time = 0 then Again
debug dec ? Time
goto Again

This seems to work. Time returns a value of around 1900. Since the 2sx
pulsin command increments time in .8us segments, I (correct me if I am
wrong!!) multiply 1900 by .8 which yields 1520. Move the decimal over three
places to change to ms, giving 1.52ms. The length of the projectile is 25mm
so 25/1.52 = 16.4 meters/second. Is this all true? The values I am getting
are believable for this coil gun. I just need someone to verify that this
all makes sense.

How accurate is this likely to be? If anything the numbers are a little low.
I plan on checking the speed using a sound card and measuring the time
between the discharge and impact sounds. I have done this before, so I have
all the stuff and will set it up this afternoon. Is it at least likely to be
consistant if not accurate? What about better ways of achieving the same
goal?

As the stamp only deals with whole numbers, how do I code the math required
to make "Time" read in meters/second?

Enough questions for this post. More to follow ;-)

Thanks for the input!

Jonathan Peakall

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-06-25 09:01
    >Hi All,
    >
    >First time poster, and I just got a 2sx. Not to mention my programming is
    >limited and 15 years outdated. Here come the questions! ;-)
    >
    >I am trying to use the stamp to determine the muzzle velocity of a Coil Gun.
    >As it seems that the stamp doesn't have any timer functions (I searched the
    >archives, and that was the gist of it) and I don't have a clock chip handy,
    >and I didn't feel like mucking with a 555, I decided to try using the
    >"pulsin" command. I put an ir gate across the barrel of the gun, (which is
    >made of clear plastic) which triggers a transistor high when the gate is
    >interrupted. This makes a pulse for as long as the projectile blocks the
    >gate. I figured since I know the length of the projectile, I could calculate
    >the projectile speed from the pulse length produced. The code I used was:
    >
    >Time Var Word
    >
    >Again:
    > pulsin 1, 1, Time
    > if Time = 0 then Again
    > debug dec ? Time
    >goto Again
    >
    >This seems to work. Time returns a value of around 1900. Since the 2sx
    >pulsin command increments time in .8us segments, I (correct me if I am
    >wrong!!) multiply 1900 by .8 which yields 1520. Move the decimal over three
    >places to change to ms, giving 1.52ms. The length of the projectile is 25mm
    >so 25/1.52 = 16.4 meters/second. Is this all true? The values I am getting
    >are believable for this coil gun. I just need someone to verify that this
    >all makes sense.

    Those calculations look fine to me. Or you can go direct:
    velocity = 31250 / time ' when time is in units of 0.8 us
    or for the stamp calculation (below):
    velocity*10 = 62500 / (time/5)

    >
    >How accurate is this likely to be? If anything the numbers are a little low.
    >I plan on checking the speed using a sound card and measuring the time
    >between the discharge and impact sounds. I have done this before, so I have
    >all the stuff and will set it up this afternoon. Is it at least likely to be
    >consistant if not accurate? What about better ways of achieving the same
    >goal?

    The IR gate may be electrically slow (especially if it is the kind
    that uses a photo-transistor with a pull-up resistor). That would
    overestimate the pulse time, underestimate the velocity. Decreasing
    the pullup resistance can improve the response. I don't know about
    the optical path. A setup that uses one IR gate to set a flip-flop,
    and a second IR gate placed further away to reset the flip flop,
    could be more accurate, but it requires more external parts outside
    the Stamp.

    >
    >As the stamp only deals with whole numbers, how do I code the math required
    >to make "Time" read in meters/second?
    >
    Again:
    pulsin 1, 1, Time
    if Time = 0 then Again
    debug dec ? Time
    velocity = 62500/(time/5)
    debug "velocity=",dec velocity/10,".",dec1 velocity," m/s"
    goto Again

    That would give velocity=16.4 when raw time=1900. The trick in the
    velocity calculation is to make the numerator as large as possible,
    and keep the denominator around 2^8. There are more accurate ways
    to do it, with more calculation.

    >
    >Enough questions for this post. More to follow ;-)
    >
    >Thanks for the input!
    >
    >Jonathan Peakall


    I hope that helps!

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com
Sign In or Register to comment.