Ultrasonic Distance Sensor
Because there has been several requests for different ultrasonic distance sensors, I decided to make an all inclusive library for the ones that use similar communication protocols. These sensors require a trigger pulse and then the use of the Arduino pulseIn() function to measure the length of the output pulse. This requires custom LIFA firmware which is provided with the library.
Supported sensors:
DYP-ME007
HC-SR04
Parallax PING)))
SRF04
SRF05
US-100
I'm not able to test all of these sensors so please post to let me know if you are able to get them working. If they don't work, please also let me know so I can get them fixed.
Note: This document was formerly specifcally for the Parallax PING))).
Nathan_B thanks for your help on this Interface, I have a question, Do you have any post or tutorial where I can found a guideline on how to modify the firmware to create my new functions for the Arduino code? I would really appreciate any guiadance ond this issue. Thanks for your time. Daniel
I don't believe that I've seen any specific guide for creating custom functions but what I recommend is to duplicate and existing function (e.g. Digital Write Pin) with a new command number in 0xF1 range (any number that doesn't currently exist in the main switch statement). Then, I test to make sure that I've got that working as it was original meant to work. Then, from there, I add code to customize for my particular application. There is quite a bit you can learn by digging down into the existing functions and their associated VIs.
If you have issues you can simply post in the discussion section and someone will likely help you out.
Hey Nathan, I'm having trouble with the vi.
I downloaded the zip file, extracted it, and downloaded the new arduino sketch into my Uno. Then I opened the ping example vi, and set the arduino resource to my proper com-port.
When I run the vi, the Rx blinks. In the get ping distance vi, i get the error message "Get Ping Distance.viLabVIEW Interface for Arduino.lvlib:Init.vi. A timeout occurred while trying to read form the Arduino."
I think I'm missing a step. I then tried to run the SetPin2vi you gave me and that still works. I am using the "Arduino firmware" you gave us in the zip file for both vi's.
I'm still too green to trouble shoot, do you have any ideas as to why the this vi isn't working for me?
The only thing that I can think of right now is that the firmware did not get uploaded correctly. Otherwise, I'm not really sure. Does the Init VI work fine? Try running it with execution highlighting and watch the block diagram to see if you can get anymore clues.
hola nathan un saludo desde mexico queria saber si me puedes ayudar para la medicion de distancia con un sensor ultrasonico hy-sfr05 he descargado el zip cargado en el arduino el correspondiente LIFA y al ejecutar el ejemplo de sr05 no me funciona en la grafica solo me aparece una linea no logro medir distancia me ayudaria mucho que me contestaras
As far as I can tell, that sensor should work exactly the same as the SRF05. Are you sure you uploaded my custom firmware? Is it all wired correctly? With more details, I can't really help much more.
gracias por tu respuesta rapida ya logre medir distancia con los archivos que subiste lo que me hacia falta era agregar la libreria ultrasonic.h en arduino bueno despues de hacer eso ya no tube problemas ahora mi problema es¿ como le podria hacer para conectar 4 mas de estos sensores? ¿y medir la distancia de cada uno de ellos al mismo tiempo? ¿copio el diagrama de bloques y cambio los pines de echo y trigger segun los conecta a mi arduino?
Please Mr. Nathan How to upload the firmware.
Thanks
Charbel
You upload the firmware in the same way that you would the original firmware but instead of the original firmare folder, you use the one that I have provided.
chitus, de donde descargaste la librerira ultrasonic.h, sería de mucha ayuda tu respuesta, tengo tu mismo problema.
Works perfect with HC-SR04 with Arduino Mega board, thank you so much, I tried a few other vi that I found in the forums and none of them worked. Thank you.
CHITUS!!! donde agrego la libreria ultrasonic.h??? en que parte del arduino???
Where do I add the ultrasonic.h library???
This does not use that library. Also, you should switch to LINX since it has support for this sensor natively.
Where should i put the extrated folder in? Should i replace it with the original LIFA folder or i just need to extrat it on desktop?
You should replace it with the old lifa filder
Sent from my HTC
You can put the folder anywhere you want but you will want to put it somewhere that you won't have to move it later. You then compile it with the Arduino IDE and upload it.
Because I don't know how VI packages handle custom content in folders created by the package, I would probably not put it in the "vi.lib/LabVIEW Interface for Arduino" folder at all.
thanks for the reply.... can i ask a few more questions?
1)why is the byte to read set to 4? How to get that value and what it does?
2) why is the trigger length set to 10?
3) why divide it by 58 to get the distance? instead of 29 or something else..
sorry for silly questions... i just got into this thing yesterday...
Hello, hope you are fine.
Don't worry, it's good to ask.
Some of NI have built this LIFA, and frankly our team didn't go deep into the details. We have just used the VI.
Thank YOU!
Take a look at the datasheet of your sensor and you might find some of these numbers in there. It's been a long time since I wrote these functions so I can't remember how much information was obtains from the datasheet or from other sources. However, you can probably find a bunch of information about the sensor online if the datasheet does not provide the needed information.
thank you once again Mr.
by the way, your VI is working great..
Hey i got stuck while using above program. I have succesfully communicate arduino with Labview with Blink example. While performing this example with HC-SR04, labview showing error number 5003. Please help to read Distance with help of HC-SR04 in labview.
remember that the formula for an ultrasonic sensor tells you that the distance in centimeters is : time(microseconds)/29/2 that is the same to :time(microseconds)/58
It really works for the HCSR04, THANKS!!! Nathan...very useful your library!!!
how is it???
How is what?
how to install this library??
Mr. Nathan
Can pulse widht at ultrasonic distance sensor used in pulse widht water flow sensor output yf-s201?
thanks.
although the last post is last year, i hope any reply and solution for my question please..
i have read all the comment for this...and i've try the step..comunnication from arduino to labview fine...but when i try get distance the error 5003...can anyone help please
I'd recommend upgrading to LINX since it has the function already built-in.
http://www.labviewhacker.com/linx
Hey Mr. Nathan_B,..how are you...?
Can you help me.
I any problem on my experiment. My project is " Get distance with Arduino Uno and HC SR04 and LabVIEW. The problem...that is :"D:\Arduino IDE\Arduino\libraries\Robot IRremote\IRremote Tools.cpp:5: error: 'TKD2' was not declared in this scope"
What the solution for is ?
Thk...
Hi miftaarif,
I have had the same problem as you. I have solved it by loading the LIFA_Base.ino with the Arduino IDE 1.0.5.
I hope that solves your problem.
Hello Nathan,
I am not able to run the .vi.I am getting the cross block.Is it right?
Hello,
can anyone tell me which version Arduino IDE compile modified Nathan_B IFA Ultrasonic Distance LV9.zip ?
Why I have this compiling error?
IDE 1.0.5 r2 report error
LIFA_Base.ino: In function 'void processCommand(unsigned char*)':
LIFA_Base:225: error: 'class TwoWire' has no member named 'write'
........
I don't remember. However, since I updated this in 2013 last, it should compile fine with 1.0.5. Maybe try downgrading to 1.0.5 or earlier (but stay above 1.0.1).
But, if you have a PING))), HC-SR04, or a GH-311 then you should use LINX because they are already supported (no modifications necessary to use them).
hii
can any bod help me find a urm37 labview code for MyRio please ??
As I can see in doc. this device have DAC output Analog voltage output ( each 6.8mV represents 1 cm )
in this case you have to connect this pin to MyRio ADC channel and measure voltage 1cm = 6,8mV
try to use any example reading ADC channel and that's it.
Hi Nathan_B can you please help me to design a labview circuit which will be measuring displacmenet of ultrasonic sensor using usb port 6009?
I want to ask how the program description of the functions that are used to make costumes sub-vi of the ultrasonic sensor?
I want to ask how the program description of the functions that are used to make costumes sub-vi of the ultrasonic sensor?
Excuse me I need to know how can I add the block corresponding to the HC-SR04 sensor to my sensors list, and I have a problem when trying to excute the code in labview I am having the error because of timeout, I am using the same baude rate of the lifa but I don't know if you can help please.
That HC-SR04 is natively supported by LINX (http://www.labviewmakerhub.com/linx) which is the replacement for LIFA.
I already have linx, but I don't like to work with it, I need to know how can I create the subvi of the ultrasonic sensor, If you can help me in that.
LIFA is no longer supported. LINX is actually very similar when it comes to the LabVIEW VIs and it is faster than LIFA. If you are having issues with LINX, you should post your issue on the LINX forums.
As for your question, I don't know what you are asking. A subVI is provided in this document (in the zip file) to be used with the firmware that is also in the zip file.
Actually I saw the vi in the zipfile but when I want to excute the code in labview it giving error 5003
Because LIFA is so old, it's been too long since I've used it to try and debug your issue. This is why I highly recommend upgrading to LINX, especially since this sensor is supported natively (no modifications required). Also, IIRC, the firmware that I used for this sensor might not be the latest version of LIFA so it's possible that that is causing issues.
it is so easy using linx but my problem is that I need to use other sensors that are not found in linx and are found in arduino interface so when connecting these blocks two blocks I get an error, is there any way to combine these blocks to work normally?
What sensors are you using that aren't supported by LINX?
What two VI's are you referring to? Where does the error occur in your
code?
You should create a thread in the discussions and attach your VI.
I have no fault, fix the problem with LYNX. But, I want to program with LabView Arduino library. Thank you
Date: Thu, 1 Oct 2015 09:14:35 -0500
From: web.community@ni.com
To: bjlcm_71@hotmail.com
Subject: Re: - LIFA Ultrasonic Distance Sensor
NI Community
LIFA Ultrasonic Distance Sensor
comentario nuevo por Nathan_B. Ver todos los comentarios en este documento
What sensors are you using that aren't supported by LINX?
What two VI's are you referring to? Where does the error occur in your
code?
You should create a thread in the discussions and attach your VI.
Responda a este correo electrónico para responder al comentario de Nathan_B..
Its very simple BUT you need a hardware betwee the computer running labview
From: bjlcm <web.community@ni.com>
To: barddya <barddya@yahoo.com>
Sent: Thursday, October 1, 2015 8:23 AM
Subject: Re: - LIFA Ultrasonic Distance Sensor
|
|
NI Community |
|
LIFA Ultrasonic Distance Sensor new comment by bjlcm View all comments on this documentI have no fault, fix the problem with LYNX. But, I want to program with LabView Arduino library. Thank you Date: Thu, 1 Oct 2015 09:14:35 -0500From: web.community@ni.comTo: bjlcm_71@hotmail.comSubject: Re: LIFA Ultrasonic Distance Sensor - LIFA Ultrasonic Distance Sensor NI Community LIFA Ultrasonic Distance Sensor comentario nuevo por Nathan_B. Ver todos los comentarios en este documento What sensors are you using that aren't supported by LINX? What two VI's are you referring to? Where does the error occur in yourcode? You should create a thread in the discussions and attach your VI. Responda a este correo electrónico para responder al comentario de Nathan_B..Reply to this email to respond to bjlcm's comment. |
Please can you guide me using the Arduino library.
I have one and the Arduino sensor HC-SR04.
Date: Thu, 1 Oct 2015 18:32:18 -0500
From: web.community@ni.com
To: bjlcm_71@hotmail.com
Subject: Re: - LIFA Ultrasonic Distance Sensor
NI Community
LIFA Ultrasonic Distance Sensor
comentario nuevo por barddya Ver todos los comentarios en este documento
Its very simple BUT you need a hardware betwee the computer running labview
From: bjlcm <web.community@ni.com>
To: barddya <barddya@yahoo.com>
Sent: Thursday, October 1, 2015 8:23 AM
Subject: Re: LIFA Ultrasonic Distance Sensor - LIFA Ultrasonic Distance Sensor
|
NI Community |
LIFA Ultrasonic Distance Sensor
new comment by bjlcm View all comments on this documentI have no fault, fix the problem with LYNX. But, I want to program with LabView Arduino library. Thank you Date: Thu, 1 Oct 2015 09:14:35 -0500From: web.community@ni.comTo: bjlcm_71@hotmail.comSubject: Re: LIFA Ultrasonic Distance Sensor - LIFA Ultrasonic Distance Sensor NI Community LIFA Ultrasonic Distance Sensor comentario nuevo por Nathan_B. Ver todos los comentarios en este documento What sensors are you using that aren't supported by LINX? What two VI's are you referring to? Where does the error occur in yourcode? You should create a thread in the discussions and attach your VI. Responda a este correo electrónico para responder al comentario de Nathan_B..Reply to this email to respond to bjlcm's comment.
Responda a este correo electrónico para responder al comentario de barddya.