Calculate the speed of a vehicle

pat24

Member
Join Date
Nov 2012
Location
Be
Posts
3
We like to know the speed of a vehicle, it‘s a normal car. Two photoelectric sensors (mounted only 1 meter distance from each other) are connected on two digital inputs of the PLC. The PLC measure the time that the car needs to ride from sensor 1 to the sensor 2.

For instance the car needs 100 millisecond between sensor 1 and sensor 2. The PLC calculated the distance (m) divided by the time (sec), what gives 1 meter divide by 0,1 sec x 3,6 = 36 km/h. But inside the car on the speed meter there was only +/- 12 km/h !

Other instance, when I’m driving 50 millisec. between the 2 sensors the PLC calculate 72 km/h but inside the car on the speed meter it was only 30 km/h.?

I do not need a big accuracy but these differences between what I read inside the car and calculated by the PLC are too big – I think it is a principal problem o_O.

Does someone have an idea ?

Thanks and best regards.
 
To get any meaningful help you will need to give the following information:

The precise PLC type

The input type on the PLC

The exact model number of the sensors

A program listing showing the acquisition of the signals and the math.
 
What is the scan time of your PLC?
Should be shorter than 100ms, but probably near it. If you use normal IO your result may vary a lot due to the scan time. You should do this with fast I/O

=====================================
Edit: I didn't see the post of Mr. Carlton, of course this is from where you should start
 
Doesn't the car have a GPS, if not add one.
A lot simpler and MUCH cheaper too. :)

But then you wouldn't get your homework done, eh? ;)
 
As you are trying to make some kind of discretisation, you have to start from somewhere. Ther is a theorem for the discretisation that says "discretisation frequency(i.e. speed) should be at least two times hire than the higher frequency in the signal"
Let's say you want to achieve +/- 1 km. accuracy. If you want to have measuring range from 0 to 50km(you said 36), this means 50km. +/-1, you have to achieve measurement at about 3msec. And to be accurate concerning the Shannon's theorem mentioned above you have to reach speed twice higher - about 1.5msec. But if you are studying PLCs you should know that there is some difference between this speed and the PLC's scan time.
Of course you could increase the distance between the sensors. And by the way, for accurate measurement you should consider even the responce time of the sensor.
=================================
Edit: The GPS idea is not so bad.
 
Last edited:
Does someone have an idea ?
1. Move the photosensors as far apart as possible.
2. Set each sensor at the same exact height and aim each exactly horizontally level.
3. Drive slow, so that the longer time helps offset the scan-time error.
4. Use an adjustment factor to offset the scan-time error, the photosensor switching-time error, the car speedometer error, and any other unknown errors. Start with Actual Speed = 0.38 X Calculated Speed, and adjust by trial-an-error until you get consistent results.
 
Last edited:
Thanks all for your replies.

My question is more a philosophy question how to measure with to sensors and to get some accuracy.
The accuracy is not so important but 70 km/h calculated in the PLC and 30 km/h is a little too much for understanding...o_O

The question is not really about the PLC himself; it is a Siemens S7-1200 with a scan time from +/- 10 millisecond (with full program).
The response time on the sensors is also not important because I have 2 sensors and each sensor have identically the same response time – and goes in the same CPU with the same scan time.

Maybe the real problem is that the 2 sensors are to close, only 1 meter. Like Lancie1 write I was also thinking on a adjustment factor to offset the scan-time error. Maybe this factor can also be variable in function off the measured time between the two sensors.

Thanks all
 
How are you calculating the speed? It could be you are measuring from the rising edge when first sensor goes ON to the falling edge when second sensor goes OFF. Over a 1 meter distance that will introduce a large error.

You should measure from when the first sensor FIRST goes ON (rising signal edge) to to when the second sensor FIRST goes ON (rising signal edge). In other words, the first sensor should START the timing, and the second sensor should STOP the timing when its contact goes from off to on.
Maybe the real problem is that the 2 sensors are to close, only 1 meter.
Yes, a longer distance will offset many errors in the calculation. Also, don't forget that the photosensor aiming points in this case is very critical. If the first sensor detects the windshield of the car, but the second detects the front bumper, that will make your car look much faster than it was.
 
Last edited:
I hope the sensors are DC as AC sensors introduce a lot more uncertainty.

He's actually seeing too short of a time interval, not too long.

Is the time interval seen consistent from one run to another at the same speed?
 
Last edited:
1m/s is 3.6km/h is close to stepping speed.
suppose car is moving 36 km/h time is 0.1 second.
looptime is 0.01 sec.
so you indication should be between 32.4 and 39.6 km/h that is a big difference, you can only use longer distance to get better accuracy.
as the loop is a factor here you might want to try interrupt inputs and the clock (now()in codesys))
another way is with a fast counterinput and a 555 timer
a PLC is just not fast enough for this type of measurement, have a look at a arduino for better results.
 

Similar Topics

Hello, I'm trying to understand a servo motion system. I want to know the motor speed in RPM at a given speed setpoint entered in a MAJ...
Replies
4
Views
2,278
Hello First this ia really great site. Glad i found it. Here is my question. I need to calculate the full speed of a driven auger that is...
Replies
15
Views
5,254
hi I want to calculate speed rotation (RPM) with Omron PLC using a optical or proximity sensor. Thank You in advance
Replies
12
Views
9,599
Gear Reduction Box = 3.0 Drive Sprocket = 22 Teeth Driven Sprocket = 88 Teeth VFD = PowerFlex 40 I have a VFD controlling the speed of a...
Replies
25
Views
29,699
Hi, I am looking for a little help. I currently have an old Telemecanique TSx 17 that I need to replace. I am looking at installing an AB...
Replies
6
Views
2,517
Back
Top Bottom