LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

!! Arduino Uno + HC-SR04 Ultrasonic sensor + labview Help!!

Solved!
Go to solution

I have successufully make interface with the HC HR04 to the labview. I have used LINX tool to acuire data from sensor.Here i am also adding vi file for same.

Thanks.

0 Kudos
Message 51 of 72
(9,148 Views)

Hello Nathan.

I have installed 2.2.0.79 LIFA. I've also gone to File, Open. Go to "C: \ Program Files \ National Instruments \ LabVIEW 2011 \ vi.lib \ LabVIEW Interface for Arduino \ Firmware \ LIFA_Base" and LIFA_Base.ino open. and I will compile correctly.

My program in arduino 1.0.5 is:

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int trigger=8;

int echo=9;

float pulso, cm;

void setup(){

  pinMode(7,OUTPUT);//electrovalvula de llenado

  pinMode(6,OUTPUT);

  Serial.begin(9600);

  pinMode(trigger,OUTPUT);

  pinMode(echo,INPUT);

  lcd.begin(16,2);

void loop(){

    digitalWrite(7,HIGH);

    delayMicroseconds(5);

  digitalWrite(6,HIGH);

  delayMicroseconds(5);

  digitalWrite(trigger,LOW);

  delayMicroseconds(5);

  digitalWrite(trigger,HIGH);

  delayMicroseconds(10);

  digitalWrite(trigger,LOW);

   pulso= pulseIn(echo, HIGH);

   cm = pulso / 29 / 2;

  lcd.setCursor(0,0);

  lcd.print("dist:");

  Serial.println(cm);

  lcd.setCursor(5,0);

  lcd.print(cm);

  delay(1000);

}

In labview 2011:

1.PNG

But when I test, the value of the distance varies very fast for a few seconds and then stays at 10cm.

3.PNG

Also, I have installed the LINX.

4.PNG

I installed in Labview2011->tools->LabView Hacker->LINX->

5.PNG

But the problem persist. Please your support.

Thanks.

0 Kudos
Message 52 of 72
(9,148 Views)

You cannot use your Arduino code directly when you are using either LINX or LIFA.  Also, the LabVIEW code that you have shown in the image is not a valid program for either LIFA or LINX.

I would recommend that you stick with LINX and first make sure that you can get the example program to work (for blinking the LED).  Then, once you have control of the LED, take a look at the code for that example and base your new code on that example.

If you run into issues while using LINX, please start a thread in the LINX forum.

0 Kudos
Message 53 of 72
(9,148 Views)

I need help, How to add code in labviewinterface.pde file?I want to use Sonar Hc-S04 with Arduino Uno interface with Labview2014, the problem is that how i can implement "Inpulse" function in labview (that can check Echo HIGH state and then counts until the pin goes LOW) or how to use Arduino code of Sonar with labview....please help me,

0 Kudos
Message 54 of 72
(9,148 Views)

LINX has the SR04 already implemented.  Otherwise, you can look at the modifications that I made to LIFA for that sensor here.

0 Kudos
Message 55 of 72
(9,148 Views)

Hello, I have do all the steps, but I got this error.
can anyone help me to solve this problem ?lifa.PNG

0 Kudos
Message 56 of 72
(9,148 Views)

If you are using an Arduino Uno then you need to use the default baud rate

of 115200. If using the mega, you need to specify that in addition to

having the 9600 basis rate.

Also, check out the documentation for that error.

0 Kudos
Message 57 of 72
(9,148 Views)

Mr.Nathan, i have seen you in LVH forum, yeah you right that in LINX have a ultrasonic sensor, and it works greatly.
but I need to use a ultrasonic sensor and servo in the same time, and Mr.Sam have said 'Servo is high into the linx, so the servo won't available in linx in a few next month / year ( he said he need more time to think ).
So, I changed from using LINX back to LIFA.
but until now I have a problem to using ultrasonic sensor to LIFA. can you help me ?

0 Kudos
Message 58 of 72
(9,148 Views)

visa.PNGHello Mr.Nathan, i'm using arduino uno. andi used 9600 baudrate because in VISA the baudrate is 9600, and I dont know how to change that to 115200. so what i do is change the baudrate in IDE to 9600 and then using 9600 in labview.

is there something wrong in what i have done so makes that labview can't work ?

0 Kudos
Message 59 of 72
(9,148 Views)

The firmware that is deployed to the Arduino is hardcoded to use 115200 so you must use that.  I've never had to change the baudrate in Device Manager or MAX (I've never even looked at MAX for Serial ports; in fact, I didn't even know until recently that they existed in MAX lol).

If 115200 doesn't work then you should change the baudrate of your Serial port (through max or device manager; in both cases, it's on the "Port Settings" tab).  If you can't or don't see the "Port Settings" tab, then you might not have administrator permissions.

0 Kudos
Message 60 of 72
(9,148 Views)