⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdl_pub.bas

📁 一个根据s7200协议写的驱动控件
💻 BAS
字号:
Attribute VB_Name = "mdl_pub"
Type S7DataUnitCmd_Addr
    Identifier As Byte
    Command As Byte
    D_H10 As Byte
    Data_Size As Byte
    D_H0 As Byte
    Read_Count As Byte
    DataBlockNum(1) As Byte
    Data_Type As Byte
    Address(2) As Byte
End Type

Type s7DataWritePara
     DataMode(1) As Byte
     LengthData(1) As Byte
     Data(3) As Byte
End Type

Public Type S7AckProtocal
   ' SD SA DA FC FCS ED
    SD As Byte  '其中SD为起始符,为10H
    SrcAddr As Byte         'SA为数据源地址
    DstAddr As Byte  'DA为目的地址
    FunctionCode  As Byte     'FC为功能码,取5CH
    FCS As Byte                'FCS为SA DA + FC的和的末字节
    ED As Byte     'ED为结束符,取16H
End Type

Public Type S7DataUnit
    DATA_UNIT_Command() As Byte
    DATA_UNIT_Command_Address As S7DataUnitCmd_Addr
End Type

Public Type S7RorWProtocal
    SD As Byte  'SD:(Start Delimiter)开始定界符(68H)
    Length As Byte       'LE:(Length)报文数据长度
    LengthRepeate  As Byte 'LER:(Repeated Length)重复数据长度
    STARTLIMIT As Byte  'SD: (Start Delimiter)开始定界符(68H)
    SourceAddress As Byte    'SA:(Source Address)源地址,指该地址的指针,为地址值乘以8
    DestinationAddr As Byte  ' DA:(Destination Address)目标地址,指该地址的指针,为地址值乘以8
    FunctionCode As Byte     ' FC:(Function Code)功能码
    DstSrvAccPt As Byte      'DSAP:(Destination Service Access Point)目的服务存取点
    SrcSrvAccPt As Byte  'SSAP:(Source Service Access Point)源服务存取点
    DataUnit As S7DataUnit   'DU:(Data Unit)数据单元
    FCS As Byte  'FCS:(Frame Check Sequence)校验码
    ED As Byte 'ED:(End Delimiter)结束分界符(16H)
    IsWrite As Boolean
    WirteData As s7DataWritePara
End Type


''

'''功能码
Public Const BH_S7_FC_ACK As Byte = &H5C        '报文确认
Public Const BH_S7_FC_READ As Byte = &H6C       ' 读
Public Const BH_S7_FC_WRITE As Byte = &H7C       ' 写
Public Const BH_S7_FC_RET As Byte = &H8          'PLC返回数据功能码


'''公用

Public Const PLC_RET_DATA As Byte = &HE5         'PLC返回确认数据








⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -