APPENDIX
(2) Sample program
The following sample program reads D0 to D4 (five points) of the target PLC using the logical station number.
(a)When Visual Basic® is used
1)Screen example (Form1)
Text1
' Enter the logical station number.
Command1
' Connect to the communication line.
Command2
' Read the device data.
Command3
' Cut the communication line.
ACT control (ActEasy IF)
'ACT control for utility setting type
2)Program example
Private Sub Command1_Click()
'
'Connection
'
Dim rtn As Long
' Get LogicalstationNumber
ActEasyIF1. ActLogicalStationNumber = Val(Text1.Text)
' Connection
rtn = ActEasyIF1. Open() If rtn = 0 Then
MsgBox "The connection was successful" Else
MsgBox "Connection Error:" & Hex(rtn) End If
End Sub
Private Sub Command2_Click()
'
'Read
'
Dim rtn As Long
Dim idata(5) As Integer
'
rtn = ActEasyIF1. ReadDeviceBlock2 ("D0", 5, idata(0)) If rtn = 0 Then
MsgBox
MsgBox "Read Error:" & Hex(rtn) End If
End Sub
App. - 27 | App. - 27 |