LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding velocity of moving robot using sonar sensor

Hi
I am trying to find the velocity of my my moving robot using sonar sensor, this sensor is giving me the distance to the object and as it moves the distance gets closer and it tells me less distance Now I wonder how to get the velocity as my robot moves. Give me some idea like how to record the reading previous and present then taking difference and dividing by time i.e Velocity=distance/time.
How to do this?
My Vi is attached
0 Kudos
Message 1 of 10
(3,220 Views)
does this do what you want ??
0 Kudos
Message 2 of 10
(3,202 Views)
You need to have some record of the time. I have modified your attached vi to include some "time stamp" of your position measurements. Then, using a shift register, the previous measurement is used to calculate the DeltaX and the DeltaT, then to calculate the velocity as DeltaX/DeltaT.
However, such a simple calculation will have an accuracy that depends directly on the position accuracy and on the velocity of the robot. The loop timing (Here I used a delay of 100 ms)should be optimized.

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 3 of 10
(3,197 Views)
Hi
Mr Dan and Mr Chilly Charly
IN the Vis that you forwarded to me has similar problem. If you look at the Vi where we are using shift register and the taking the difference of two readings previous and present the answer should come out to be very low if the position has not changed.
For example my previous readings tells distance is 11.5167 cm and present reading is slightly less like 11.4822 then afetr subtraction the answer should come out to be 0.0345 but if I put indicator after that it shows me 11.5 or some thing like reading not showing the difference of two. Also in Mr Dans Vi it gives all the time a constant velocity of 13560 which I am unable to undertand why.

take it like that I am constantly getting some increasing/decreasing numbers at varying rate I need to take difference of two and divide by time.
Also time watch used by Mr charly is not taking the differnce of two timings like delta time should be very low, but it is not
what is happening here and what should I do now
Thankyou for help
0 Kudos
Message 4 of 10
(3,176 Views)
The deltaT should be close to 100 ms = 0.1 sec, but this may be a too short time period to assess the velocity with accuracy. Try to increase the loop time delay to 1 second (1000 ms). I don't see any reason not to get the proper deltaX by subtracting the last reading to the previous one.
In Dan's vi there is a confusion between the time of flight of the sound wave and the reading time, that explains the result you observe.
CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 5 of 10
(3,163 Views)
Hi
this what is happening. I am attaching files of signal which is captured on Oscope. You can see that there is one small pulse and one long pulse and then on oscope I measure the pulse width which is same as in labview. but look at the signal which I captured in labview all peaks and its amplitude is even not 5 volts which is the strenght of the signal. But same signal once I saw in automation explorer it has amplitude of 5 volts and different signal pattern.

Now I ran my Vi in that highlighted mode to see the signal and also once I increased the loop time to one second now I saw that every second reading is not range but some constant wrong number being generated by labview which ultimately gives my range equals to 0.17cm or inches so once it goes in shift register so the difference is always constant for example pattern is like the
35---0.17---35---0.17---35---0.17 and so on ,,so if we take deltax of this --one time it is +ve 35 and next time it is -ve 35 which makes whole effort useless.
once I run loop fast then I dont see such pattern but I believe it is happening at faster rate. so Thats why I am not getting velocity good.
Now what do you suggest how to get rid of that middle reading and how to capture suare wave in my Vi
Thanks
0 Kudos
Message 6 of 10
(3,157 Views)
I can't help you more here. I suggest you post a new question, more related to signal acquisition.
CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 7 of 10
(3,149 Views)
Hi tmdar,

The program you showed in the screen capture appears to be different from the one posted. Can you post the exact code which you used in obtaining that capture? Also, you mentioned that "on oscope I measure the pulse width which is same as in labview. but look at the signal which I captured in labview all peaks and its amplitude is even not 5 volts which is the strenght of the signal"..I'm a little confused if the data you're seeing in LabVIEW is correct. Did it once work, but something changed? What you're seeing in MAX may be due to the scaling of the x-axis. If you run the Test Panel in "Continuous" mode instead, sampling at around 500000Hz, what do you see?

(Alternatively, you can run a LabVIEW shipping example from Help >> Find Examples (Hardware Input and Output >> DAQmx >> Analog Measurements >> Voltage >> Cont Acq & Graph_Int clk.vi))

Thanks,
Lesley Y.
0 Kudos
Message 8 of 10
(3,121 Views)
Hi
I captured the signal in Vi you mentioned that came with examples. I mentioned earlier since sonar sensor emits small ping and then larger pulse tells you about the distance larger the pulse farther the distance ideally speaking I must see one small pulse and one larger pulse but I can see the larger pulse but instead of small I am looking at some noise or distortion. so pattern I am getting is large pulse and then distortion , larger pulse then distortion and so on. If I am able to remove that noise the larger pulse width is my distance which I want further for my calculation. Look at the attachments.
What do you suggest?
My Vi was same as I posted only I have attached graphic indicator more in the Vi.
Due to this recurrent distortion I get some wrong constant data and number alternatively which makest my delta X i.e dstance same

for example distortion every times give me 0.17 distance so if disance is like 20 cm my display will work like 20--0.17---21---0.17--22---0.17 so if I take deltax that is difference between twoconsecutive distance change which should be like difference between 22-21=1 it actually becomes 22-0.17=20.93 and next time it calculates 0.17-23=-22.83 which becomes wrong.

If I remove this distortion or tell my Vi not to read below certain votages--- how can I do that.
Thanks
0 Kudos
Message 9 of 10
(3,111 Views)
Tmdar,

From your screen shot, it seems like the signal is betwen 1.5V and 5V. One way you can eliminate the small (0.7V) noise distortion is to use the "In Range and Coerece" VI such that a value less than 1.5V is coereced to 1.5V. You can find this VI in the Comparison subpalette.

Thanks,
Lesley
0 Kudos
Message 10 of 10
(3,083 Views)