3/30/2011 11:27 AM | |
Joined: 1/17/2007 Last visit: 10/21/2024 Posts: 1547 Rating: (537)
|
When you send a write command to a modbus device, you get a confirmation response returned. This response is normally just an echo of the request, but consult the Modbus Protocol Specification for the exact details id the response packets. You could also read the coil / holding register that you have just written to confirm that the write value has been accepted. So the sequence would be:- 1) Perform the write request. 2) Check that you get a write response confirmation 3) Read the data back to check that it now has the new value written. |
Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
3/31/2011 12:48 PM | |
Joined: 1/17/2007 Last visit: 10/21/2024 Posts: 1547 Rating: (537)
|
I was not referring to any PCS7 add-on. The conformation response is part of the standard modbus protocol and is handled by the standard modbus blocks. When you perform a write operation on the slave, this response is automatically returned. You just need to check that the P_RCV_RK NDR output is set (or secess counter in the application example has incremented). Application example is available in section 9 on this manual. If you get either of these indications, it indicates that the slave has accepted the write operation. You just then need to readback the value using the read holding register (FC 03) or read coils (FC 01) function code to validate the read actually worked. If the readback shows that the write failed, then you could either wait a short period and perform another readback (giving the slave a bit more time to complete the action), or continue to repeat the write / readback operation until it is sucessful. I can see no reason why the write operation would not work, unless the write telegram failed for some reason. But if that was the case, I would expect that the modbus blocks would report some kind of error. The only other possibility is that there is a timing issue. You perform the write, and then the readback, but if you do this in quick sucession, there may not be emough enough time for the slave to update the value before you read it back. Remember the slave device will have its own cycle time which will almost certainly not be synchronised to the S7 cycle. |
Last edited by: smiffy at: 3/31/2011 12:48 PMProgramming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
4/1/2011 10:47 AM | |
Posts: 3 Rating: (0) |
Thanksfor all your interesting comments. I think that I must to make some changes in my strateggy. for check answers, and repeat orders,and.... Thanks for all |
Follow us on