LabVIEW Interface for Arduino Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LIFA Ultrasonic Distance Sensor

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))).

Comments
piperj3
Member
Member
on

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

Nathan_B.
Active Participant
Active Participant
on

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.

BryanFury9000
Member
Member
on

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?

Nathan_B.
Active Participant
Active Participant
on

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.

chitus
Member
Member
on

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

Nathan_B.
Active Participant
Active Participant
on

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.

chitus
Member
Member
on

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?

ctawk
Member
Member
on

Please Mr. Nathan How to upload the firmware.

Thanks

Charbel

Nathan_B.
Active Participant
Active Participant
on

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.

mosomi_36
Member
Member
on

chitus, de donde descargaste la librerira ultrasonic.h, sería de mucha ayuda tu respuesta, tengo tu mismo problema.

Jbricenoo
Member
Member
on

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.

blackandblue93
Member
Member
on

CHITUS!!! donde agrego la libreria ultrasonic.h??? en que parte del arduino???

Where do I add the ultrasonic.h library???

Nathan_B.
Active Participant
Active Participant
on

This does not use that library.   Also, you should switch to LINX since it has support for this sensor natively.

jijer0711
Member
Member
on

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?

ctawk
Member
Member
on

You should replace it with the old lifa filder

Sent from my HTC

Nathan_B.
Active Participant
Active Participant
on

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.

jijer0711
Member
Member
on

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...

ctawk
Member
Member
on

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!

Nathan_B.
Active Participant
Active Participant
on
  • We have to read 4 bytes because we need to read a 32-bit (4-byte) integer that contains the pulse width (the sensor output).
  • The trigger length (10us for some of the sensors) is dependent on the sensor and what it requires to start an acquisition.
  • 58 is a conversion factor to convert from microseconds to centimeters (this is based on the sensor's output signal).  If you need different units, simply take the output (centimeters) and convert it to the unit of length which you need or prefer.

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.

jijer0711
Member
Member
on

thank you once again Mr.

by the way, your VI is working great..

chirag3993
Member
Member
on

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.

P51MUSTANG
Member
Member
on

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

P51MUSTANG
Member
Member
on

It really works for the HCSR04, THANKS!!! Nathan...very useful your library!!!

aleex
Member
Member
on

how is it???

Nathan_B.
Active Participant
Active Participant
on

How is what?

zangetsuredinso
Member
Member
on

how to install this library??

u-man
Member
Member
on

Mr. Nathan

Can pulse widht at ultrasonic distance sensor used in pulse widht water flow sensor output yf-s201?

thanks.

FaizalRiezky
Member
Member
on

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

Nathan_B.
Active Participant
Active Participant
on

I'd recommend upgrading to LINX since it has the function already built-in.

http://www.labviewhacker.com/linx

miftaarif
Member
Member
on

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...


horacinho
Member
Member
on

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.

sonu26
Member
Member
on

Hello Nathan,

I am not able to run the .vi.I am getting the cross block.Is it right?Capture.JPG

NikolaB
Member
Member
on

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'

........

Nathan_B.
Active Participant
Active Participant
on

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).

mohammadali7
Member
Member
on

hii

can any bod help me find a urm37 labview code for MyRio please  ??

NikolaB
Member
Member
on

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.

Behnam00170
Member
Member
on

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?

Anonymous49
Member
Member
on

I want to ask how the program description of the functions that are used to make costumes sub-vi of the ultrasonic sensor?

Anonymous49
Member
Member
on

I want to ask how the program description of the functions that are used to make costumes sub-vi of the ultrasonic sensor?

zuzu12
Member
Member
on

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.

Nathan_B.
Active Participant
Active Participant
on

That HC-SR04 is natively supported by LINX (http://www.labviewmakerhub.com/linx) which is the replacement for LIFA.

zuzu12
Member
Member
on

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.

Nathan_B.
Active Participant
Active Participant
on

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.

zuzu12
Member
Member
on

Actually I saw the vi in the zipfile but when I want to excute the code in labview it giving error 5003

Nathan_B.
Active Participant
Active Participant
on

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.

zuzu12
Member
Member
on

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?

Nathan_B.
Active Participant
Active Participant
on

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.

bjlcm
Member
Member
on

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..

barddya
Member
Member
on

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.

bjlcm
Member
Member
on

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.

Contributors