B&B Electronics MODSCAN32 - Manual User Manual
Page 82

82
Timer2 is configured to run every 5 seconds. The Serial Port Configuration Property defines the time-out 
associated with the RTU slave device as 1 second. If the user attempts to address a node which is not 
present, no indication will be received, (i.e. the Ready event will not trigger). This is why the first timer 
updates the status text every second asynchronously to the updates. 
 
 
Private Sub Timer2_Timer() 
 
ErrRet = Modbuss1.Update()
End Sub 
 
If the results of the Update Poll are successful, the Modbus Data Control will fire the Ready event, 
signifying that new data is now available to be processed. The application must determine if it is to display 
integer or boolean data by checking the data address. 
 
 
Private Sub Modbuss1_Ready() 
 
If (Modbuss1.Address < 30000) Then
Call update_coils
Else: Call update_regs
End If 
 
Public Sub update_coils() 
 
For i = 0 To 19
If (Modbuss1.Coil(i) = True) Then
Label5(i).Caption = "ON"
Else: Label5(i).Caption = "OFF"
End If
Next i
End Sub 
 
Public Sub update_regs() 
 
For i = 0 To 19
Label5(i).Caption = Format(Modbuss1.Register(i), "00000")
Next i
End Sub 
 
