Today is...
Sunday, December 21, 2014
Welcome to the Modbus Community, about
the world's leading automation protocol.
Sending strings over modbus
Can I send text strings over modbus RTU
By Andrew Townsend on 24 February, 2010 - 8:59 am

Hi,
A customer has asked if he can read application information from the PLC (Version, author, project name etc) over modbus to display on his touch screen HMI.

I am the one doing the application software in the HVAC PLC, so would need to make this info (string) available on modbus, of course I am the modbus slave in this instance.

Is this possible?

Thanks alot for any info.
Andrew

Strings are commonly sent over modbus. Each 16bit register can hold two 8 bit characters. Therefore, fairly large blocks of registers are required for long strings.

There is some good information on this at www.simplymodbus.ca/FAQ.htm

Theoretically, yes,

a) if you have the ability to write custom programming, but you'd have to do it for both the master and the slave. Modbus 'just' transfers data values (bits in bytes).

b) the information your customer wants is available where your custom algorithm can get at it.

If you (can) write an algorithm that converts characters to a number (every character has a unique number) on the one side, it's entirely possible to send the numbers (or read the numbers), then decode the numbers back to characters and then reassemble the characters into text words, assuming you have the processing power and the appropriate algorithm.

The bigger question is whether what you have to charge your customer to do that is worth what he'll have to pay.

By Fred Loveless on 24 February, 2010 - 2:26 pm

It really depends on the device and the communicaitons software. Strings are just byte arrays. You cannot have a string that excedes the maximum packet size but as long as the device and the communications software support it you should have no problems.

Fred Loveless
Applicaitons Manager
Kepware Technologies
http://www.kepware.com

I don't think the maximum packet size would be a limitation. After all, Modbus is really just a memory transfer protocol, and you could just make multiple requests until you have the whole memory block containing the string or strings.

By John Correa on 24 February, 2010 - 4:35 pm

Yes. I'm not sure what type of PLC you are using but if this data is not available through modbus you can code it manually in a memory area of your PLC that can be read from MB Master (HMI).

You can simply put characters in a series of consecutive registers, with one or two characters per register. It's the same way you would store a string in the PLC's memory. That bit is easy. The real question is whether the HMI can handle strings, and if so then in what format.

We have definitely done this in the past on controllers we have designed. All we did was define a fixed-length string field (no longer than the Modbus packet size allows). Then we would make each register in a block of registers contain 1 character of the string, or 2 characters if we knew the HMI was capable of splitting the registers. We would pad the remaining registers in the block with space characters.

The HMI would read the block of registers using Function 3, and then concatenate the values to re-create the string.

It really does just come down to what string format the HMI will support, since there isn't an enforced standard.

If the HMI supports it, you could use the Modbus Read Device Information command (function 43/14), which is intended for this purpose.