Function 06

J

Thread Starter

Jurie

I use a Siemens CP341 Comms card running Modbus Master going through a Phoenix Modbus TCP Gateway to talk to Modbus TCP slaves. When I use Function 06 command I get errors from the PLC saying the reply is incorrect. (Error 0E 56H - Echo wrong) The command; change register 30 to 2:<pre>
I send =00 06 01 06 00 30 00 02
The reply =00 04 01 06 00 30 </pre>
I would have expected the reply to be the same as the command.

Both Phoenix and IDX have said that the reply is incorrect but when I use the modbus TCP simulator (Mod-RSsim) I get the same reply as from my TCP slave.

Which is the correct reply and how can I sort out this problem?

Thanks
 
> I send =00 06 01 06 00 30 00 02

It seems you forgot to send bytes 0-3
// bytes 0,1 Transaction ID faithfully copied from the request message
// bytes 2,3 Protocol number always zero
00 This is OK. Always zero
06 This is OK. Equal to the number of bytes which follow
01 slave=1
06 function=6 PresetSingleRegister
00 start_adr_high
30 start_adr_low
00 num_register_high
02 num_register_low

Please compare with our Modbus communication class:
http://pvbrowser.org/pvbrowser/sf/manual/rllib/html/classrlModbus.html
(surf through the sourcecode)
 
Thank you for your reply but my question relates to the reply - I did not add the whole command<pre>
If I send =00 06 01 06 00 30 00 02
Is the reply (A) =00 04 01 06 00 30 ?
or
Is the reply (B) =00 06 01 06 00 30 00 02 ?</pre>
I am pretty sure B is correct for Modbus, but why am i getting A from Modbus TCP. Are Modbus and Modbus TCP different from each other?
 
S

Scott Henson

Yes, you are correct. The reply should be the same as the query for function 06.

(And yes, the data section of an RTU packet is exactly the same as the data section of a Modbus/TCP packet. There is just more header information on the TCP frame and no CRC.)

It looks to me like your target slave isn't properly supporting FC 06. You should try FC16 with a count of 1 register and see if that works. I have seen a lot of slaves that support FC16 but not FC06.
 
Top