If I am interpreting this correctly, you want to monitor 500 bits. If this is the case, the DataSubscriber will not be the best solution. The DataSubscriber was created allow subscribing to a small number of items without the need to write code.
I will give you a lower level solution to subscribe to 500 elements directly to the driver. The Modbus driver does not support subscribing to arrays, so an individual subscription has to be created for each item.
Start by right clicking a blank area in your MainForm and select View Code. Then paste the following code:
Code:
Private SubscriptionID(500) As Integer
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
For i = 1 To 500
SubscriptionID(i) = ModbusTCPCom1.Subscribe("0000" & CStr(i), 1, 100, AddressOf ModbusTCPCom1_DataReceived)
Next
Catch ex As Exception
Dim dbg = 0
End Try
End Sub
Private LastValues(500) As String
Private Sub ModbusTCPCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
Dim index As Integer = CInt(e.PlcAddress)
'* Make sure data has been return
If e.ErrorId = 0 AndAlso e.Values.Count > 0 Then
'* Did the value change?
If e.Values(0) <> LastValues(index) Then
'* Save this value for the next roudn trip comparison
LastValues(index) = e.Values(0)
'* Is it true?
If String.Compare(e.Values(0), "True", True) = 0 Then
Try
'* Place your code here that you want to do when a bit has gone true
'MsgBox("Item " & e.PlcAddress & " has went true")
Catch ex As Exception
'* Show the error
MsgBox(ex.Message)
End Try
End If
End If
End If
End Sub
This may seem a bit complicated because it is directly subscribing to the driver, but it is the most efficient method.
From here you can fill in the area with the code such as your database writing.