台达VFD通讯示例.docx
《台达VFD通讯示例.docx》由会员分享,可在线阅读,更多相关《台达VFD通讯示例.docx(11页珍藏版)》请在冰豆网上搜索。
![台达VFD通讯示例.docx](https://file1.bdocx.com/fileroot1/2023-2/23/31b2fcf0-ebe0-48c5-b40b-753cc338107f/31b2fcf0-ebe0-48c5-b40b-753cc338107f1.gif)
台达VFD通讯示例
台达VFD-B变频器串口通信中,频率设定,还有正转、反转、停止字符串是怎样写?
范例1:
设定VFD-B系列变频器的频率为30.00Hz,通讯格式为9600,8,N,2,RTU
010620010BB8D488
范例2:
设定VFD-B系列变频器正转,通讯格式为9600,8,N,2,RTU
0106200000220213
范例3:
设定VFD-B系列变频器停止,通讯格式为9600,8,N,2,RTU
01062000000143CA
西门子与台达变频器通讯
ORGANIZATION_BLOCK 主程序:
OB1
TITLE=实现S7-200 PLC与台达变频器通信
// 实现功能是PLC通过RS485通信控制变频器的正转启动、反转启动、停止、加速、减速和读取输出频率。
变频器通过Modbus通信方式进行
// 要求台达变频器设置基本通信参数:
// P00=d03(主频率由RS485控制)
// P01=d03(运转/停止由RS485通信控制)
// P88=d01(站点定义为1号站)
// P90=d00 P91=d00 P92=d02 P113=d01
// (其他参数都是出厂默认值,可根据实际情况调节)
//
BEGIN
Network 1
LD SM0.1
CALL SBR0
Network 2 // 正转启动命令
LD M10.0
EU
MOVB 16#30, VB104
MOVB 16#36, VB105
MOVB 16#32, VB106
MOVB 16#30, VB107
MOVB 16#30, VB108
MOVB 16#30, VB109
MOVB 16#30, VB110
MOVB 16#30, VB111
MOVB 16#31, VB112
MOVB 16#32, VB113
CALL SBR1
Network 3 // 反转启动指令
LD M10.1
EU
MOVB 16#30, VB104
MOVB 16#36, VB105
MOVB 16#32, VB106
MOVB 16#30, VB107
MOVB 16#30, VB108
MOVB 16#30, VB109
MOVB 16#30, VB110
MOVB 16#30, VB111
MOVB 16#32, VB112
MOVB 16#32, VB113
CALL SBR1
Network 4 // 停止指令
LD M10.2
EU
MOVB 16#30, VB104
MOVB 16#36, VB105
MOVB 16#32, VB106
MOVB 16#30, VB107
MOVB 16#30, VB108
MOVB 16#30, VB109
MOVB 16#30, VB110
MOVB 16#30, VB111
MOVB 16#30, VB112
MOVB 16#31, VB113
CALL SBR1
Network 5 // 1秒脉冲
LDN T37
TON T37, 10
Network 6 // 加速指令(每1秒步进加速0.01Hz)
LD M10.3
A T37
INCW VW135
Network 7 // 减速指令(每1秒步进减速0.01Hz)
LD M10.4
A T37
DECW VW135
Network 8 // 上限频率50.00Hz
LDW>= VW135, 5000
MOVW 5000, VW135
Network 9 // 下限频率0.1Hz
LDW<= VW135, 10
MOVW 10, VW135
Network 10 // 凡有频率改变,调用子程序3
LDW<> VW135, VW145
O SM0.1
CALL SBR3
Network 11 // 读取输出频率指令
LD M10.5
EU
MOVB 16#30, VB104
MOVB 16#33, VB105
MOVB 16#32, VB106
MOVB 16#31, VB107
MOVB 16#30, VB108
MOVB 16#33, VB109
MOVB 16#30, VB110
MOVB 16#30, VB111
MOVB 16#30, VB112
MOVB 16#31, VB113
S M20.0, 1
CALL SBR1
Network 12 // 当读取频率时,执行频率显示运算子程序
LD SM4.5
A M20.1
CALL SBR2
Network 13 // SMB86=0表示正在接收,但本例是利用中断来接收
LDB<> SMB86, 0
MOVB SMB86, VB400
Network 14 // 发送完成标志
LD SM4.5
= Q0.0
END_ORGANIZATION_BLOCK
SUBROUTINE_BLOCK SBR_0:
SBR0
TITLE=通信初始化参数子程序
BEGIN
Network 1 // 初始化通信参数及定义开始符、终止符等接收信息
LD SM0.0
MOVB 16#69, SMB30
MOVB 16#E0, SMB88
MOVB 16#3A, SMB89
MOVB 18, SMB94
Network 2 // 初始化固定参数
LD SM0.0
MOVB 16#3A, VB101
MOVB 16#30, VB102
MOVB 16#31, VB103
MOVB 16#0D, VB116
MOVB 16#0A, VB117
Network 3 // 声明使用发送完成中断
LD SM0.0
ATCH INT0, 9
ENI
END_SUBROUTINE_BLOCK
SUBROUTINE_BLOCK SBR_1:
SBR1
TITLE=计算校验及子程序
BEGIN
Network 1 // 建立指针及参数清零等初始化
LD SM0.0
MOVD &VB101, VD131
MOVW 0, VW129
MOVW 6, VW127
MOVW 0, AC0
MOVW 0, AC1
MOVW 0, AC2
MOVW 0, AC3
Network 2 // 循环计算原始累加和
LD SM0.0
FOR VW125, 1, VW127
Network 3
LD SM0.0
LPS
MOVW *VD131, AC0
ANDW 16#FF, AC0
AB> AC0, 16#39
MOVW AC0, AC1
-I 16#37, AC1
LRD
AB<= AC0, 16#39
MOVW AC0, AC1
-I 16#30, AC1
LRD
INCD VD131
LRD
MOVW *VD131, AC0
ANDW 16#FF, AC0
LRD
AB> AC0, 16#39
MOVW AC0, AC2
-I 16#37, AC2
LRD
AB<= AC0, 16#30
MOVW AC0, AC2
-I 16#30, AC2
LRD
SLB AC1, 4
LRD
MOVW AC1, AC3
+I AC2, AC3
LRD
+I AC3, VW129
LPP
+D 1, VD131
Network 4
NEXT
Network 5 // 指针加一,指向下一个
LD SM0.0
MOVW 0, AC2
MOVW 0, AC3
+D 1, VD131
Network 6
LD SM0.0
LPS
MOVW 16#FF, AC0
ANDW VW129, AC0
INVW AC0
MOVW 1, VW800
+I AC0, VW800
MOVB VB801, AC2
SRB AC2, 4
AW> AC2, 9
+I 16#37, AC2
LRD
MOVB AC2, *VD131
LRD
+D 1, VD131
LRD
MOVB VB801, AC3
ANDB 16#0F, AC3
LRD
AW> AC3, 9
+I 16#37, AC3
LRD
AW<= AC3, 9
+I 16#30, AC3
LPP
MOVB AC3, *VD131
Network 7 // 发送前,强行禁止接收
LD SM0.0
MOVB 16#70, SMB87
RCV VB200, 0
Network 8 // 开始发送
LD SM0.0
MOVB 17, VB100
XMT VB100, 0
FILL 0, VW200, 9
Network 9 // 发送后允许接收
LD SM0.0
MOVB 16#F0, SMB87
END_SUBROUTINE_BLOCK
SUBROUTINE_BLOCK SBR_2:
SBR2
TITLE=频率显示运算子程序
VAR
LIN1:
DWORD;
lLIN2:
DWORD;
LIN3:
DWORD;
LIN4:
DWORD;
END_VAR
BEGIN
Network 1 // 把接收到的16进制ASCII码信息,转换成习惯的小数点形式
LD SM0.0
BTI VB2008, LW0
BTI VB2009, LW2
BTI VB2010, LW4
BTI VB2011, LW6
Network 2
LD SM0.0
LPS
AW> LW0, 16#40
MOVW LW0, AC0
-I 16#37, AC0
LPP
AW< LW0, 16#40
MOVW LW0, AC0
-I 16#30, AC0
Network 3
LD SM0.0
LPS
AW> LW2, 16#40
MOVW LW2, AC1
-I 16#37, AC1
LPP
AW< LW2, 16#40
MOVW LW2, AC1
-I 16#30, AC1
Network 4
LD SM0.0
LPS
AW> LW4, 16#40
MOVW LW4, AC2
-I 16#37, AC2
LPP
AW< LW4, 16#40
MOVW LW4, AC2
-I 16#30, AC2
Network 5
LD SM0.0
LPS
AW> LW6, 16#40
MOVW LW6, AC3
-I 16#37, AC3
LPP
AW< LW6, 16#40
MOVW LW6, AC3
-I 16#30, AC3
Network 6
LD SM0.0
MOVB AC0, LB8
SLB LB8, 4
MOVB AC2, LB9
SLB LB9, 4
Network 7
LD SM0.0
MOVB LB8, VB3200
ORB AC1, VB3200
Network 8
LD SM0.0
MOVB LB9, VB3201
ORB AC3, VB3201
Network 9
LD SM0.0
ITD VW3200, VD3300
DTR VD3300, VD3304
MOVR VD3304, VD3308
/R 100.0, VD3308
Network 10
LD SM0.0
R M20.1, 1
END_SUBROUTINE_BLOCK
SUBROUTINE_BLOCK SBR_3:
SBR3
TITLE=输出频率通信格式整理子程序
BEGIN
Network 1 // 凡是有输出频率,频率改变
LD SM0.0
MOVB 16#30, VB104
MOVB 16#36, VB105
MOVB 16#32, VB106
MOVB 16#30, VB107
MOVB 16#30, VB108
MOVB 16#31, VB109
MOVW VW135, VW137
MOVW 0, AC0
MOVW 0, AC1
MOVW 0, AC2
MOVW 0, AC3
Network 2
LD SM0.0
LPS
MOVB VB137, AC0
ANDB 16#0F, AC0
AW> AC0, 9
+I 16#37, AC0
LRD
AW<= AC0, 9
+I 16#30, AC0
LRD
ITB AC0, VB111
LRD
MOVB VB138, AC1
ANDB 16#0F, AC1
LRD
AW> AC1, 9
+I 16#37, AC1
LRD
AW<= AC1, 9
+I 16#30, AC1
LPP
ITB AC1, VB113
Network 3
LD SM0.0
LPS
MOVW VW137, VW139
SRW VW139, 4
MOVB VB139, AC2
ANDB 16#0F, AC2
AW> AC2, 9
+I 16#37, AC2
LRD
AW<= AC2, 9
+I 16#30, AC2
LRD
ITB AC2, VB110
LRD
MOVB VB140, AC3
ANDB 16#0F, AC3
LRD
AW> AC3, 9
+I 16#37, AC3
LRD
AW<= AC3, 9
+I 16#30, AC3
LRD
ITB AC3, VB112
LRD
MOVW VW135, VW145
LPP
CALL SBR1
END_SUBROUTINE_BLOCK
INTERRUPT_BLOCK INT_0:
INT0
TITLE=发送完成中断程序
BEGIN
Network 1 // 除读取频率其他指令返回信息
LD M20.0
RCV VB200, 0
Network 2 // 读取频率返回信息
LD M20.0
RCV VB2000, 0
S M20.1, 1
R M20.0, 1
END_INTERRUPT_BLOCK