LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV losing bytes (once?) in loop process

Solved!
Go to solution

Hey dear NI community!

 

I am losing bytes... and I assume, I am doing so during the first loop of my programme.

Below the .vi is attached. Here is a screenshot of the block diagram and the 'live feed' monitor indicating missing bytes (explanation following):

 

block diagram + live feed.png

 

Here is how the programme works:

My Arduino Mega2560 sends the data of 16 pins + the marker string 'xx' in a continuous cycle. Now I want to monitor these pins.

1. 34 (=16pins*2[bytes]+2['xx']) bytes are read and checked for the 'xx' sequence.

2. The index of the first character after 'xx' determines how many more bytes have to be read before our loop starts. (The purpose behind this is to have the 34-bytes-strings during each loop to start with the 32 data bytes followed by the marker bytes 'xx'.)

3. The loop takes 34 bytes and evaluates the first two bytes corresponding to the value of the first pin.

 

The 'before loop correction' shows, that the used string ends with 'xx' right before the start of the loop. Measuring the loop-bytes with 'live feed' however shows data, where 'xx' is not at the end, rendering the evaluation of my string impossible. (Note: 'xx' in hexadecimal display is '7878', so the byte string in the picture above is off by one byte.) Also note, that once the programme is started, the false position of '7878' stays the same, as if the byte lose occurce once.

 

Any ideas?

 

Kind regards,

Friedrich G. Froebel

 

 

PS: The Arduino Mega2560 is operating at 38400 bauds. Higher values are not accepted. Do you know why or how I could fix this?

0 Kudos
Message 1 of 3
(2,299 Views)

Hi,

 

please make sure, that receiver and transmitter have the same baud rate etc.

The next step is: How fast does your receiver sends the data. Please make a gap between the sending of the data on the arduino of about 1 sec, does your program work correctly?

 

Regards, Fabian

 

0 Kudos
Message 2 of 3
(2,245 Views)
Solution
Accepted by topic author Frieder713

Friedrich,

 

The default for VISA Configure Serial Port is to terminate reads with a termination character = line feed = 0A. Any time a 0A occurs in your data set the read will terminate without waiting for 34 characters. Solution: wire a False constant to the Enable Termination Character input at the top of the Configure function.

 

Or you could change the termination character to be your marker character (as discussed in your other thread).

 

Lynn

Message 3 of 3
(2,238 Views)