Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Myrio ultrasonic

Dear NI Community,

 

I am a student majoring in mechanical engineering and I have a myrio project that utilises ultrasonic sensors.

 

Can please anyone help me in how i can make my ultrasonic sensors to work on myrio because i have tried a lot and nothing worked and the deadline is next week.

 

Any help is much appreciated !

 

Thank you for your time.

0 Kudos
Message 1 of 7
(6,417 Views)

You will need to provide much more information - specific values - if you expect to get any help.

 

Consider if someone asked you for help on a project which uses levers and told you that they had several rocks but nothing worked. You do not know the masses of the rocks or the lengths of the levers. You do not know what they were trying to move. You do not know the magnitude or directions of any forces involved.  You do not know whether the levers broke or did not move at all or moved too far. How would you help that person?

 

Lynn

Message 2 of 7
(6,398 Views)

Thank you for that !

 

I have two 4-pin ultrasonic sensors: RB URF02 and HC-SR04 and i am using myRIO as DAQ. Ive made a code on Labview to try and make them work. the code has many mistakes but the readings im getting are illogical to me and i need help in how to fix the code or make a new one altogether. I gave the trigger a low signal for 2 microseconds then high for 10 microseconds and waited 10 ms for the echo pin and then the loop repeats. On the graph im getting values that quickly alternate between 3 and 7 and it doesnt seem to respond logically to my hand moving away and closer to the sensor. The code i attached has a digital in from the myrio which is in turn attached to echo pin but i tried the analog signal outout also and nothing seemed to work.

 

If anyone can please send a code or any help !

0 Kudos
Message 3 of 7
(6,389 Views)

I do not have the myRIO drivers but there are several obvious difficulties with your VI.

 

1. The use of sequence structures in LabVIEW is discouraged. Use dataflow to control the order of execution.  Your code can do without it completely.

2. You have race conditions in three of the frames.  There is no way to determine whether the Time Delays will run before, after, or in parallel with the Digital Output VIs.  See the dataflow comment in 1.

3. The minimum timing resolution of the Time Delay Express VI is 1 millisecond.  This does not appear to be documented in the help except for a note about similar behavior to the Wait (ms) function.  If you open the front panel and then the block diagram of the Time Delay VI you will find that it uses Wait (ms) internally. So your delays in the first two frames are either zero or one millisecond, most likely zero.

4. If those ultrasonic transducers use the common 40 kHz frequency, your pulses are not long enough to be useful. At 40 kHz one cycle lasts 25 microseconds. The transducers may have a transient when first turning on that could last a few cycles.

5. This code will not work either because of the timing values but it shows how to eliminate the sequence structure.

 

No Sequence.png

 

Looking at the echo pin at one fixed timing point seems inappropriate unless you only want to know if the target is at a specific distance.  The 10 ms delay you mentioned represents 3.4 m in air and the 30 ms in your VI corresponds to ~10 m. 

 

Lynn

0 Kudos
Message 4 of 7
(6,384 Views)

Then how should i code to put microsecond delays if the minimum is milliseconds? or should i use milliseconds in coding instead of microseconds?

 

If that is the time one cycle takes then how do you suggest that i code to send the impulse triggers?

 

But if youre saying its 3.4 m in air then that means i should code for a smaller time interval?

 

Im sorry if I sound stupid in my questions but the software is very new to me and this project is 30% of my grade..

 

Thank you so much for your time.

0 Kudos
Message 5 of 7
(6,379 Views)

You cannot do software timing at microsecond intervals. There may be a way to use the myRIO hardware to do it, but I do not have that so I do not know. 

 

The speed of sound in air is approximately 343 m/s. So a sound will travel about 3.4 meters in 10 milliseconds. If you are doing an ultrasonic project, I would have thought that you would have done those calculations before you started wiring sensors or writing code.

 

I would probably run the acquisition and the pulse generation in parallel. Use hardware timing for both the data acquisition and for the generation. Acquire both the transmitted pulse (or an attenuated version of it) and the reflected pulse in the same session. Then you can use the sample rate to calculate the time interval between the two pulses.

 

Lynn

0 Kudos
Message 6 of 7
(6,373 Views)

I did the vi for the sumo robot and deployed it as a real time application on the Myrio but the robot didnt do anything. I restarted the myrio (already had deployed the real time application VI) and it still did not do anything.

0 Kudos
Message 7 of 7
(6,338 Views)