6/12/2009 4:59 AM | |
Joined: 10/7/2005 Last visit: 11/7/2024 Posts: 3026 Rating: (1057) |
Hello Kvdm let me try to explain how your S7 program needs to handlethe calls of P_SND_RKand P_RCV_RK by drawing an analogy to how aProfibus DP Master handlesthree DP Slaves. 1.) DP Master sends a "request" (i.e. the Outputs) to DP Slave 1 and waits for a "response" (i.e. the inputs). 2.)Slave 1 responds (or error) --> Master sends a "request" to Slave2 and waits for a "response". 3.)Slave2 responds (or error) --> Master sends a "request"toSlave3 and waits for a "response". 4.)Slave3 responds (or error) --> Master sendsa "request" toSlave1 and waits for a "response". and so on and so on Error handling is automatically taken care of by the Master, should he receive an invalid response back from the Slave ORa timeout occurs, the Master will move on to poll the next Slave (ok, he will typically "retry" to talk to the same Slave again before he moves on). Bottom line is: ONE request to ONE Slave is active on the bus at any given time (bear in mind that we are talking serial comms here). The Slave only responds to a requestand the Master will "wait" for a response before he moves on to request data from the next Slave. This is the kind of handling that you need to program into your S7 logic for communication with a Modbus device. Based on the above,your logicneed to (should, could)handle aModbus READ request via aCP341 as followed: 1.) Start a request via P_SND_RK (e.g. Modbus function code 3 toreadmultiple registers) and memorise (latch) that you have triggered a "job request". 2.) Havethe corresponding P_RCV_RK active to await the arrival of the data. 3.)Evaluate the P_SEND_RK"DONE" bit and use it together withyour memorised "job request" bit to determine successful completion of this Modbus job (i.e. reset the memorised "job request" and move on to trigger a new job). Error handling: Evaluatethe Error bits of the P_SND_RKand corresponding P_RCV_RK. If you get either of them together with your memorised "job request" bit you use this toreset the memorised "job request" and move on to trigger a new job. You can have a number ofP_SND_RK/P_RCV_RK FB pairs programmed,the important thing is to make sure you only have one of them active at any given time(i.e. you essentially multiplex the calls if you have to read out different areas from one Modbus Slave OR need to read and write to one Modbus Slave OR have to communicate with a number of Modbus Slaves). Alternatively you can also have only one programmed P_SND_RK/P_RCV_RK FB pairin you logic and change the call parameters(this requires a bit more programming effort upfront but will lead to a more flexible implementation). I hope this helps Cheers Fritz |
Last edited by: fritz at: 6/13/2009 2:13 PM"Cleaned up" some ambiguities Last edited by: fritz at: 6/12/2009 8:48 AMcorrected spelling mistakes only (oops) Cheers |
|
This contribution was helpful to1 thankful Users |
6/13/2009 1:44 PM | |
Joined: 10/7/2005 Last visit: 11/7/2024 Posts: 3026 Rating: (1057) |
Hello again Kevin Your question 1 raises a very good point and is admittedly one that can easily be a source of confusion (and looking back at my previous post this is something that I did not fully address/explain). The “Loadable Driver for Point-to-Point CPs MODBUS Protocol RTU Format S7 is Master” manual (ED 03-2009) does in principal quite correctly explain how to handle it (ref chapter 7.1 for CP341). What is important to understand (and typically a source of confusion) is that a distinction must be made between overall Modbus READ or WRITE functionality and how this relates to usage of the P_SND_RK and P_RCV_RK Blocks in the S7 program. The following relationship/handing applies for a (CP341 related) Modbus WRITE: Required in S7 program: ONLY P_SND_RKHandling: 1.) P_SND_RK is used to “send” the data to the Modbus Slave via CP341 2.) Modbus Slaves receives the data, writes them into the nominated register and responds with an acknowledgment back to the CP341 3.) P_SND_RK signals a successful overall Modbus WRITE job via DONE bit or an unsuccessful overall Modbus WRITE job via ERROR bit The following relationship/handing applies for a (CP341 related) Modbus READ: Required in S7 program: P_SND_RK AND P_RCV_RKHandling: 1.) P_SND_RK is used to “send” the read request to the Modbus Slave via CP341. 2.) Modbus Slave receives the read request and (if all is well) responds by sending back the requested data to the CP341 3.) P_RCV_RK now needs to be used to transfer the received “read” data from the CP341 to whatever the destination area is in the S7. P_RCV_RK’s NDR bit or ERROR bit also indicate if this data transfer took place or not. P_SND_RK however signals a successful overall Modbus READ job via DONE bit or an unsuccessful overall Modbus READ job via ERROR bit As for your question 2, I don’t quite understand what you are referring to with “What is the proper procedure for the SND and RCV resets?”, please advise further. I hope this helps Cheers
|
Cheers |
|
This contribution was helpful to1 thankful Users |
6/16/2009 10:19 AM | |
Joined: 10/7/2005 Last visit: 11/7/2024 Posts: 3026 Rating: (1057) |
Hello Kevin here is my take on the "R" (execute reset) input of P_SND_RK/P_RCV_RK: Q: When should these be used? A: If you want to abort/cancel a job and (re)set P_SND_RK/P_RCV_RK to its initial stage. Inever had the need to use the reset inputthough. Q: How long should the input be on? A: As long as you want to effectively disable the job (a oneshot is good enough to carry out the reset) Q:How do I know the reset is complete? A: There is no dedicated status value that indicates that a reset is "DONE" or in progress, you simply need to trust that this will reset/initialise the P_SND_RK/P_RCV_R Blocks. It effectively "kills" the link between the P_SND_RK/P_RCV_R and the CP341 for as long as it is on. I hope this helps Cheers Fritz |
Cheers |
|
6/16/2009 12:08 PM | |
Posts: 261 Rating: (42) |
That means if we are having with 25 nos of slaves it will update the status after 25 scan cycles? regards ddg |
6/18/2009 5:46 AM | |
Joined: 10/7/2005 Last visit: 11/7/2024 Posts: 3026 Rating: (1057) |
Hello ddg assuming you do this via one CP341 and have onlyone Modbus function code request per Slave then YES you will need 25 P_SND_RK "cycles" to "talk" to all Modbus Slaves (and note that this will require more than 25 OB1 related PLCscan cycles). Such is the nature of serial comms (one at a time) and Profibus DP is in principal no different (just heaps faster as the DP Master does take care of it all at a typically quite high baudrate rather than the typical low Modbus RTU baudratetogether withyour OB 1 driven P_SND_RK/P_RCV_RKrelated program "overhead"). Cheers Fritz |
Cheers |
|
This contribution was helpful to1 thankful Users |
7/11/2009 11:39 AM | |
Posts: 382 Rating: (47) |
Dear Kvdm, Hope this attach document can help you to understand better! with regards, how come? AttachmentModbus Over Serial Line_V1.pdf (529 Downloads) |
This contribution was helpful to2 thankful Users |
Follow us on