AdvancedHMI Software
General Category => Support Questions => Topic started by: vitico bon on January 09, 2017, 10:01:08 AM
-
Archie/Godra,
In my test for OPC I got now data coming, it is a very simple test, just two BasicLabel, one Barlevel, one label to see when the Timer occurs and one ProgressBarEx that need to be handle manually.
This is the code, with some MsgBox for my test:
Imports System.IO 'System library to import so StreamReader could be use
Public Class test
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
OpcDaCom1.BeginRead("M20943_A1_Scaled_Value", 1)
Label1.Text = Now
End Sub
Private Sub OpcDaCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles OpcDaCom1.DataReceived
If e.ErrorId <> 0 Then ' no good data received.
MsgBox(e.ErrorId)
Exit Sub
End If
MsgBox(e.Values(0))
ProgressBarEx1.Value = CInt(e.Values(0))
End Sub
Private Sub test_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Now for some reason the BeginRead command is giving me the error “Parameter count mismatch.†Then if I change the # of elements of the BeginRead to 2 the error goes away but the DataReceived event never gets trigger, I also try with a OpcDaCom1.read but it also is giving me error.
Once again thank you guys
-
What is the timer interval set for?
Can you try to do the reading with a button instead?
Have you tried similar setup with MatrikonOPC simulator (read its Bucket Brigade.Real4 tag maybe)?
-
Time interval is one second.
Try the pb with same result.
-
Try it like this just for test:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Label1.Text = OpcDaCom1.BeginRead("M20943_A1_Scaled_Value", 1)(0)
End Sub
-
Because a picture worth a thousand words.
-
Try changing it to Read instead.
-
It appears that the DataReceived event of the OPC driver doesn't function properly.
-
I changed to read, the only way to avoid errors was to declare the "a" as a string array, the return was a single element a(0) with nothing inside. (Label is located below the Button1, scaled was 5.62).
-
What errors did you get before you declared "a"?
-
Value of type '1=dimensional array of String' cannot be converted to 'string'.
-
So what exactly is M20943_A1_Scaled_Value? Is it an array?
From picture in other topic a value similar to this seems to show as Single float value.
-
Victor,
A line of code like this would produce that same error:
Label1.Text = OpcDaCom1.Read("M20943_A1_Scaled_Value", 1)
A line of code like this wouldn't:
Label1.Text = OpcDaCom1.Read("M20943_A1_Scaled_Value", 1)(0)
-
Godra,
Spend the last two and a half day working with Archie in the modbus, finally it appears that now my problems are centered in the communication adapter I was using, I ordered the one that he is using hoping that everything will be ok when I get it.
Now going back to this thread, your last suggestion of using "Label1.Text = OpcDaCom1.Read("M20943_A1_Scaled_Value", 1)(0)" did not produced any error, but also returned an empty string. tonight I will try using a subscription to see if I get any result.
Regards
Victor.