LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication problem - Modbus ASCII

Solved!
Go to solution

Here is my Labview-program.

 

What do you exactly mean with "Post some codes"?

0 Kudos
Message 11 of 28
(449 Views)

@StefanieWernet wrote:

Here is my Labview-program.

 

What do you exactly mean with "Post some codes"?


That is what I meant, posting your VI so we can see how you programmed it.

 

You might have to ask the manufacturer as to what exception code 9 is.  I don't know if they are allowed to created new ones that don't already exist in the modbus spec.

 

Looking at your command string, I do see something odd,

 

:050300800004AC

:  Is that the start command?  I only work with RTU and not ASCII so I'm not used to seeing that.

05  slave address

03 command code for Read holding registers

00 80,  Starting address.  Is 128, so are you trying to read 400129 ?

00  number of registers to read.  I think you'd want 01 here.  Perhaps that is the reason for the error?

04AC checksum (which will have to change if you change any of the values before this)

 

 

0 Kudos
Message 12 of 28
(444 Views)

I am sorry, the upload did not work well. I use a different input string. It is now hopefully shown in the png, called input.

 

I have problems to calculate the checksum. Do I have to consider the whole string or without the : ?

Does someone have a good online calculation program?

0 Kudos
Message 13 of 28
(438 Views)

I'm not sure about the checksum.  I'd check the manual for the device.

 

Also take a look at http://modbus.org/tech.php.  The specs might talk about it.

0 Kudos
Message 14 of 28
(429 Views)
Highlighted

I the manual is not written a lot. There is just a short part about the "Communication Register", which is in the appendix.

 

Can someone explain which code I have to use to read the process value?

0 Kudos
Message 15 of 28
(425 Views)

I ran into this symptom once, using the current NI-supplied Modbus API (I wholeheartedly recommend this version, not the old version linked earlier). I was getting an undefined error code from the library functions, which was due to the Modbus device returning exception code 9, which is undefined in the Modbus spec (the discussion of the problem starts here). I was talking to an Automation Direct SureServo drive via Modbus RTU, and it turned out I was trying to write to a holding register which was read-only when the drive was enabled, causing it to return exception code 9. Check and double-check that the register you're trying to read/write is valid and accessible in the current state of your controller.

 

As I said, I'd recommend using NI's free Modbus library, but if you insist on rolling your own, then instead of using a delay and Bytes At Port before your VISA Read, you should enable the termination character for your COM port and configure it for 0x0A (a linefeed character) and tell the VISA Read to read a number of bytes in excess of what you expect to receive.

0 Kudos
Message 16 of 28
(423 Views)

Thanks for your help!

I am not sure about the validity of my register. Can someone explain me the "Communication Register" of my device, which I uploaded earlier?

I thought I have to use :01031000 to read the register of the process value.

 

I am a total beginner with Labview, therefore I do not understand how to "enable the termination character for my COM port and configure it for 0x0A". Can you explain it to me in more detail?

 

 

0 Kudos
Message 17 of 28
(418 Views)

At your VISA Configure Serial Port, you have a False constant wired to "Enable Termination Character"; change that to True. The input next to it, "termination char", has a default of 0x0A, a linefeed character, which is what you want for Modbus ASCII so you don't have to wire anything to that. Then at your VISA Read, wire a large number like 1000 to the "byte count" input. The Read will stop when it sees the linefeed at the end of the Modbus reply or when it times out. This is the proper way to do it, though the NI Modbus library already does this for you.

 

As for whether you're reading a valid register, you didn't tell us the make and model of your temperature controller, so we don't know whether the register you're trying to read is valid. Can you share the documentation for the controller with us?

 

 

0 Kudos
Message 18 of 28
(410 Views)

Sorry, I missed that you had posted excerpts from your manual. Presumably you have the correct speed, data length, parity, stop bits, and Modbus type, or you wouldn't be getting a reply at all. The most recent example you posted has your sent string as ":01031000191", but that doesn't look to be formatted correctly. From what I've read, the starting address and number of words to read should both be 16-bit values, or four hex digits, so your message looks like it's missing a few bytes.

0 Kudos
Message 19 of 28
(402 Views)

Of course! I am using a temperature control CN7663. The manual is in the appendix.

0 Kudos
Message 20 of 28
(401 Views)