from the Forum department...
Sending strings over modbus
Communications systems and equipment. topic
Posted by Andrew Townsend on 24 February, 2010 - 8:59 am
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.

Posted by jc on 24 February, 2010 - 1:15 pm
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

Posted by David on 24 February, 2010 - 1:30 pm
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.

Posted 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

Posted by Ian Goldby on 25 February, 2010 - 5:51 am
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.

Posted 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).

Posted by M Griffin on 24 February, 2010 - 4:47 pm
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.

Posted by Tim Kirk on 25 February, 2010 - 10:43 pm
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.

Posted by Frank O'Gorman on 26 February, 2010 - 3:21 am
If the HMI supports it, you could use the Modbus Read Device Information command (function 43/14), which is intended for this purpose.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

This life is a test. It is only a test. Had this been an actual life,
you would have received further instructions as to what to do and where
to go.