LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino read write serial interface

Hello every one ...  I am working recently on a read write serial communication with Arduino via LabVIEW. At the beginning Arduino asks like that " Please enter the value of Latitude" and I type a value of a certain latitude ( like 33) and then it askes for longitude "Please enter the value of Longitude" , I type a value of longitude ( like 44) but what happend the labview sends 33 to the arduino and does not send the another value (44) , so the Arduino takes (33) for both latitude and longtude unlike what I want so what is the problem. the block digram shown below . thanks to every one tries to help me Heart

lv block.jpg

0 Kudos
Message 1 of 17
(8,132 Views)

And this is the front panel.
lv front.jpg

0 Kudos
Message 2 of 17
(8,128 Views)
Your code makes no sense. You are constantly sending the same data until you manually change the front panel control. How can the arduino possibly know the difference between a latitude or longitude? Append a prefix or combine the two values, separated by a comma, and terminated with a cartridge return or line feed. The arduino would parse the data it receives. Don't constantly send. Use an event structure to send only when you click a Boolean. I don't know what you mean by 'arduino asks'. The read you have does nothing and you are improperly using Bytes at Serial Port.

Look at the arduino Linx toolkit.
Message 3 of 17
(8,121 Views)

Look I am new with LabVIEW and Iam just made this from videos that avialable on you tube . but the arduino works perfect with Arduino IDE serial monitor, what I meant with arduino asks is that, arduino requests from the user to enter the Latitude, the user types the value of latitude and presses enter botton to send it to Arduino and then the Arduino requests the value of Longitude, the user does same. It is a project about sun tracking through sun-earth  geometrical relationship. 

The image below shows how it looks like with Arduino IDE's serial monitor.

A2.jpg

0 Kudos
Message 4 of 17
(8,097 Views)

Not too bad for having learned off videos!

 

The issue is that the VI will send the content of the "write" control to the serial port every 1 second regardless of what the Arduino does.  Are you sending the "Enter the ...." strings over serial from the Arduino?  If so, have the LabVIEW while loop poll the serial port.  Based on the string received from the Arduino, you can wire that to a CASE structure to send (write) an appropriate value back to the Arduino.  

 

The tricky part is making sure you get the whole string ("Enter the Latitude" for instance).  When LabVIEW reads the port it may only get "Enter th" and you have to add the next read to it to get the whole string so that you can execute the correct CASE.

Message 5 of 17
(8,078 Views)
But there is no indication that you are reading and responding to any text from the arduino in the LabVIEW VI. As I said, you are just constantly sending the same value over and over again. If the arduino is truly sending a request, your VI has to do a read first, parse the data, and then write. Write the program to do what the monitor and you do manually.
Message 6 of 17
(8,071 Views)

It is very helpful if any one of you my friends provide me with a code or block diagram . thanks Smiley Happy

0 Kudos
Message 7 of 17
(8,043 Views)

To be able to make a LabVIEW program to talk to your Arduino, you need to show how the code is written in the Arduino.

 

How does the Arduino send out serial data?

What format does to expect to receive?

 

It is only you how knows this.

 

There are tons of post about talking to an Arduino, have you tried to look a them for tips and tricks?

Message 8 of 17
(8,033 Views)
Look at the arduino community and Linx - https://decibel.ni.com/content/groups/labview-interface-for-arduino

There are numerous on-line tutorials here on the NI site. Mostly though, you need to write the arduino sketch in a better fashion.
Message 9 of 17
(8,021 Views)

This is  a part of the Arduino codes that I made just for entering the values of Longitude and Latitude and there is no need to show the whole codes cus it is for moving a motors to the desired location depending on sun -earth geometry .

float latitude, longitude;
float result;
boolean printed;
int state;

void setup()  
{
  Serial.begin(9600);
}
void loop()  
{
  if (state == 0)
  {
    if (!printed) Serial.println(F("Enter the Latitude"));
    printed = true;
    if (Serial.available())
    {
      latitude = Serial.parseFloat();
      Serial.print(F("Latitude = "));
      Serial.println(latitude);
      printed = false;
      state = 1;
    }
  }
  else if (state == 1)
  {
    if (!printed) Serial.println(F("Enter the Longitude"));
    printed = true;
    if (Serial.available())
    {
      longitude = Serial.parseFloat();
      Serial.print(F("Longitude = "));
      Serial.print(longitude);
      printed = false;
      state = 2;
    }
  }
  else if (state == 2)
  {
    // the complement of the codes that depends on the values of Longitude and Latitude 
  }
}

 

0 Kudos
Message 10 of 17
(8,014 Views)