SIEMENS西门子辽宁省大连市(授权)一级代理商——西门子东北总代理

供货厂家
广东湘恒智能科技有限公司  
西门子总代理
PLC
西门子一级代
驱动
西门子代理商
伺服电机
报价
电议
联系人
张经理(先生)
手机
15903418770
询价邮件
517987251@qq.com
发布日期
2024-04-04 10:23
编号
13252695
发布IP
120.237.217.245
区域
惠州工控系统及装备
地址
惠州大亚湾澳头石化大道中480号太东天地花园2栋二单元9层01号房
请卖家联系我
详细介绍

Private Sub Q00_Click()
Q0_Value = &H1    ‘&H1是16进制的1,转换成八位二进制就是00000001,这是让Q 0.0=1;如果让Q0.1=1,则=&H2(八位二进制00000010);让Q0.2=1,则=&H4(八位二进制00000100);让Q0.1和Q0.0同时=1,则=&H3(八位二进制00000011);这个值可以是&H0~&HFF中的任意一个值,使Q0.7~Q0.0得到得到不同的状态

Write_Q0 (Q0_Value)
End Sub

Sub Write_Q0(ByRef Q0_Value)

Dim str_write(0 To 37) As Byte
Dim str_val(0 To 5) As Byte
Dim haha As Byte
Dim i As Integer
Dim Temp_FCS As Variant

MSComm1.RThreshold = 24

str_write(0) = &H68
str_write(1) = &H20
str_write(2) = &H20
str_write(3) = &H68
str_write(4) = &H2
str_write(5) = &H0
str_write(6) = &H7C
str_write(7) = &H32
str_write(8) = &H1
str_write(9) = &H0
str_write(10) = &H0
str_write(11) = &H0
str_write(12) = &H0
str_write(13) = &H0
str_write(14) = &HE
str_write(15) = &H0
str_write(16) = &H5
str_write(17) = &H5
str_write(18) = &H1
str_write(19) = &H12
str_write(20) = &HA
str_write(21) = &H10
str_write(22) = &H2
str_write(23) = &H0
str_write(24) = &H1
str_write(25) = &H0
str_write(26) = &H1
str_write(27) = &H82
str_write(28) = &H0
str_write(29) = &H0
str_write(30) = &H0 ' 如果是改写Q0.x,这个地方就=&H0;如果是改写Q1.x,这个地方就是=&H8
str_write(31) = &H0
str_write(32) = &H4
str_write(33) = &H0
str_write(34) = &H8

str_write(35) = Q0_Value  'QB的值,也就是Q0.x或Q1.x的状态


For i = 4 To 35
    Temp_FCS = Temp_FCS + str_write(i)
    Next
str_write(36) = Temp_FCS Mod 256
str_write(37) = &H16
MSComm1.Output = str_write

VB6.0或VBA用PPI协议怎么让S7-200的Q0.1或Q0.0置1

Sleep (50)
str_val(0) = &H10
str_val(1) = &H2
str_val(2) = &H0
str_val(3) = &H5C
str_val(4) = &H5E
str_val(5) = &H16

MSComm1.Output = str_val
End Sub


Private Sub UserForm_Initialize()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,e,8,1"
MSComm1.InputLen = 0
MSComm1.RThreshold = 24
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
End Sub



我们的其他产品
您可能喜欢
 
相关一级代理商产品