12/27/2013 12:14 PM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Dear LKMNVRS, the LADDR := 256 is for the communication between the CPU and the CP through the standard SEND/RECEIVE blocks which are called internal from the MBMA340 block. Therefore the LADDR has to match witch the address configured for the CP340 in the HW-Config. That's it. This address does not specify where to store thedata from the slave. That you need to tell with the S7ADDR. Example for reading data from two slaves: CALL "MBMAREQ" , "MBMAREQ NO.1" // MODBUS MASTER REQUEST FUNCTION BLOCK LINK :="LINK_340" // I-LINK WORD (CONNECT TO MBMA340 FUNCTION BLOCK!) RW :=FALSE // I-FUNCTION = READ SLAVE :=1 // I-SLAVE NUMBER START :=L#43001 // I-START ADDRESS (43001) END :=L#43001 // I-END ADDRESS (43001) WRMODE:=FALSE // I-WRITE MODE = AUTO S7ADDR:="MBDB READ OUTPUT REGS".DATA_BYTE[0] // I-S7 ADDRESS FORMAT:=0 // I-NONE DONE :="DONE_340" // Q-DONE ERROR :="ERROR_340" // Q-ERROR STATUS:="STATUS_340" // Q-STATUS WORD CALL "MBMAREQ" , "MBMAREQ NO.2" // MODBUS MASTER REQUEST FUNCTION BLOCK LINK :="LINK_340" // I-LINK WORD (CONNECT TO MBMA340 FUNCTION BLOCK!) RW :=FALSE // I-FUNCTION = READ SLAVE :=2 // I-SLAVE NUMBER START :=L#43001 // I-START ADDRESS (43001) END :=L#43001 // I-END ADDRESS (43001) WRMODE:=FALSE // I-WRITE MODE = AUTO S7ADDR:="MBDB READ OUTPUT REGS".DATA_BYTE[100]// I-S7 ADDRESS FORMAT:=0 // I-NONE DONE :="DONE_340" // Q-DONE ERROR :="ERROR_340" // Q-ERROR STATUS:="STATUS_340" // Q-STATUS WORD The first request will store the data fromSLAVE 1from DATA BYTE 0onwards, and the second request will storethe data from SLAVE 2 fromDATA BYTE 100 onwards in the "MBDB READ OUTPUT REGS"data block. Sorry for the "sheep" in the post, but stands for 100. Itchanges automatically into a sheep whenI upload thispost. Best Regards. |
Give us your feedback and show us your respect! |
|
12/27/2013 3:28 PM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Dear LKMNVRS, you are absolutly correct and understood the concept of the driver without any documentation. I beleive it is easy to use, even for somebody who does not understand much about modbus. Anyhow, the CRC generation/verification is taken care by the MBMA340 function block internally, so you don't have to worry about it. Let me know if it RUN's Best Regards. |
Give us your feedback and show us your respect! |
|
1/9/2014 10:35 AM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Hi LKMNVRS, most probably you made a configuration/parameter mistake somewhere in your software. Here are some basic rules: - Each MBMAREQ block needs to have his own and unique instance data block. - The CP address at the MBMA340 block has tomatch with the address set in the HW-Config - The LINKfrom the MBMAREQ and MBMA340 has to be the same. If you still cannot find the erroryou canuploadthe software and I can have a quick look at it. Best Regards. . |
Give us your feedback and show us your respect! |
|
1/9/2014 5:52 PM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Hi LKMNVRS, You moved the MBMA340 communication block from the interrupt OB intothe startup OB. How it will now communicate I don't know while it does not get executed after startup. The TX LED MUST FLASH at least! You can do one thing, move the MBMA340 block and put it after the MBMAREQ block in OB1. Does the CPU still goes intoSTOP mode? Did you copied all FB's from the example program? Try to make the example program running withyour CPU. You canuploador send me your program. I will send you my contact details in PM. Best Regards. |
Last edited by: TIBI68 at: 1/9/2014 6:05 PMGive us your feedback and show us your respect! |
|
1/10/2014 7:59 AM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Hi LKMNVRS, so at least it is communicating now and we know about the causestopping the CPU. In order to modify the block calls I will need to edit end recompiletheSCL source. I beleive you cannot do anything unless movingyour driver blocks. Best Regards. |
Give us your feedback and show us your respect! |
|
1/10/2014 7:04 PM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Dear LKMNVRS, you are welcome. If the softwaredoes thejob for you"RATE" it! I like to work with professionals Have a good time. Best Regards. |
Give us your feedback and show us your respect! |
|
This contribution was helpful to1 thankful Users |
6/17/2014 8:21 AM | |
Joined: 12/1/2009 Last visit: 6/7/2024 Posts: 672 Rating: (147) |
Hello LKMNVRSand welcome back! Regarding FB-Numbers I will make an exception for you and send you the program with other function block numbers. I kindly request you to send me a private message withan emailto which I can send the software. Regarding Modbus Function codes I believe that it it easier for a user just to handle with modbus addresses rather than function codes, especially for beginners.The MBMAREQ (FB10) will generate the corresponding modbus function code internally, sothe user does not needto keep themin mind. Number of Registers The number of registers is getting automatically calculated by the MBMAREQ function block as well. (END address register) minus (START address register) + 1 What now? I would request your slave supplier to provide you with a modbus address list. Then you just simply enter these addresses atthe MBMAREQ block which willdo the rest for you (generating the respective modbus function code and number of registers). Modbus cannot be easier. Maybe you can send me the address list and I will have a look at it. Best Regards. Conversion of the first two Modbus requests as per Data MAP (DB201) DB201 Slave Address: 3 Function Code: 2 Start Register: 0 No. of Registers: 200 = MBMAREQ (FB10) RW:=FALSE // I-FUNCTION = READ SLAVE :=3 // I-SLAVE NUMBER
START:=L#10001// I-START ADDRESS (10001) END :=L#10200// I-END ADDRESS (10200) DB201 Slave Address: 3 Function Code: 4 Start Register: 0 No. of Registers: 87 = MBMAREQ (FB10) RW:=FALSE // I-FUNCTION = READ SLAVE :=3 // I-SLAVE NUMBER START:=L#30001// I-START ADDRESS (30001) END :=L#30087// I-END ADDRESS (30087) Best Regards. |
Last edited by: TIBI68 at: 6/17/2014 11:39 AMLast edited by: TIBI68 at: 6/17/2014 11:38 AMData MAP conversion added Give us your feedback and show us your respect! |
|