Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Waiting for data on serial port

Solved!
Go to solution

Hello everyone.

 

I'm trying to figure how I can solve a problem on LabView. I've programmed an Arduino board to read and send an array of data from an accelerometer to the serial port. I want LabView to receive the data and graph it. My problem is that Arduino is sending data continuosly and sometimes LabView can't keep up with the flow and read some values as "0".

 

Is there a way to wait for the data and solve this problem?

 

I've attached my current vi.

 

Thank you very much in advance.

0 Kudos
Message 1 of 10
(6,098 Views)

Well, LabVIEW can certainly keep up with a 9600 baud serial port.

 

1. You have the port configured with the default setting: Enable Termination Character = True. You should never use that setting and Bytes at Port at the same time. If a termination character ever occurs in the data, the read will terminate early.

2. How does the Arduino identify the end of one data array (or data point) and the beginning of the next?

3. How many characters are in each data point or array from the Arduino?

 

Lynn

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

Thanks for your answer.

 

For your questions:

 

1) Then I'll change it, sorry but I'm a newbie.

2) I've made a for cycle, when the array is filled Arduino send the data to the serial port and then he restarts to collect the data.

3) Each data point has 6 characters and I have 6 values (the 3 axis of the accelerometer and the 3 of the magnetometer).

0 Kudos
Message 3 of 10
(6,077 Views)

Good. Now a little more detail, please.

 

3) Are the characters ASCII numerals, binary, or something else? What is the range of all possible characters in the data?

 

The reason for these questions is to determine whether it is possible to identify the beginning or end of each data cycle.

 

Lynn

0 Kudos
Message 4 of 10
(6,062 Views)

Well, they are numerals.

 

Sorry for not understanding, but what do you mean for the range of all possible characters in the data?

 

I really appreciate your help.

0 Kudos
Message 5 of 10
(6,058 Views)

Your device sends the ASCII characters "0" "1" "2" "3" "4" "5" "6" "7" "8" and "9", right? What about "+" "-" or "."? The bytes have decimal values in the range of 43 to 57?

 

The reason I ask this is that the terminology or language used to describe the characters can be confusing and I am trying to be sure that I understand exactly what your Arduino is sending.  The fixes or solutions for your problem depend on knowing those details.

 

Lynn

0 Kudos
Message 6 of 10
(6,051 Views)

Yes, the characters are from 0 to 9 and - No "+" or ".". And the bytes have that range.

 

Once more, thank you very much.

0 Kudos
Message 7 of 10
(6,049 Views)
Solution
Accepted by topic author AndreasSchnaas

@AndreasSchnaas wrote:

Yes, the characters are from 0 to 9 and - No "+" or ".". And the bytes have that range.

 

Once more, thank you very much.


Since you are sending actual ASCII characters, change your Arduino code to send an End Of Line character (byte value of 10) at the end of each transmission.  Your code is already setup to use that.  Then you don't need to use the Bytes At Port at all.  Just tell the VISA Read to read a huge number of bytes.  The read will stop when it finds the termination character (the value of 10).  Your code will get a lot easier from there.


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
Message 8 of 10
(6,046 Views)

I was thinking exactly what crossrulz wrote. Try it that way.

 

Lynn

Message 9 of 10
(6,044 Views)

Thanks to both of you for the suggestions. I'll try to take this way.

0 Kudos
Message 10 of 10
(6,039 Views)