Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus communications not receiving some of the bytes then receiving the remainder of the bytes

I wrote a serial Modbus communications VI that transmit 8 bytes to a circuit board then receives 115 bytes from the circuit board. The VI also extracts (parses) two bytes of data from the receive data string. The problem I am having is when the 8 bytes are transmitted it only receives 13 bytes first and then receives the next 112 bytes. Therefore the first 13 bytes end up at the end of the data string instead of being at the beginning of the data string. What is the cause for this happening? I have attached the VI.

0 Kudos
Message 1 of 9
(5,188 Views)

Hello lgreen123,

 

Just looking for a little clarification on this. You mentioned that you expect to receive 115 bytes from the board. But you are seeing it only receiving 13 bytes and then 112 bytes. So this is 125 bytes total. Am I missing something or just misunderstanding?

 

Could you post the actual data that you receive in the 'Receive Data' indicator? This might prove helpful in figuring this thing out!

dK
0 Kudos
Message 2 of 9
(5,180 Views)

Sorry that should be 102 bytes not 112 bytes. I have attached the transmit and receove data string

 

 

 

0 Kudos
Message 3 of 9
(5,174 Views)

This is perfect! Thank you.

 

Do you have a manual for the circuit board? I'm guessing the manual states that we should get a certain response of data bytes when we write 0103 0064 0037 45C3 to the line. Is this how you know the 13 data bytes are in the wrong position?

 

What happens if we change the byte count on VISA Read to 13 bytes rather than 115, or any other lesser number? I am just curious when the 13 bytes are read in exactly.

 

Can we test the Modbus serial communication with the circuit board with any other program rather than LabVIEW? We could even try the VISA test panels in MAX to see if we experience the same behavior. The reason I ask this is so that we can cross reference and see where the communication is breaking down.

dK
0 Kudos
Message 4 of 9
(5,172 Views)

The circuit board that I am commmunicating has communication firmware that I wrote and has been tested by using test software and with using a PLC. so there is no issues with the the circuit board communication.

 

I will try to send a modbus command to receive 13 or less bytes and let you know the result.

0 Kudos
Message 5 of 9
(5,143 Views)

I tried receiving less than 115 bytes (even less than 13)  and I would see the same result of not receiving all the bytes at once and not in the correct order.

 

It seems like to me that the receive function is some how getting interrupted and not able to receive all the bytes at once and receives all bytes in two steps. As a result of this, the bytes it receives in the first step are at the end of the receive data string instead of being at the begining and the bytes that get received in the second step are at the start of the receive data string instead of being at the end.

 

 

 

 

0 Kudos
Message 6 of 9
(5,141 Views)

I'd suggest using this:

https://decibel.ni.com/content/docs/DOC-30140

it is included in lv2014 dsc and rt modules, if you have either of those.

 

if you want to keep doing what you're doing, then you might look at the settings for termination characters. I'm not sure of the default but you can set a visa read to terminate on receiving N bytes or on a certain termination character. Since your string ends with 0x0A, which is newline, that might be the issue.

0 Kudos
Message 7 of 9
(5,128 Views)

Adding in the VISA property node fixed my problem. I have attached the updated VI with the property node inserted for the termination character.

0 Kudos
Message 8 of 9
(5,116 Views)

Hi,

 

Can you try this ?

 

You must wait some time before reading characters and only retrieve the number of character that are present at the serial port.

 

Kees

0 Kudos
Message 9 of 9
(5,096 Views)