LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lectura del puerto serial e impresion de datos

Solved!
Go to solution

Wire the ascii code for a comma into the termination character input of the Serial Configure.  Decimal 44 or hex 2C.

 

But it would be more logical to program it to send a linefeed character which is ASCII code decimal 10 or hex 0A.  The serial configure already defaults to linefeed as the termination character.

0 Kudos
Message 11 of 49
(1,748 Views)

Can you help me with an example? I got the idea about Arduino, but I'm new to using LabView, I owe you one for help me, thanks

0 Kudos
Message 12 of 49
(1,748 Views)

How can I wire the Property Node to just accetp the data that come from write "L" for example? 

0 Kudos
Message 13 of 49
(1,741 Views)
Solution
Accepted by topic author cesarjr.1991

@cesarjr.1991 wrote:

How can I wire the Property Node to just accetp the data that come from write "L" for example? 


I have no idea what you mean by this question.

 

Attached is a much simpler VI that will work.  You just need to program your Arduino to send the LF character at the end of every message it sends out.

0 Kudos
Message 14 of 49
(1,735 Views)

Really thanks! It works, but just for 10 seconds 😕 after that I have this problem.

help.PNG

0 Kudos
Message 15 of 49
(1,717 Views)

Did you change the code in your Arduino?  That message tells me you hadn't received the termination character.

 

A slightly better version of the VI that takes care of some missing wires and indicators.

0 Kudos
Message 16 of 49
(1,703 Views)

No my friend, I don't know what I have to change, and What is the mean of this " 100" in write block, this is my Arduino code, What I have to change?

 

 

#include "TinyGPS.h"
#include "DHT.h"

TinyGPS gps;

#define GPS_TX_DIGITAL_OUT_PIN 5
#define GPS_RX_DIGITAL_OUT_PIN 6
#define DHTPIN 22 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

char in,p,s,t,g;
int temp, hum, solenoide1=50,solenoide2=51,on,leer,cont;
long startMillis;
long secondsToFirstLocation = 0;

#define DEBUG

float latitude = 0.0;
float longitude = 0.0;
float alture=0.0;


void setup() {
#ifdef DEBUG
Serial.begin(9600);
#endif
dht.begin();
Serial3.begin(9600);

// prevent controller pins 5 and 6 from interfering with the comms from GPS
pinMode(GPS_TX_DIGITAL_OUT_PIN, INPUT);
pinMode(GPS_RX_DIGITAL_OUT_PIN, INPUT);
pinMode(hum,OUTPUT);
pinMode(temp,OUTPUT);
pinMode(solenoide1, OUTPUT);
pinMode(solenoide2, OUTPUT);

startMillis = millis();
Serial.println("Starting");
}

void loop() {
readLocation();
while(Serial.available() )
{

in =(byte)Serial.read() ;
if(in=='L')
{
Serial.print(latitude, 6);
Serial.println(" ");
}
else if(in == 'l'){
Serial.print(longitude, 6);
Serial.println("");
}
else if(in == 'a'){
Serial.print(alture, 6);
Serial.println("");
}
else if(in == 'T'){
temp = dht.readTemperature();
Serial.println(temp);
}
else if(in == 'H'){
hum = dht.readHumidity();
Serial.println(hum);
}
else if(in == 'p'){
digitalWrite(solenoide1, LOW);
digitalWrite(solenoide2, LOW);

}

else if(in == 's'){
digitalWrite(solenoide1, HIGH);
digitalWrite(solenoide2, LOW);
}
else if(in == 't'){
digitalWrite(solenoide1, LOW);
digitalWrite(solenoide2, HIGH);

}

}

}
//--------------------------------------------------------------------------------------------
void readLocation(){
bool newData = false;
unsigned long chars = 0;
unsigned short sentences, failed;

// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (Serial3.available())
{
int c = Serial3.read();
//Serial.print((char)c); // if you uncomment this you will see the raw data from the GPS
++chars;
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;
}
}

if (newData)
{
// we have a location fix so output the lat / long and time to acquire
if(secondsToFirstLocation == 0){
secondsToFirstLocation = (millis() - startMillis) / 1000;
Serial.print("Acquired in:");
Serial.print(secondsToFirstLocation);
Serial.println("s");
}

unsigned long age;
gps.f_get_position(&latitude, &longitude,&age);

latitude == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : latitude;
longitude == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : longitude;
alture=gps.f_altitude();
alture == TinyGPS::GPS_INVALID_F_ALTITUDE ? 0.0 : alture;

//Serial.print("Location: ");
/*Serial.print(latitude, 6);
Serial.println(" ");
Serial.print(longitude, 6);
Serial.println("");
Serial.print(alture, 6);
Serial.println("");*/


}

if (chars == 0){
// if you haven't got any chars then likely a wiring issue
Serial.println("Check wiring");
}
else if(secondsToFirstLocation == 0){
//still working
}
}

0 Kudos
Message 17 of 49
(1,697 Views)

Really thanks for everything man, really thanks! 

0 Kudos
Message 18 of 49
(1,690 Views)

You need to right the linefeed character wherever you send a response.

 

If you wrote the Arduino code, then YOU should know how to do it.  I don't do C code.

 

In basic it would be something like print#1, chr$(10)

0 Kudos
Message 19 of 49
(1,689 Views)

Thanks man for everything, i'll try it, realyy thanks I never see this code works like this! Thank you so much! 😄 And excuse me that I don't understand some directions, I don't understand English very well, but i'm doing it, Thank you again man.

0 Kudos
Message 20 of 49
(1,686 Views)