Showing results for 
Search instead for 
Did you mean: 

Including a Carriage Return when Writing to a Single Register Using Modbus

Go to solution

I am using a NI USB to RS-232 to communicate with a Watlow EZ-Zone PM controller using Modbus protocol and am having trouble writing a value (set-point temperature) to the controller.  I am successful when reading register values, so I know my settings are correct.  I have also verified this using a Modbus Test program Watlow provides.  While using this program, it has become clear to me that a carriage return is required after the numeric value.  The MB Serial Master Query Write only allows for an U16 value.  How can I include a carriage return? 

0 Kudos
Message 1 of 6

A carriage return is a 13 decimal, or 10 hex in ASCII.  So you could add that byte to your data.


However, what you are saying doesn't make sense to me.  Modbus doesn't have anything to do with carriage returns or linefeeds.  It is a pretty specific protocol that defines the purpose of each and every byte in a packet sent to or read from the device.  The value of hex10 (decimal 13) is just as valid a piece of data in the binary protocol as any other byte.


Are you sure the Modbus Test program from watlow is requiring you to send a carriage return?  There is no real meaning to a carriage return byte in a true Modbus packet.


Now if you were sending data in an ASCII format, (e.g. sending the value 1000 is sent as a "1", "0", "0", and a "0", then ending that string with a carriage return is quite common.  But that isn't modbus.

0 Kudos
Message 2 of 6

You will have to forgive me, I am new to Modbus.


The Watlow ModbusTest documentation states "Each data value must be followed by a carriage return."  Within this test program, when entering a set point temperature of 72.0 for register 2160, the value on the controller does not change unless a carriage return is included in the "write data" pane.


In LabVIEW, I set the read/write address of the MB Serial Master Query Write to 2160.  With a temperature value (72.0 for example) is wired to the holding register terminal and the program executed, the value on the controller does not change.  Therefore, I assume I have the same problem of needing the carriage return.



0 Kudos
Message 3 of 6
Accepted by topic author ELDMATT

A statement like that makes me think it isn't talking modbus.


Run their program while running something like Portmon.


Then compare the data sent back and forth with the modbus spec.

Message 4 of 6

Thank you for your help.  Portmon was very useful.


You were correct, it was not an issue with a carriage return.  


Portmon allowed me to see that when I read a value, it was actually from 2 registers and in Hex format.  I was able to get the controller working by writing to multiple registers and converting to hex before passing the value into the terminal.


Thanks again!

0 Kudos
Message 5 of 6

I'm glad I good help.


But please give me the credit for supplying you the solution by marking my post as the solution.  First, you'll have to unmark your post as the solution by going to the Options menu to the upper right of your message.

0 Kudos
Message 6 of 6