10-08-2010 03:19 PM
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
Solved! Go to Solution.
10-08-2010 03:25 PM
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.
10-08-2010 03:30 PM
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!
10-08-2010 03:36 PM
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!
10-08-2010 10:37 PM
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.
10-15-2010 04:44 PM
Thx Ravens!
It has workes really well!
I´m sending the VI!
Thanks
10-16-2010 02:01 PM - edited 10-16-2010 02:02 PM
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.
10-20-2010 02:29 PM
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!
10-20-2010 02:40 PM