Author Topic: Tag Database  (Read 11879 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Tag Database
« on: September 10, 2015, 08:07:05 PM »
Many of the HMI software packages use a tag database to reference PLC addresses by a tag name/alias. This allows you to use an address in multiple places throughout the HMI, but change the actual PLC address in one location.

AdvancedHMI has both the capability of using a direct PLC address in properties such as PLCAddressValue or creating a Tag Name database. The tag name database for AdvancedHMI is referred to as Application Settings. The data is stored in an XML file which allows you to edit the XML file and change addresses without the need of editing in Visual Studio and recompiling.

Here's how you go about using these Application Settings to do the equivalent of a Tag Database:

- Add a driver to the form
- Add a BasicLabel to the form
- In the Properties Window for the BasicLabel, scroll all the way to the top
- You will see Application Settings with a "+" sign next to it. Click the "+" sign
- Click in the (Property Binding) and you will get a button with 3 dots (ellipsis)
- Click on the ellipsis to open a new window of Application Settings for BasicLabel1
- In that Window look for PLCAddressValue, click in the area to get a drop down arrow
- Click (New...)
- Another window will open of New Application Setting
- For Defaultvalue enter your PLC Address (e.g. N7:0, 40001, MyTag, etc)
- For Name enter the Tag Name/Alias you would like to refer to this address as
- Click OK to close the 2 windows

You can now run your application that fetches its PLC address from an equivalent of a Tag Database.


These Application Settings are not limited PLC addresses. For example, let's say you have many forms each with a driver instance and you want them to all have the same IPAddress. Using the same procedure you can create an Application Setting for IPAddress and use that application setting for every driver instance.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Editing Your Application Settings (Tag Database)
« Reply #1 on: September 10, 2015, 08:13:26 PM »
In Visual Studio
- Right Click the AdvancedHMI project in Solution Explorer and select Properties
- Select the Settings tab
- You can now see all of your tags and edit the values


After Compiling
After you compile or run your application that uses Application Settings, you can use an editor such as XML Notepad to edit the data. This is done by browsing to where your executable resides (normally \AdvancedHMI\bin\Debug) and opening the file AdvancedHMI.exe.config

After editing and saving the file, the next time you run your application it will use the edited values.

A word of caution: recompiling your application will revert the AdvancedHMI.exe.config back to the values defined in Visual Studio

psullivan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Tag Database
« Reply #2 on: September 17, 2015, 12:05:54 PM »
I am taking a crack at this method for syncing an IP address for multiple driver instances on multiple forms as you suggested. The only problem I am having is if a change the IP at runtime I need to close and reopen the form for the change to take effect. Do I just need to disable or reenable subscriptions on the driver or something?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Tag Database
« Reply #3 on: September 17, 2015, 01:47:34 PM »
How are you changing the IP at run time?

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Tag Database
« Reply #4 on: September 17, 2015, 09:21:22 PM »
Just throwing this out there
I was on a job a few  years ago , where I saw a HMI screen that someone had programmed and all the tags where read from a simple excel spreadsheet , could this be done with ADV HMI , from what I remember it looked very easy to change addresses etc.

Darrell

psullivan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Tag Database
« Reply #5 on: September 17, 2015, 09:59:22 PM »
I am writing to the application property that I have the IP address fields bound to, and then calling the my.settings.save() method. Before I tried using data binding I was just writing to the "IPaddress" property of the driver Instance, and that seemed to work just fine.
« Last Edit: September 17, 2015, 10:02:04 PM by psullivan »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Tag Database
« Reply #6 on: September 17, 2015, 10:26:20 PM »
I was on a job a few  years ago , where I saw a HMI screen that someone had programmed and all the tags where read from a simple excel spreadsheet , could this be done with ADV HMI , from what I remember it looked very easy to change addresses etc.
This is every bit possible, but would take a fair amount of code writing. I saw an application from one of the users in which they put all of their addresses in a text file and on startup read the file and put the values in all of the properties. It was a fair amount of code to do it.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Tag Database
« Reply #7 on: September 17, 2015, 10:27:46 PM »
I am writing to the application property that I have the IP address fields bound to, and then calling the my.settings.save() method. Before I tried using data binding I was just writing to the "IPaddress" property of the driver Instance, and that seemed to work just fine.
Are you doing something like My.Settings.name="192.168.0.1"

psullivan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Tag Database
« Reply #8 on: September 18, 2015, 08:01:09 AM »
Yes. That is exactly what I am doing.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Tag Database
« Reply #9 on: September 18, 2015, 08:20:17 AM »
I have to look a bit further into this. When changing the setting value it does not push it to the property of the driver. I did a quick test with a Label and a setting for the Text property, then changed the setting value at run time. It pushed the new value to the property. For some reason the same doesn't work with the drivers.

psullivan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Tag Database
« Reply #10 on: September 18, 2015, 08:57:25 AM »
Okay. Thanks for your help!

RyanLeo

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Tag Database
« Reply #11 on: May 02, 2016, 06:12:22 AM »
  '
I have worked out that if needed I can write the IP address at runtime with My.Settings.name as suggested above by commenting out the IP address in the MainForm.Designer.vb file as per the example below.

'ModbusTCPCom1
        '
        Me.ModbusTCPCom1.DisableSubscriptions = False
       ' Me.ModbusTCPCom1.IPAddress = "10.0.0.55"
        Me.ModbusTCPCom1.MaxReadGroupSize = 20
        Me.ModbusTCPCom1.SwapBytes = True
        Me.ModbusTCPCom1.SwapWords = False
        Me.ModbusTCPCom1.SynchronizingObject = Me
        Me.ModbusTCPCom1.TcpipPort = CType(20108US, UShort)
        Me.ModbusTCPCom1.TimeOut = 3000
        Me.ModbusTCPCom1.UnitId = CType(10, Byte)




I then add the following to the form loadevent   

Me.ModbusTCPCom1.IPAddress = My.Settings.Name    (with error checking)

 Please be aware the designer.vb file is auto generated so it is required to comment this piece of code out each time the project is rebuilt. It worked for me so I hope it may help others
« Last Edit: May 02, 2016, 06:16:13 AM by RyanLeo »

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Tag Database
« Reply #12 on: May 02, 2016, 11:03:44 AM »
I'm doing this by using the DisableSubscriptions property.  My driver has the DisableSubscriptions=true in design view.

In my form_Load I set the IP to what I want and then set DisableSubscriptions = false

I haven't tried it on the fly, but if you were to set DisableSubscriptions=true, change the IP and then set DisableSubscriptions = false I would think it'll work.

And my trial is on a ModbuTCP driver.

        Me.ModbusTCPCom1.IPAddress = "10.10.10.120" 'or My.Settings.Name
        Me.ModbusTCPCom1.DisableSubscriptions = False