LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Synchronizing Bytes to Read, Time to wait while Aquiring data from Arduino

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

0 Kudos
Message 1 of 10
(2,759 Views)

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.

0 Kudos
Message 2 of 10
(2,751 Views)

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

0 Kudos
Message 3 of 10
(2,745 Views)

\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.)

0 Kudos
Message 4 of 10
(2,741 Views)

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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 10
(2,732 Views)

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!

0 Kudos
Message 6 of 10
(2,711 Views)

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.

0 Kudos
Message 7 of 10
(2,707 Views)

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

0 Kudos
Message 8 of 10
(2,703 Views)

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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 10
(2,694 Views)

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


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(2,685 Views)