Shop OBEX P1 Docs P2 Docs Learn Events
ping))) speed detector — Parallax Forums

ping))) speed detector

irivineirivine Posts: 18
edited 2009-01-14 17:07 in BASIC Stamp
hi

i am a student currently working on a project that uses products from parallax

i have bought the following product from parallax
1) ping))) ( http://www.parallax.com/Store/Sensors/ObjectDetection/tabid/176/CategoryID/51/List/0/Level/a/ProductID/92/Default.aspx?SortField=ProductName%2cProductName)
2)BS2
3)lcd display (http://www.parallax.com/Store/Accessories/Displays/tabid/159/CategoryID/34/List/0/Level/a/ProductID/50/Default.aspx?SortField=ProductName%2cProductName·)
4)math coprocessor (http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/coprocessor/List/1/ProductID/244/Default.aspx?SortField=ProductName%2cProductName)

I am suppose to make a device that have 2 program:
1) a program that can display the distance(part 1)·and the speed(part 2)·the device is moving on the lcd screen using the ping )))
2) a program that can can be place on a doorway and detector the number of passbyer and display the count on the lcd screen

I have manage to get the distance(part 1)·of program 1 and program 2 done ... but i am still having problem with the speed


Problems encounter:
1)in the code , i could get the speed in cm/hr , but the value appear *****.*** when it reach the maximum the ping))) can detect· (which·is·3100·cm) , how do i solve this problem ?
2)Regarding the speed·reading i want , i·am not sure if i am·heading in the right direction
· i·would like to make it into this kind of device(llustrate with situation)

Situation:
i am holding this device , there is an object in front of me , when i moved towards or away from it , it shows the speed i am moving at. if i am not moving the speed·, it will show (an example) 0 cm/hr.

how do i edit my code to allow it to get the program i want?

All helps are appreciated ! smilewinkgrin.gif

Thanks you

the source code for this program is attach below

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-01-14 17:07
    Since the BS2 does not have an onboard clock (that you can access) you'll need to estimate the speed, and do some tests. Basically, what you need is a loop that executes with constant time. Within that loop you get the Ping distance and get the difference of that reading with a previous reading. Then you can simply display the speed as difference / time (time is a constant in this case). Of course, this could end up with something like 134/3.4, so you may want to divide the value before you display it. Since the BS2 is not floating point capable, you'll need two divide operations (/ and %), and then display them with a . in between. Finally, you'll have to compare the old and new measurements to see which is greater (and hence which direction you are moving in)

    For the maximum distance maxing out your speed, you can just test to see if the ping has reached the maximum range. If it has then your relative speed is 0.
Sign In or Register to comment.