From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-01-2016 08:03 AM - edited 08-01-2016 08:05 AM
Hi,
Sorry in advanced if this isn't the most suitable forum. I'm not entirely sure whether this was a more general "software" problem or specific to the MyRIO. I have searched the forums and have found a few related topics but could find none that help me in this context.
I am trying to measure the pulse width of an ultrasonic ping sensor. It outputs a conditioned signal - the time it is high directly corelates to how far away the object is. Being new to LabVIEW I'm confused as to how I should calculate the time it remains high.
I've read that LabVIEW shouldn't need "variables" like in python or C, so what is the best way of measuring the time the signal is high? Normally I would go (new_time - old_time) but obviously I can't store an old time in LabVIEW like I would in python or C.
Other notes:
I've got the ping sensor echoing properly and I can display the echos on a chart and see a perfectly valid square wave.
Solved! Go to Solution.
08-01-2016 10:53 AM
Don't worry, I've ended up using an arduino to do the data collecting. It then pipes it over UART to the MyRIO. I can grab the distance in cm with a single line and the NewPing library on the arduino.
08-01-2016 11:43 AM
To answer your question about how you would do it in LabVIEW...
While LabVIEW doesn't have declared/named variables like you have in a text-based language, data is stored on the wires. You can use nodes like the feedback node or shift registers to store values between iterations of a loop:
(this will keep subtracting y (starting with 0) and store the result for the next time it runs)
LabVIEW also has functions in the maths/signal processing palette for doing pulse width detection on a waveform.
08-01-2016 01:46 PM
Thanks heaps, I think the notion of Feedback Nodes (and potentially shift registers) is what I was missing.
08-29-2017 09:05 AM
how to create measure the pulse and counting
08-30-2017 11:16 AM
I'm not sure exactly what you are asking, but we do have pulse width examples in NI Example Finder (Help tab >> Find Examples). The PWM Measurement.lvproj example shows you how to measure a digital input signal and calculate the time the signal is high or low.