LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

losing data from serial communication with arduino

Hi , first of all english isn't my native language so forget de orthographic mistakes.

i'm making a datalogger with arduino uno, with 6 analog inputs. the uno sends the data just fine (i use CoolTerm to test). but when im geting the data with labview some bits are lost. i make two VI's, one using "bytes at port" and the other with "byte count". as seen below:

18-11-2013 17-53-36.png

 

in the next graph i show you the data that reads coolterm and  every VI 

 

18-11-2013 18-01-18.png

 

you can see the time stamp that arduino is sending, in coolterm is every 2-3 ms, with byte count is 2-3 ms but frequently some data is lost and with bytes at port look like its random.

 

additional data:

baud rate 115200, 8 bits

the case structure is for dismiss the first data in the buffer and to start an pause the acquisition , using a serial flush in bytes at port, dont know why i can't use serial flush with byte count so i use memory free function.

 

arduino code:


String buffer;
int i;
unsigned long t;
int datos[5];
void setup()
{
Serial.begin(115200);

Serial.flush();
}
void loop()
{

for(i=0;i<6;i++){
datos[i]=analogRead(i);
}
t=millis();
buffer = String(datos[0])+" "+String(datos[1])+" "+String(datos[2])+" "+String(datos[3])+" "+String(datos[4])+" "+String(datos[5])+" "+String(t);
Serial.println(buffer);

}

 

Download All
0 Kudos
Message 1 of 4
(4,003 Views)

attached the other VI 

0 Kudos
Message 2 of 4
(3,999 Views)

What I recommend is add an End Of Line character to the end of you Arduino buffer.  This way you will actually have a termination character.  Then just read a huge number of bytes.  The VISA Read will stop when it finds the termination character.  So get rid of that case structure before the VISA Read.  You don't need to free up memory for this.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(3,996 Views)

i put "T" as end of line in arduino, 0x54 in labview and still lose some data. it get the first 550 strings that are send and start to lose data  , could be that the data is coming to fast?¿?¿  maybe taking more samples and then send all as a bigger buffer?¿?¿ 

0 Kudos
Message 4 of 4
(3,978 Views)