LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parts of string lost while communicating with Arduino.

Solved!
Go to solution

While communicating with arduino, the string I receive from arduino is buffered but it isn't totally read by LabVIEW

and some information is lost, changing the data I plot. Anyone knows how to solve this problem?

Maybe useful information:

Arduino mega

Baud rate: 19200

Loop delay in Arduino: 10 ms

The string is composed by 3 integers values concatenated like this:

gh123ab123cd123ef

 

I´m attaching the Vi.

 

Thx very much!

Paulo

0 Kudos
Message 1 of 9
(4,048 Views)
Solution
Accepted by topic author PauloLETE

Is your time to wait actually 0 milliseconds?  That isn't very long to wait for a message to come in.

 

Does every message end with a linefeed character as a termination character?  You have the termination character enabled by default.  If so, then you are better off reading a large number of bytes and letting the termination character end the read, rather than using "Bytes at Port".  If at the instant you read, not all of the bytes have arrived yet, then you're bytes at port will be less than you really want and you will wind up reading an incomplete message.

0 Kudos
Message 2 of 9
(4,039 Views)

I thought that with time to wait equal 0 it would always receive the string like an open door.

 

I will try what you said! I makes very much sense!

 

Thx!

0 Kudos
Message 3 of 9
(4,037 Views)

Sorry Ravens Fan!

 

I am very new to LabVIEW! How could I use the termination character ins tead of bytes at port? Is there any VI tha does that?

 

Thx!

0 Kudos
Message 4 of 9
(4,032 Views)

The Serial Port configuration VI has two inputs called Enable Termination Character and Termination Character which you did not wire.  So they use there defaults of Enabled and Line Feed Character.

 

What does the data coming from your device actually look like?  Does it have a line feed character at the end?  Or a carriage return?  Or anything else?  If it does, that gives a good marker of when one message ends (and thus the VISA read can return the data).

 

Though you have an unusual string of data there, but if that is a reliable pattern where the data of interest is numerical characters, and the last character of the data packet is always "f", and you never get an "f" anywhere else in the packet.  Then you can set your termination character to be an "f".  Actually you will wire up a constant that is equivalent to the ASCII value for an "f" at the Serial Port Configuration VI.

0 Kudos
Message 5 of 9
(4,025 Views)

Thx Ravens!

It has workes really well!

I´m sending the VI!

 

Thanks

0 Kudos
Message 6 of 9
(3,964 Views)

I'm glad it's working.

 

Here are a couple more tips to help you fix minor problems with your code.

 

1.  You have a few cases where data is being coerced from one data type to another as shown by the red dots on inputs into functions.  When you need a constant or control, right click on the input to the function and click Create Constant or Create Control.  It will give you the appropriate datatype wired up and no coercion dot.

 

2.  On the 3 decimal string to number functions, it is not necessary to convert the blue wire (integer) to an orange wire (double).  If you wire a constant to the lower left of the function with the appropriate datatype, the output of the decimal string to number will match.

 

0 Kudos
Message 7 of 9
(3,941 Views)

Hi!

 

I'm having some trouble... I'm trying to send to arduino data treated inside labview...

But it is taking to much time to iterate...

Delay time is 5 ms and the program has a frequency of 1 Hz more or less...

Could someone take a look to see if there is something wrong??

Thx in advance!

0 Kudos
Message 8 of 9
(3,901 Views)
0 Kudos
Message 9 of 9
(3,895 Views)