AdvancedHMI Software
General Category => Open Discussion => Topic started by: rbeavers on November 21, 2016, 10:15:47 AM
-
Hello,
I would like to read a PLC tag value or array directly into a VB variable or array. I would like this to happen in the background without having to display a control or controls...
Is it possible to read values from a PLC without having a control visible on the screen? Is there a specific tool for this?
Thanks,
-Rob
-
Which driver are you using?
All of the drivers allow you to directly read/write via code. There is also the option of using a DataSubscriber to get a continuous update PLC data that will be send to an event handler.
-
Hi Archie, I am using the EthernetIPforCLXCom v 3.99p driver. I'm particularly interested in the DataSubscriber to Event; but Discrete and Array work as well.
Can you post some VB.Net (2013) code examples for DataSubscriber and Discrete/Array? I may be using other drivers in the future, usually the AB line of PLC's.
Thanks,
-Rob
-
The Datasubscribers works well when you need a continuous update of data. You can think of the DataSubscriber as a BasicLabel without the visual component. This is how you would use it:
- Add a DataSubscriber to the form
- Set PLCAddressValue to a tag
- Double click the DataSubscriber to get back to the code
- Enter this code:
Msgbox (e.PLCAddress & "=" * e.Values(0))
If you want to read a one time value in code, then you would use it like this:
Dim MyValue as string
MyValue=EthernetIPforCLXCom1.Read("MyTag")
-
Thanks Archie.
How about addressing a single bit within an array?
-
How about addressing a single bit within an array?
As in a BOOL array or an array of DINT?
-
Example:
RobotComms[20] - 20 Word Array
Need to address:
RobotComms[3].7 - Word 3, Bit 7 Boolean
and/or
RobotComms[5] - Word 5 (SINT, DINT or Real)
-
Example:
RobotComms[20] - 20 Word Array
Need to address:
RobotComms[3].7 - Word 3, Bit 7 Boolean
and/or
RobotComms[5] - Word 5 (SINT, DINT or Real)
To read multiple array elements in code:
Dim values() as string
values=EthernetIPforCLXCom1.Read("RobotComms[0]",20)
The others are exactly as you have them. For example, add a BasicLabel to the form and put RobotComms[3].7 in the PLCAddressValue Property
-
Thanks Archie!
Superb support!!! :)