6/29/2020 12:27 PM | |
Joined: 4/26/2016 Last visit: 8/6/2024 Posts: 42 Rating: (0) |
Hi, I am using S7-300 CPU315-2PN/DP to work like ModbusTCP client and acquire data at every second from the third Party Modbus Device. I am using TAI portal for S7-300 PLC programming. After little modification in the modbusTCP example as in the attached TAI portal Program. But i can connect with the device but not able to get data from the holding register. In my case PLC IP address is 192.168.1.101 and HRM-0800 modbus device address is 192.168.1.112. OB100 is programmed as -------------- // for initialization CALL MODBUSPN , "MODBUSPN_DB" id :="MODBUS_PARAM".Connection_1."Connection settings".id db_param :="MODBUS_PARAM" REG_KEY_DB :="LICENSE_DB" RECV_TIMEOUT :="CONTROL_DAT".RECV_TIME CONN_TIMEOUT :="CONTROL_DAT".CONN_TIME DISCONNECT :="CONTROL_DAT".DISCONNECT ENQ_ENR :="CONTROL_DAT".ENQ_ENR LICENSED :="CONTROL_DAT".LICENSED CONN_ESTABLISHED :="CONTROL_DAT".CONN_ESTABLISHED BUSY :="CONTROL_DAT".BUSY DONE_NDR :="CONTROL_DAT".DONE_NDR ERROR :="CONTROL_DAT".ERROR STATUS :="CONTROL_DAT".STATUS STATUS_FUNC :="CONTROL_DAT".STATUS_FUNC IDENT_CODE := Init_Error :="CONTROL_DAT".Init_Error Init_Status :="CONTROL_DAT".Init_Status UNIT :="CONTROL_DAT".UNIT DATA_TYPE :="CONTROL_DAT".DATA_TYPE START_ADDRESS :="CONTROL_DAT".START_ADDRESS LENGTH :="CONTROL_DAT".LENGTH WRITE_READ :="CONTROL_DAT".WRITE_READ Init :="CONTROL_DAT".Init L t#500ms T "CONTROL_DAT".RECV_TIME L t#5s T "CONTROL_DAT".CONN_TIME SET S "CONTROL_DAT".Init --------------------------------------- OB1 is programmed ---------------------------------- // Reset trigger after job has started A "CONTROL_DAT".ENQ_ENR R "CONTROL_DAT".ENQ_ENR // For cyclic data exchange remove the comment characters O "CONTROL_DAT".DONE_NDR O "CONTROL_DAT".ERROR SET = "CONTROL_DAT".ENQ_ENR A "CONTROL_DAT".DONE_NDR CLR = "CONTROL_DAT".ENQ_ENR // JCN Err // Job finished without error L "CONTROL_DAT".Count_Done//for test purposes + 1 T "CONTROL_DAT".Count_Done // You can set the parameters for the next job here // It is set in comments to give you the possibility // to use the variable table for changes during test L 2 T "CONTROL_DAT".UNIT L 3 T "CONTROL_DAT".DATA_TYPE L 10 T "CONTROL_DAT".START_ADDRESS L 5 T "CONTROL_DAT".LENGTH CLR = "CONTROL_DAT".WRITE_READ SET = "CONTROL_DAT".ENQ_ENR//job trigger JU End Err: A "CONTROL_DAT".ERROR JCN End // Job finished with error L "CONTROL_DAT".Count_Error//for test purposes + 1 T "CONTROL_DAT".Count_Error L "CONTROL_DAT".STATUS T "CONTROL_DAT".Save_STATUS//for static display in VAT // STATUS_FUNC => Save_STATUS_FUNC CALL BLKMOV blk_type:=Any SRCBLK :="CONTROL_DAT".STATUS_FUNC RET_VAL :=#BLKMOV_RetVal DSTBLK :="CONTROL_DAT".Save_STATUS_FUNC End: NOP 0 --------------------- MODBUS_PARAM is programmed ------------ Connection settings Struct 0.0 block_length Word 0.0 W#16#0040 id Word 2.0 16#0001 connection_type Byte 4.0 16#0011 active_est Bool 5.0 TRUE local_device_id Byte 6.0 16#0002 local_tsap_id_len Byte 7.0 16#0 rem_subnet_id_len Byte 8.0 16#0 rem_staddr_len Byte 9.0 16#0004 rem_tsap_id_len Byte 10.0 16#0002 next_staddr_len Byte 11.0 16#0 local_tsap_id Array[1..16] of Byte 12.0 local_tsap_id[1] Byte 12.0 16#0001 local_tsap_id[2] Byte 13.0 16#00F6 rem_staddr[1] Byte 34.0 16#00C0 rem_staddr[2] Byte 35.0 16#00A8 rem_staddr[3] Byte 36.0 16#0001 rem_staddr[4] Byte 37.0 16#0070 rem_staddr[5] Byte 38.0 16#0 for client address 192.168.1.112 rem_tsap_id Array[1..16] of Byte 40.0 rem_tsap_id[1] Byte 40.0 16#0001 rem_tsap_id[2] Byte 41.0 16#00F6 ----------------------------- If you can guide me why i am not getting data on the CPU data block, i will be thankful. Thanks ------------------------------------------------------------------------------------------ |
Last edited by: Jen_Moderator at: 06/29/2020 14:20:53New subject after splitting |
|
7/1/2020 2:13 PM | |
Joined: 10/3/2008 Last visit: 8/28/2024 Posts: 961 Rating: (124)
|
Hi, what is the problem now? Wüstenräuber |
7/2/2020 7:56 AM | |
Joined: 4/26/2016 Last visit: 8/6/2024 Posts: 42 Rating: (0) |
The result with online is attached With "JCN Err" and commented "JCN Err" AttachmentPLCModbusOnline.docx (680 Downloads) |
7/2/2020 8:05 AM | |
Joined: 4/26/2016 Last visit: 8/6/2024 Posts: 42 Rating: (0) |
The complete project is attached for your reference.. The PLC address is 192.168.1.101 The modbusTCP device IP address is 192.168.1.112. Thanks Vishnu AttachmentMODBUS300Test.zip (690 Downloads) |
Follow us on