Shop OBEX P1 Docs P2 Docs Learn Events
javelin stamp sensors — Parallax Forums

javelin stamp sensors

DakDuifDakDuif Posts: 8
edited 2007-01-09 12:39 in General Discussion
Hello,
I'm a 3th years college student on the MBO nv. 4 on ROC Zadkine Spijkenisse in the Netherlands.

We recently had an assesment to create a traintrack in which we got sensors that check how fast the train goes idea.gif

I need to check now how to convert the·time between 2 sensors (point 1 and 2) to speed (KMPH)·

Any hints burger.gif


Cheers,

Dave Koekebacker

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-11-14 14:53
    In pseudo code:

    Timer t = new Timer();
    int time,speed;
    while (true) {
    · while (!train_passed_sensor1) ; //wait until train passes sensor1
    · t.mark();
    · while (!train_passed_sensor2) ; //wait until train passes sensor2
    · time = t.passedMS(); //passed milliseconds
    · speed = distance/time; //distance is distance between sensor1 and sensor2
    }


    You need to specify how sensors registrate a train passing by.
    This could be a low pulse while train passes, it could also be a sticky value
    with a second pin resetting the sensor.

    regards peter
  • DakDuifDakDuif Posts: 8
    edited 2006-11-21 11:47
    hey mate, this is exactly what i was looking for, thanks alot! turn.gif

    cheers

    Dave Koekebacker
    Peter Verkaik said...

    In pseudo code:

    Timer t = new Timer();
    int time,speed;
    while (true) {
    · while (!train_passed_sensor1) ; //wait until train passes sensor1
    · t.mark();
    · while (!train_passed_sensor2) ; //wait until train passes sensor2
    · time = t.passedMS(); //passed milliseconds
    · speed = distance/time; //distance is distance between sensor1 and sensor2
    }


    You need to specify how sensors registrate a train passing by.
    This could be a low pulse while train passes, it could also be a sticky value
    with a second pin resetting the sensor.

    regards peter

  • DakDuifDakDuif Posts: 8
    edited 2007-01-09 12:25
    hey does anyone of you know a timer class which i can use?··· one that matches the

    Timer t = new Timer();
    int time,speed;
    while (true) {
    · while (!train_passed_sensor1) ; //wait until train passes sensor1
    · t.mark();
    · while (!train_passed_sensor2) ; //wait until train passes sensor2
    · time = t.passedMS(); //passed milliseconds
    · speed = distance/time; //distance is distance between sensor1 and sensor2
    }

    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-01-09 12:39
    The Timer class is supplied with the Javelin IDE.
    It is located in folder %path%\lib\stamp\core
    The original Timer class does not have the passedMS() method.
    You will find that in my adapted Timer class located here:
    http://tech.groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/
    You will also find the Timer16 class and ScaledTimer16 class.
    These provide you with a userdefined time unit and utilize only 16bits
    which is easier to handle than the 32bits of the Timer class.
    For your application, the StopwatchScaledTimer16 class may be of interest.
    It allows you to pause and restart, accumulating time.

    regards peter
Sign In or Register to comment.