Author Topic: DataSubscriber2 Walk Through  (Read 7023 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
DataSubscriber2 Walk Through
« on: January 06, 2016, 09:16:30 PM »
This guide will step you through using multiple addresses with a single DataSubscriber2. This example uses the ModbusTCP driver, but it can be substituted for any driver.

- Add a ModbusTCPCom driver from the ToolBox to the form
- Set the IP address to that of your PLC
- Set PollRateOverride to 2000 (2 seconds0
- Add a DataSubscriber2 from the ToolBox to the form
- In the Properties window next to the PLCAddressValueItems property click the ellipsis (3 dots)
- A collection editor window will open up
- Click the Add button
- In PLCAddress enter 40001
- Click the Add button again
- In PLCAddress enter 4002
- Click OK
- Double click the DataSubscriber in the tray below the form. This will take you to the DataChanged event handler
- Enter this code:
Code: [Select]
        If e.PlcAddress = "40001" Then
            MsgBox("Address 40001 value=" & e.Values(0))
        End If

        If e.PlcAddress = "40002" Then
            MsgBox("Address 40002 value=" & e.Values(0))
        End If

Now run the application and every 2 seconds you should get a pop up with the values.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #1 on: January 31, 2016, 09:23:20 PM »
Hi Archie.  I'm trying to use the Scale factor in the DataSub2 control but it doesn't seem to do anything.  Also is it possible to add a numeric format property to this control?  Thanks. 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: DataSubscriber2 Walk Through
« Reply #2 on: February 01, 2016, 12:11:13 AM »
The ScaleFactor has not been implemented on the DataSubscriber2. That component actually wasn't meant to be released until version 4, so it has Properties that do not do anything in version 3.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #3 on: February 01, 2016, 07:25:40 AM »
 I will look forward to it. Thanks.

maxketcham

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #4 on: February 01, 2016, 12:00:06 PM »
When I try to use the DataSubscriber2 It will not allow me to add anything to the PLCAddress, see attached image. Am I doing something wrong or do I need to do something to the control to make it work? VB2013 VS2013 Pro.

maxketcham

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #5 on: February 01, 2016, 12:02:24 PM »
Forgot to mention I'm using the OPC driver and the error is object does not match target type.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: DataSubscriber2 Walk Through
« Reply #6 on: February 01, 2016, 12:23:00 PM »
When I try to use the DataSubscriber2 It will not allow me to add anything to the PLCAddress, see attached image. Am I doing something wrong or do I need to do something to the control to make it work? VB2013 VS2013 Pro.
This is a quirk of VS and open source. Usually just closing all of your open forms and exiting VS will resolve this. If not try this:

http://advancedhmi.com/forum/index.php?topic=1062.0

maxketcham

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #7 on: February 01, 2016, 01:34:20 PM »
Unfortunately I lost my whole project, won't do that again. not the first time, for some reason if there is an error in the program and you clean the solution, it erases every control on the form. not sure why but it's not the first time this has happened to me. once they are gone, that's it gotta start over. to make it worse it erase every damned handles clause associated with the controls that are now gone so just putting everything back isn't a solution. have to rewrite all code to. I know it's not your code, it is something wrong in Visual studio had it happen before with other programs using custom controls. Almost makes it not worth using them.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: DataSubscriber2 Walk Through
« Reply #8 on: February 01, 2016, 02:31:32 PM »
The key to cleaning the solution is to close every form open in design view before exiting VS. After the clean, do not open any forms until the rebuild is complete.

Since the AdvancexHMI controls are in source code, a clean will eliminate their existence until a rebuild. If a form is open or tried to be opened before the source controls are compiled, the. VS reports them as non-exist any and fails to open the form in design view.

Homie

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: DataSubscriber2 Walk Through
« Reply #9 on: March 18, 2016, 05:55:03 AM »
Guten Morgen and Hello
I just started testing AdvancedHMI and have a question to the Datasubscriber2 setup.
Reading some other Threads about it made me even more curious.

I want to read an array of data from a CLX, and I am not sure about the adressing.
Do I have to add the startpoint in the array to the tagname or not?

Example: I want to read 15 elements from the DINT array Stoplist.
Do I have to set PLCAdress to: Stoplist[0] or is it only Stoplist?
Number of elements will be 15.

Edit: Could test it.  Stoplist[0] is working.

I have access to a PLC only from time to time, but I can send my file to a friend to test it.
He has even less clue from VB than I have. So I want to verrify as much as possible upfront.

Thanks in advance
Thomas
« Last Edit: March 19, 2016, 06:29:51 AM by Homie »