迪文DGUS通过RS485控制台达PLC继电器

1. 硬件连接指南

台达PLC电源通过220V交流电直供。

触摸屏电源通过PLC自带24V供电即可。

PLC上D+、D- 两个引脚对应连接触摸屏A、B引脚接通RS485通讯。

2. PLC软件配置指南

PLC配置9600波特率,Modbus RTU通讯模式。

迪文DGUS通过RS485控制台达PLC继电器_第1张图片

继电器配置

M0控制Y1

迪文DGUS通过RS485控制台达PLC继电器_第2张图片

D100控制Y2

迪文DGUS通过RS485控制台达PLC继电器_第3张图片

M512(掉电保持)控制Y3

迪文DGUS通过RS485控制台达PLC继电器_第4张图片

触摸屏界面控制程序

点击对应继电器区域,弹出键盘,输入数字1吸合继电器,输入数字2断开继电器。

迪文DGUS通过RS485控制台达PLC继电器_第5张图片

如下是用DGUS屏带的DWIN OS做的二次开发编程。

ORG  1000H
    GOTO MAIN
    
    ORG  1080H
MAIN:
    CALL T300MS
    
    CALL INITE
    
    GOTO MAIN  
;***************

T300MS:    
    LDBR R30,0X00,1
    LDBR R31,0X64,1
    LDBR R32,0X00,1
    LDBR R33,0X96,1
    LDBR R34,0X00,1
    LDBR R35,0XFA,1
    LDBR R36,0X01,1
    LDBR R37,0X2C,1
    MOVDR 37,R25,2
    JU  R25,R30,T300_END   
    LDBR  R80,1,1
    JU  R25,R32,T300_END
    LDBR  R80,2,1
    JU  R25,R34,T300_END
    LDBR  R80,3,1
    JU  R25,R36,T300_END
    LDBR  R80,4,1
    LDBR  R200,0,1
    LDWR  R25,0
    MOVRD R25,37,2
    NOP
    RET
T300_END:
    
    NOP
    RET
;***************
;上电初始化    
INITE:    
	    IJNE      R255,0,INIRET
            LDBR      R255,1,1
            COMSET    40H,1632   
;设置串口4,波特率9600,上电执行一次
            CONFIG    1,2,1
            RET 
           ; LDBR      R250,0,1
            	                     
           ; NOP	   
INIRET:     
            IJNE R80,1,NT1
          
            CALL RDY04
            RET
NT1:        
            IJNE R80,2,NT2
            RET
NT2:        IJNE R80,4,NT3
            RET
NT3:        ;IJNE R81,1,NTRET
            CALL T1014           
            CALL T1015
            CALL T1016             
            CALL T1017   
            CALL T1018 
NTRET:      RET  
RDY04:      
       IJNE      R200,1,SENDR
       IJNE      R201,0,OT_RET
       RDXLEN    4,R40   ;FIFO长度
       IJNE      R40,0,OT_TEST  ;FIFO长度不等于0       
       RET       
SENDR:                            
;读Y0~Y4状态
       LDBR      R90,0x02,1
       LDBR 	 R91,0x02,1    ;命令码 
       LDBR 	 R92,0x05,1    
       LDBR 	 R93,0x00,1  
       LDBR 	 R94,0x00,1
       LDBR 	 R95,0x05,1
       LDBR 	 R11,0x06,1
       CRCA 	 R90,R122,R11   ;6字节做ANSI CRC计算
       MOV  	 R122,R96,2     ;赋值给R96 R97
       LDBR 	 R9,0x08,1
       COMTXD 	 4,R90,R9
       LDBR      R200,1,1 
       LDBR      R201,0,1  
       RET    
OT_TEST:
       MOVDR     17,R41,1
       IJNE      R41,0,OT_RET
       RDXLEN    4,R40
       RDXDAT    4,R50,R40
       IJNE      R50,0X02,OT_RET
       IJNE      R51,0X02,OT_RET
       IJNE      R52,0X01,OT_RET
       
       CALL      SC0
       CALL      SC1
       CALL      SC2
       CALL      SC3
       CALL      SC4
          
       LDBR      R201,1,1

       RET       
OT_RET:
       NOP
       RET   
SC0:   
       LDBR      R0,0X10,1
       LDBR      R1,0X14,1
               
       LDBR      R60,0X01,1
       AND       R60,R53,1
       IJNE      R60,0X01,SC00 
       
       LDBR      R20,0,1
       LDBR      R21,1,1
       MOVXR     R20,0,1   ;写0x0001进变量
       LDBR      R250,0,1
       LDBR      R249,1,1
       RET
