抖音粉丝群1
『7x24小时有问必答』

ModbusTCP is used as a communication protocol to establish communication whit the third-part devices, polling is uesd in most case to read the state of the third-party devices. the following "CASE"statement can be use to compile polling programs to provide ideas.(This statement is tested on a specific device and does not guarantee that is meets other devices. It needs to be modified according to the actual parameters of the thied-part devices before use. )

在TIA中使用ModbusTCP作为通信协议第三方设备建立通信时,大部分情况会用到轮询来读取第三方设备的状态编写轮询程序是可通过下面的CASE语句编写,提供思路(该语句在特定设备上测试完成,不保证满足其他所设备,使用前需要根据第三方设备的实际参数进行修改,这里只提供思路

    CASE #Polling_Step OF
        0:
            IF #Polling_condition
            THEN
                ##Polling_Step := 1;
            END_IF;
            
        1:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 0;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43000;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 11;
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                
                MOVE_BLK(IN := #S_MB_Communication.DATA.Mb_Data[0],
                         COUNT := 11,
                         OUT => #MB_Client.DATA.Data_Conversion.Local_Data.IN_1[0]);
                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 2;
            END_IF;
            
            
        2:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 0;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43060;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 9;
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                
                MOVE_BLK(IN := #S_MB_Communication.DATA.Mb_Data[0],
                         COUNT := 9,
                         OUT => #MB_Client.DATA.Data_Conversion.Local_Data.IN_2[0]);
                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 3;
            END_IF;
            
        3:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 0;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43197;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 3;
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                
                MOVE_BLK(IN := #S_MB_Communication.DATA.Mb_Data[0],
                         COUNT := 3,
                         OUT => #MB_Client.DATA.Data_Conversion.Local_Data.IN_3[0]);
                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 4;
            END_IF;
        4:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 0;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43431;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 49;
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                
                MOVE_BLK(IN := #S_MB_Communication.DATA.Mb_Data[0],
                         COUNT := 49,
                         OUT => #MB_Client.DATA.Data_Conversion.Local_Data.IN_4[0]);
                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 5;
            END_IF;
        5:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 2;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43060;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 11;
            
            MOVE_BLK(IN := #MB_Client.DATA.Data_Conversion.Local_Data.OUT_1[0],
                     COUNT := 9,
                     OUT => #S_MB_Communication.DATA.Mb_Data[0]);
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                

                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 6;
            END_IF;
        6:
            #S_MB_Communication.IN.MB_Pmr.MB_MODE := 2;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_ADDR := 43198;
            #S_MB_Communication.IN.MB_Pmr.MB_DATA_LEN := 2;
            
            MOVE_BLK(IN := #MB_Client.DATA.Data_Conversion.Local_Data.OUT_2[0],
                     COUNT := 2,
                     OUT => #S_MB_Communication.DATA.Mb_Data[0]);
            
            #S_MB_Communication.IN.REQ := true;
            IF
                #S_MB_Communication.OUT.Done
            THEN
                

                
                #S_MB_Communication.IN.REQ := FALSE;
                
                ##Polling_Step := 1;
            END_IF;
            
    END_CASE;

    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    上一主题上一主题         下一主题下一主题
    QQ手机版小黑屋粤ICP备17165530号

    关于我们·投诉举报· 用户帮助· 联系我们 · 本站服务 · 版权声明· 隐私政策 · 投搞指南

    法律保护:PLC技术网,plcjs.com,plcjs.net等字样
    Copyright 2010-2030. All rights reserved. 


    微信公众号二维码 抖音二维码 百家号二维码 今日头条二维码哔哩哔哩二维码