01-11-2011 10:42 AM
Hey there!
Is there any practical way to estimate Bytes to Read and Time to Wait in LabVIEW?
From Arduino I receive a string in this format
aa111,222,
I use "aa" to locate the beginning of the string and the commas to separate the values.
I'm going to post my VI
Thank You!!
Paulo Oguro
01-11-2011 12:15 PM
Is your Arduino sending a termination character like a line feed? Your serial port is set up to terminate VISA Reads on a line feed. Then you can just read a sufficiently large number of bytes and the read will terminate as soon as the line feed is received.
01-11-2011 12:21 PM - edited 01-11-2011 12:21 PM
Hello Ravens Fan!!
Nice to see ya!
Well the arduino code is this:
void setup() {
Serial.begin(115200);
}
void loop() {
int analogValue = analogRead(0);
Serial.print("aa");
Serial.print(analogValue*0.5);
Serial.print(",");
Serial.print(analogValue*1);
Serial.print(",");
Serial.print("\n");
delay(4);
}
So there is a line feed, but when I run LabVIEW it reads for 1 or 2 seconds, then it stops like if there is no more data to acquire.
I thought it happened because I did not configure correctly these parameters I mentioned before.
Thank You!!
Paulo
01-11-2011 12:25 PM
\n is the slash code in LabVIEW that gives a visual display of the linefeed character.
In your Arduino code, you are sending a slash and an "n". Not the same thing.
You need to send the character x0A or decimal 10. It would be something like Serial.Print(chr$(10)).
(Assuming the Arduino has a chr$ function like other basic languages.)
01-11-2011 12:35 PM
As I recall the Ardunio runs on the FTDI chip set. It appears that you are sending small packets at a very high speed. You will need to optomize the com port settings for this application (the default 16mS latency timer is going to become a roadblock) See paragraph 3.1 in the attached link.
01-12-2011 10:07 AM
Hi there!
Now my arduino code is like this:
void setup() {
Serial.begin(19200);
}
void loop() {
int analogValue = analogRead(0);
Serial.print("aa");
Serial.print(analogValue*0.5);
Serial.print(",");
Serial.print(analogValue*1);
Serial.print(",");
Serial.print("\n");
Serial.print(char(10));
delay(4);
}
Does that guarantee that labVIEW will read as a termination char?
Keeping the same delay of 4ms, LabVIEW acquire data for more or less 4 seconds, then it stops.
So I think you are right too, Jeff Bohrer.
I'll try to raise delay time up to 20ms.
I will post results in a sec.
Thanks!
01-12-2011 10:16 AM
I raised time to wait to 22 ms, and this didn' t resolve my problem. Now it works for more or less 15 seconds and then it stops working.
Arduino's delay is 20ms. So even being small packets sent in a high frequency, the delay time is longer than the 16 ms of latency of FTDI.
I'll try to raise the time some more, but I don't belive it will work.
It seems like there is a maximum number of packets I can receive in COM port.
Maybe its only my impression.
01-12-2011 10:31 AM
Hey there!!
I have raised the delay of arduino and I now I have got another problem!
The modulus of the analog output is proportional to the delay time of arduino.
I have put it 4 ms, and the output was around 1.50 and it should be 3V3 (3.3V).
With 400 ms, its around 2.90 much more correct than with lower delay.
But that problem of the labVIEW stopping acquiring remains. I can't figure out yet.
Thank you
Paulo Oguro
01-12-2011 11:08 AM
Paulo-
you might want to look at the document again on optomizing the FTDI. Reduce the Latency timer and packet sizes in the com port setup.
01-12-2011 11:33 AM
Here is a good source of infomation. The AnalogRead() actually takes 100mS for the conversion. I'm wondering exactly how fast the ardunio loops with your routine? Beyond my area of expertize.
Always glad to help - and learn