11-14-2014 02:38 PM
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 ![]()
11-14-2014 02:41 PM
And this is the front panel.
11-14-2014 02:50 PM
11-14-2014 11:53 PM - edited 11-15-2014 12:00 AM
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.
11-15-2014 01:05 AM
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.
11-15-2014 01:13 AM
11-15-2014 10:58 AM
It is very helpful if any one of you my friends provide me with a code or block diagram . thanks ![]()
11-15-2014 11:20 AM
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?
11-15-2014 11:54 AM
11-15-2014 11:59 AM - edited 11-15-2014 12:00 PM
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
}
}