AdvancedHMI Software
General Category => Open Discussion => Topic started by: FuzyDragon on October 20, 2015, 01:51:40 PM
-
I'm currently working on a way to read multiple PLC Addresses in a single call as opposed to individually stating each Address (because I have a lot of addresses to read). The code I have so far looks like this: Inside a ButtonClick trigger I have the driver read the addresses and create the array
For x As Integer = 1 To 120
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].in1", 120)
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].in2", 120)
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].in3", 120)
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].out1", 120)
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].out2", 120)
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[" & x.ToString & "].out3", 120)
Next
Then when data is received I use this piece of code
Private Sub EthernetIPforMicro800Com1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles EthernetIPforMicro800Com1.DataReceived
For x As Integer = 1 To 120
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].in1 " Then
For index As Integer = 0 To 119
CalDataToLog(index) = e.Values(index)
Next
End If
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].in2" Then
For index As Integer = 131 To 250
CalDataToLog(index) = e.Values(index)
Next
End If
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].in3" Then
For index As Integer = 262 To 381
CalDataToLog(index) = e.Values(index)
Next
End If
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].out1" Then
For index As Integer = 393 To 512
CalDataToLog(index) = e.Values(index)
Next
End If
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].out2" Then
For index As Integer = 524 To 643
CalDataToLog(index) = e.Values(index)
Next
End If
If e.PlcAddress = "DAQThermocouple[" & x.ToString & "].out3" Then
For index As Integer = 655 To 774
CalDataToLog(index) = e.Values(index)
Next
End If
Next
End Sub
None of this actually catches the data though. I think it may be a problem with reading the PLC Addresses initially but I'm not sure.
Thanks in advance for any advice or help
-
Your read loop is going to try to preform 86,400 reads. If you break out your for-Next loop, this is what it would look like:
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[1].in1", 120) '* Read elements 1-121
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[2].in1", 120) '* Read elements 2-122
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[3].in1", 120) '* Read elements 3-123
EthernetIPforMicro800Com1.BeginRead("DAQThermocouple[4].in1", 120) '* Read elements 4-124
.
.
.
My guess is that is not your intention
-
OK I see my issue with the read portion. Thank you for the quick response.