SC00:  
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       LDBR      R250,1,1
       LDBR      R249,0,1
       RET
SC1:   
       LDBR      R0,0X10,1
       LDBR      R1,0X15,1
       
       LDBR      R60,0X02,1
       AND       R60,R53,1
       IJNE      R60,0X02,SC10 
       LDBR      R20,0,1
       LDBR      R21,1,1
       MOVXR     R20,0,1   ;写0x0001进变量
       LDBR      R248,0,1
       LDBR      R247,1,1
       
       RET
SC10:  
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       LDBR      R248,1,1
       LDBR      R247,0,1
       
       RET
SC2:   
       LDBR      R0,0X10,1
       LDBR      R1,0X16,1
       
       LDBR      R60,0X04,1
       AND       R60,R53,1
       IJNE      R60,0X04,SC20 
       
       LDBR      R20,0,1
       LDBR      R21,1,1
       MOVXR     R20,0,1   ;写0x0001进变量
       LDBR      R246,0,1
       LDBR      R245,1,1
       RET
SC20:  
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       LDBR      R246,1,1
       LDBR      R245,0,1
       RET
SC3:   
       LDBR      R0,0X10,1
       LDBR      R1,0X17,1
       
       LDBR      R60,0X08,1
       AND       R60,R53,1
       IJNE      R60,0X08,SC30 
       
       LDBR      R20,0,1
       LDBR      R21,1,1
       MOVXR     R20,0,1   ;写0x0001进变量
       LDBR      R244,0,1
       LDBR      R243,1,1
       RET
SC30:  
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       LDBR      R244,1,1
       LDBR      R243,0,1
       RET
SC4:   
       LDBR      R0,0X10,1
       LDBR      R1,0X18,1 
             
       LDBR      R60,0X10,1
       AND       R60,R53,1
       IJNE      R60,0X10,SC40 
       
       LDBR      R20,0,1
       LDBR      R21,1,1
       MOVXR     R20,0,1   ;写0x0001进变量
       LDBR      R242,0,1
       LDBR      R241,1,1
       RET
SC40:  
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       LDBR      R242,1,1
       LDBR      R241,0,1
       RET 
;********************   
T1014:                   ;直接操作Y0寄存器  装置地址0x500
       LDBR  R0,0X10,1
       LDBR  R1,0X24,1 
       MOVXR R20,1,1    
       IJNE  R20,0,E1014
       IJNE  R21,0,N1014
       RET
N1014:
       IJNE  R21,1,C1014
       CALL  O1014
       RET
E1014:
       NOP
       RET
C1014: IJNE  R21,2,E1014
       LDBR 	 R101,0x05,1   ;命令码
       LDBR 	 R102,0x05,1   ;0x0500   Y0继电器
       LDBR 	 R103,0x00,1  
       LDBR 	 R104,0x00,1
       LDBR 	 R105,0x00,1
       
       CALL      U4TX
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       RET
O1014:
      LDBR 	R101,0x05,1    ;命令码
      LDBR 	R102,0x05,1    ;0x0500   Y0继电器
      LDBR 	R103,0x00,1  
      LDBR 	R104,0xFF,1
      LDBR 	R105,0x00,1
      CALL      U4TX
      LDBR      R20,0,1
      LDBR      R21,0,1
      MOVXR     R20,0,1   ;写0x0000进变量 
      RET
T1015:                   ;直接操作Y0寄存器  装置地址0x500
       LDBR  R0,0X10,1
       LDBR  R1,0X25,1 
       MOVXR R20,1,1    
       IJNE  R20,0,E1015
       IJNE  R21,0,N1015
       RET
N1015:
       IJNE  R21,1,C1015
       CALL  O1015
       RET
E1015:
       NOP
       RET
C1015: 
       IJNE      R21,2,E1015
       LDBR 	 R101,0x05,1    ;命令码
       LDBR 	 R102,0x08,1    ;0x0800   M0辅助继电器
       LDBR 	 R103,0x00,1  
       LDBR 	 R104,0x00,1
       LDBR 	 R105,0x00,1
       
       CALL      U4TX
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       RET
O1015:
      LDBR 	R101,0x05,1    ;命令码 
      LDBR 	R102,0x08,1    ;0x0800   M0辅助继电器
      LDBR 	R103,0x00,1  
      LDBR 	R104,0xFF,1
      LDBR 	R105,0x00,1
      CALL      U4TX
      LDBR      R20,0,1
      LDBR      R21,0,1
      MOVXR     R20,0,1   ;写0x0000进变量 
      RET      
