Speed/time measurement


Recommended Posts

I want to measure the speed of an object. The object passes two optical sensors, causing the output of the sensors go from high (~10 Volts) to low (~0 Volts) and back again.

In order to measure the speed I would like to measure the time between the two respective falling edges of the signals coming from the two sensors. I want to start the measurement at the first falling edge and stop it at the second falling edge. In the worst case the time between the two edges is extremely short, i.e. some microseconds.

I am thinking to measure/count the clock pulses between the two events, or perhaps count the number of data points, providing that I can measure and record at a very high sampling rate.

Does anyone have an idea how to achieve this?

Link to comment
Share on other sites

First what hardware are you using?  If you are using a LabJack you can use on of their timer modes to achieve this, though you may need to add a latching circuit, something so that the first sensor latches the output high, then the second sensor brings it back low.  But the folks at LabJack will know how best to do this hardware wise.

You won't be able to do this without using a hardware mode due to the extremely short time frame.

Link to comment
Share on other sites

We support line-to-line timer features for both UD and T-series devices that should be able to achieve your goal. Please see the documentation for your given device below and let us know if we can help with anything further.

For UD devices:

https://labjack.com/support/datasheets/u3/hardware-description/timers-counters/timer-mode-descriptions/line-to-line-measurement

For T-series devices:

https://labjack.com/support/datasheets/t-series/digital-io/extended-features/line-line

Link to comment
Share on other sites

Thanks for the fast reply.

I plan on using a Labjack U6. I am happy to read that it should be possible to measure such short intervals. 

I am going to try to follow the Labjack tutorials on this topic. At first glance it seems rather complicated. So far I have only limited experience with DaqFactory.

Link to comment
Share on other sites

I have been experimenting with the Labjack U6. In the documents, the line-to-line measurement requires mode 14 for both timers. Unfortunately there are only 13 modes available in the mode menu of panel 'Configure Timers and Counters' of the U6 Test Panel.  The line-to-line measurement mode seems to be missing.

 

Link to comment
Share on other sites

Thanks for the support. I tried out the example you sent me.

I have connected my top sensor to FIO0 and my bottom sensor to FIO1.

When an object passes the top sensor, the time display stays at 0 seconds, which is good because the timer should now start at the falling edge produced by the top sensor.

When the object passes the bottom sensor, the display shows a very low value, even if the object (in this case my hand) passes the bottom sensor seconds after it passes the top sensor (see figure).

In fact, even if my hand only passes the bottom sensor, a value is shown (again a very low value). In this case the timer should not be started at all.

It seems that the timer is started by the bottom sensor (FIO1) and also stopped by the same sensor. It looks as if the time duration of the falling edge (from high to low) is measured and displayed.

image.png.8b11c3caa090857a95cd15bd5c0363be.png

 

Link to comment
Share on other sites

The issue may be to do with the maximum measurable time using your timer settings. As I had the example set up (using a 1MHz clock) the maximum time between edges is 65535/1000000 = 65ms and the resolution is 1/1000000=1 microsecond. There is a tradeoff between maximum measurable time and resolution depending on your timer clock frequency.

Note that you must update the global variable clockFreq if you update the timer clock settings. Our timer documentation and pseudocode have additional information about the line to line feature and available timer clock settings:

https://labjack.com/support/datasheets/u6/hardware-description/timers-counters/line-to-line-measurement

https://labjack.com/support/datasheets/u6/high-level-driver/example-pseudocode/timers-counters

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share