Znam, znam...
Jednak można inaczej:
Kod: Zaznacz cały
' Mach3, without seriall Modbus plugin, read/write only to two selected inputs & two outputs.
'
' output coil registers: 0-7 single bit each
' discrette input reg.: 0-7 single bit each
' input register: 64-71 two byte each
'
' output coil
For x = 0 To 7 'mach inputs < 63, 8 registers
SetModOutPut(x,1) 'register, state 1
message ("coil" & x & " = 1")
sleep 250
SetModOutPut(x,0) 'register, state 0
message ("coil" & x & " = 0")
sleep 250
Next x
' discrette input register
Dim y (9) As Byte 'one byte, 8 registers
For z = 0 To 7 'mach inputs < 63
y(z) = GetInput (z)
Next z
message ("discrette inputs 0 to 7 = " & y(0) & y(1) & y(2) & y(3) & y(4) & y(5) & y(6) & y(7))
sleep 1000
' input register
Dim q (9) As Double 'two byte, 8 registers
For u = 64 To 71 'mach inputs > 63
v = u - 64 'first place in table > 0
q(v) = GetInput (u)
Next u
message ("register inputs 64 to 71 = " & q(0) & ", " & q(1) & ", " & q(2) & ", " & q(3) & ", " & q(4) & ", " & q(5) & ", " & q(6) & ", " & q(7))
End