T1016:                   ;直接操作Y0寄存器  装置地址0x500
       LDBR  R0,0X10,1
       LDBR  R1,0X26,1 
       MOVXR R20,1,1    
       IJNE  R20,0,E1016
       IJNE  R21,0,N1016
       RET
N1016:
       IJNE  R21,1,C1016
       CALL  O1016
       RET
E1016:
       NOP
       RET
C1016: 
       IJNE      R21,2,E1016
       LDBR 	 R101,0x06,1    ;命令码
       LDBR 	 R102,0x10,1    ;0x1064   D100
       LDBR 	 R103,0x64,1  
       LDBR 	 R104,0x00,1
       LDBR 	 R105,0x00,1
       
       CALL      U4TX
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量
       RET
O1016:
      LDBR 	R101,0x06,1    ;命令码 
      LDBR 	R102,0x10,1    ;0x1064   D100
      LDBR 	R103,0x64,1  
      LDBR 	R104,0x00,1
      LDBR 	R105,0x01,1
      CALL      U4TX
      LDBR      R20,0,1
      LDBR      R21,0,1
      MOVXR     R20,0,1   ;写0x0000进变量 
      RET
   
T1017:
       LDBR  R0,0X10,1
       LDBR  R1,0X27,1 
       MOVXR R20,1,1    
       IJNE  R20,0,E1017
       IJNE  R21,0,N1017
       RET
N1017:
       IJNE  R21,1,C1017
       CALL  O1017
       RET
E1017:
       NOP
       RET
C1017: 
       IJNE      R21,2,E1017
       LDBR 	 R101,0x05,1    ;命令码
       LDBR 	 R102,0x0A,1    ;0x0A00   M512辅助继电器 掉电保持
       LDBR 	 R103,0x00,1  
       LDBR 	 R104,0x00,1
       LDBR 	 R105,0x00,1
       
       CALL      U4TX
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量 
       RET
O1017:
      LDBR 	R101,0x05,1    ;命令码 
      LDBR 	R102,0x0A,1    ;0x0A00   M512辅助继电器 掉电保持
      LDBR 	R103,0x00,1  
      LDBR 	R104,0xFF,1
      LDBR 	R105,0x00,1
      CALL      U4TX
      LDBR      R20,0,1
      LDBR      R21,0,1
      MOVXR     R20,0,1   ;写0x0000进变量  
      RET
T1018:
       LDBR  R0,0X10,1
       LDBR  R1,0X28,1 
       MOVXR R20,1,1    
       IJNE  R20,0,E1018
       IJNE  R21,0,N1018
       RET
N1018:
       IJNE  R21,1,C1018
       CALL  O1018
       RET
E1018:
       NOP
       RET
C1018: IJNE      R21,2,E1018
       LDBR 	 R101,0x06,1    ;命令码
       LDBR 	 R102,0x11,1    ;0x1198   D408 掉电保持
       LDBR 	 R103,0x98,1   
       LDBR 	 R104,0x00,1
       LDBR 	 R105,0x00,1
       
       CALL      U4TX
       LDBR      R20,0,1
       LDBR      R21,0,1
       MOVXR     R20,0,1   ;写0x0000进变量  
       RET
O1018:
      LDBR 	R101,0x06,1    ;命令码 
      LDBR 	R102,0x11,1    ;0x1198   D408 掉电保持
      LDBR 	R103,0x98,1  
      LDBR 	R104,0x00,1
      LDBR 	R105,0x01,1
      CALL      U4TX
      LDBR      R20,0,1
      LDBR      R21,0,1
      MOVXR     R20,0,1   ;写0x0000进变量   
      RET
U4TX:
       LDBR      R100,0x02,1   ;02 05 05 00 FF 00 8C C5
       
            
       LDBR 	 R10,0x06,1
       CRCA 	 R100,R120,R10   ;6字节做ANSI CRC计算
       MOV  	 R120,R106,2     ;赋值给R106 R107
       LDBR 	 R9,0x08,1
       COMTXD 	 4,R100,R9 
       RET

 

你可能感兴趣的:(迪文)