06-26-2015 02:28 PM
Hi Everyone,
My program has to calculate the speed of passing vehicles based on interrupting the connection between the two IR transmitters and receivers. Also program has to count the number of passed vehicles. Devices are plugged into the Arduino UNO, and i use a LINX to connect Arduino to LabVIEW. The program detects infrared waves intervals but I don't know how to calculate the time between the termination on one wave and the other to calculate the speed. Distance between two sensors is permament. Please give me some suggestions.
06-29-2015 03:37 AM
Hi!
As far as I understand you problem, you could successfully detect the pass on each sensor but you need help in measuring time.
In order to do this you have to get a timestamp, when the car passed the first sensor, then another when the secon sensor signal, then subtract the values.
In order to get time I suggest using the Tick Count (ms) VI. Detailed description:
http://digital.ni.com/public.nsf/allkb/6F6B9F4E149C80578625652800784764
In order to remember the value through loop iteration you can use shift registers:
http://www.ni.com/getting-started/labview-basics/shift-registers
I hope this helps,
András Bükkfejes
National Instruments
06-29-2015 08:19 AM
LINX is fairly slow and uses asynchronous communications so make sure the sensors are far enough apart that the timing latency and jitter due to communications does not introduce unacceptable errors.
Lynn
06-29-2015 08:27 AM
I would change the code in the Arduino to do all of the calculations for you and just pass the needed information up to the LabVIEW interface via the serial port. The arduino on its own will have a lot better resolution than reading the sensors with the Arduino, sending the data via the serial port, and reading in the PC application. So in the end, the Aruino does all of the heavy work and then just pass the speed and number of vehicles passed up to LabVIEW.