文件名称:松下FP系列PLC与VB通信源码
文件大小:12KB
文件格式:RAR
更新时间:2014-11-27 07:52:50
VB 松下 PLC FP0 C32
以前调试设备使用过很多次,现在将这些功能整合,可以作为松下PLC与上位机VB通信的初级教程。有多个应用,以下为部分。 Public Function ImadacommPanasonic(Mymscomm As MSComm, ByVal id As Integer) Mymscomm.CommPort = id Mymscomm.Settings = "9600,o,8,1" Mymscomm.InBufferSize = 1024 Mymscomm.OutBufferSize = 512 Mymscomm.InputLen = 0 Mymscomm.InputMode = comInputModeText Mymscomm.Handshaking = comNone Mymscomm.PortOpen = True FlagConnectOK = True End Function Public Function ImadacommPanasonicOFF(Mymscomm As MSComm, ByVal id As Integer) Mymscomm.CommPort = id Mymscomm.Settings = "9600,o,8,1" Mymscomm.InBufferSize = 1024 Mymscomm.OutBufferSize = 512 Mymscomm.InputLen = 0 Mymscomm.InputMode = comInputModeText Mymscomm.Handshaking = comNone Mymscomm.PortOpen = False End Function '==============================读取D寄存区地址数据=============================== Public Function ReadNAIS_D(ByVal PLCAddress As String, ByVal ValueNum As String, ByVal PLCINstr As String, Mymscomm As MSComm) Dim OutString As String Dim instring As String Dim strMsg As String Dim fcdd As String Dim PLCOutAdd(1) As String Dim start PLCOutAdd(0) = add_0_N(PLCAddress, 5) PLCOutAdd(1) = add_0_N(CStr(Val(PLCAddress) + Val(ValueNum) - 1), 5) OutString = "#RDD" + PLCOutAdd(0) + PLCOutAdd(1) fcdd = CalBcc(OutString) OutString = OutString + fcdd + vbCr Mymscomm.Output = OutString start = Timer Do DoEvents strMsg = strMsg & Mymscomm.Input Loop Until Abs(Timer - start) > 0.1 Or Right(strMsg, 1) = vbCr If Mid(strMsg, 4, 1) = "$" Then instring = Mid(strMsg, 7, 4 * CLng(ValueNum)) ReadNAIS_D = ChangeHexHL_NW(instring) ElseIf Mid(strMsg, 4, 1) = "!" Then MsgBox ErrorCode(Mid(strMsg, 5, 2)) End If End Function
【文件预览】:
松下PLC与上位机通信模块(V1.0)
----FrmMain.frm(481B)
----松下PLC_VB.vbw(115B)
----FrmPLC.frm(58KB)
----ReadPLC.bas(13KB)
----public.bas(14KB)
----松下PLC_VB.vbp(971B)
----FrmPLC.frx(182B)