Advanced HMI and Dynamic DNS

cdogmillion

Member
Join Date
May 2016
Location
Darwin
Posts
6
Hi,

I'm working on a project to setup a Micrologix 1100 at a remote site and a PC running AdvancedHMI locally.
Does anyone have any experience setting up AdvancedHMI to resolve domain names into IP addresses? This is where I am stuck..

At the remote end the PLC is connected to a wireless router/3G modem with its own internet connection. The PLC has its own local fixed IP address. The router gets a dynamic IP address issued by the internet provider for use over the internet.
I then setup port forwarding in the router to forward communications coming from over the internet on port 44818 to the local ip address of the PLC.
At the remote end I then use whatismyip.com to get the current ip address of the internet connection, put this IP into my EthernetIPforSLCMicroCom1 driver and build the exe file and I can then connect to my PLC using AdvancedHMI from any internet connected computer.

Problem is the internet service at the remote site provides a dynamic ip which changes all the time, and when it changes advancedHMI no longer works. So I then setup a fre noip.com account to get a fixed domain name and also setup the Dynamic DNS function in the router at the remote site. So now I basically have a fixed domain name for my PLC instead of and IP address and the router updated the Domain name server with my ip address whenever it changes.

So does anyone no how to modify the code to get AdvancedHMI to resolve my domain name to an ip address?
 
Hands down - the best Dynamic DNS Service is "dyndns.org" their simple plan is $40.00 per year and allows 30 host.

You will want to set this up in the router, most router's today provide a provision that allow the use of DDNS. Study this is the router manual, I don't think you will have problems.

P.S. Only the router should be setup with DDNS Service.
 
So does anyone no how to modify the code to get AdvancedHMI to resolve my domain name to an ip address?
The AdvancedHMI Ethernet drivers should be able to resolve your name to an IPAddress. For the IPAddress property, instead of putting the IP address, put in the host name.

In order to verify your host name, open a command prompt and ping the host name and verify it is the same IP address you would put into AdvancedHMI. This is essentially what the driver will attempt to do.

I have done this with the TwinCAT drivers and know it works, but never tried it on the AB drivers.
 
Hi Archie,
The first thing I tried was inserting my host name "[email protected]" into the IPAddress field. When you try to start the form it just brings up an invalid operation exception.

When I ping the host name it gives me the correct IP address.
I had a go at putting my Host name into the Twincat drivers and it seemed to work fine..


Exception looks like this:
Well above my technical abilities..

System.InvalidOperationException was unhandled
HResult=-2146233079
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: An invalid IP address was specified.
Source=AdvancedHMI
StackTrace:
at MfgControl.AdvancedHMI.My.MyProject.MyForms.Create__Instance__[T](T Instance) in :line 190
at MfgControl.AdvancedHMI.My.MyProject.MyForms.get_MainForm()
at MfgControl.AdvancedHMI.My.MyApplication.OnCreateMainForm() in D:\PLC\AdvancedHMIBetaV399d\AdvancedHMI\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at MfgControl.AdvancedHMI.My.MyApplication.Main(String[] Args) in :line 81
InnerException:
HResult=-2146233033
Message=An invalid IP address was specified.
Source=System
StackTrace:
at System.Net.IPAddress.InternalParse(String ipString, Boolean tryParse)
at System.Net.IPAddress.Parse(String ipString)
at MfgControl.AdvancedHMI.Drivers.EIPTransport.set_IPAddress(String value)
at MfgControl.AdvancedHMI.Drivers.EIPEncapsulation.set_IPAddress(String value)
at AdvancedHMIDrivers.EthernetIPforSLCMicroCom.CreateDLLInstance() in D:\PLC\AdvancedHMIBetaV399d\AdvancedHMIDrivers\AllenBradley\EthernetIPforSLCMicroCom.vb:line 104
at AdvancedHMIDrivers.EthernetIPforSLCMicroCom.set_IPAddress(String value) in D:\PLC\AdvancedHMIBetaV399d\AdvancedHMIDrivers\AllenBradley\EthernetIPforSLCMicroCom.vb:line 199
at MfgControl.AdvancedHMI.MainForm.InitializeComponent() in D:\PLC\AdvancedHMIBetaV399d\AdvancedHMI\MainForm.Designer.vb:line 101
at MfgControl.AdvancedHMI.MainForm..ctor()
InnerException:
 
This is kind of a long work around, but I think it should work.

- In Solution Explorer, expand down the AdvancedHMIDrivers project
- Expand down the AllenBradley folder
- Right click EthernetIPforSLCMicroCom.vb and select View Code
- Go down to line 93, which will be the first line in the Properties Region
- Replace from that line all the way down to the first occurrence of End Property with this code:
Code:
    Private m_IPIniFile As String = ""
    Private m_HostName As String

    Public Overrides Property IPAddress As String
        Get
            If Not String.IsNullOrEmpty(m_IPIniFile) Then
                Return m_IPIniFile
            ElseIf Not String.IsNullOrEmpty(m_HostName) Then
                Return m_HostName
            Else
                Return MyBase.IPAddress
            End If
        End Get
        Set(value As String)
            If Not String.IsNullOrEmpty(value) Then
                If MyBase.IPAddress <> value Then
                    If value.IndexOf(".ini", 0, StringComparison.CurrentCultureIgnoreCase) > 0 Then
                        Try
                            If Not Me.DesignMode Then
                                Dim p As New IniParser(value)
                                MyBase.IPAddress = p.GetSetting("IPADDRESS")
                            End If
                            m_IPIniFile = value
                        Catch ex As Exception
                            System.Windows.Forms.MessageBox.Show(ex.Message)
                            Exit Property
                        End Try
                    Else
                        Dim address As New System.Net.IPAddress(0)
                        If System.Net.IPAddress.TryParse(value, address) Then
                            MyBase.IPAddress = value
                            m_IPIniFile = ""
                        Else
                            Dim IP As System.Net.IPHostEntry
                            Try
                                IP = System.Net.Dns.GetHostEntry(value)
                                For i = 0 To IP.AddressList.Length - 1
                                    If IP.AddressList(i).AddressFamily = Net.Sockets.AddressFamily.InterNetwork Then
                                        MyBase.IPAddress = IP.AddressList(i).ToString
                                    End If
                                Next
                            Catch ex As Exception
                            End Try
                            m_HostName = value
                        End If
                    End If
                Else
                    m_IPIniFile = ""
                End If
            End If
        End Set
    End Property

- Rebuild the Solution
- Exit Visual Studio and re-open
- You should now be able to put your Host Name in the IPAddress property
 
Correction to the code above:

Code:
    Private m_IPIniFile As String = ""
    Private m_HostName As String

    Public Overrides Property IPAddress As String
        Get
            If Not String.IsNullOrEmpty(m_IPIniFile) Then
                Return m_IPIniFile
            ElseIf Not String.IsNullOrEmpty(m_HostName) Then
                Return m_HostName
            Else
                Return MyBase.IPAddress
            End If
        End Get
        Set(value As String)
            If Not String.IsNullOrEmpty(value) Then
                If MyBase.IPAddress <> value Then
                    If value.IndexOf(".ini", 0, StringComparison.CurrentCultureIgnoreCase) > 0 Then
                        Try
                            If Not Me.DesignMode Then
                                Dim p As New IniParser(value)
                                MyBase.IPAddress = p.GetSetting("IPADDRESS")
                            End If
                            m_IPIniFile = value
                            m_HostName = ""
                        Catch ex As Exception
                            System.Windows.Forms.MessageBox.Show(ex.Message)
                            Exit Property
                        End Try
                    Else
                        Dim address As New System.Net.IPAddress(0)
                        If System.Net.IPAddress.TryParse(value, address) Then
                            MyBase.IPAddress = value
                            m_IPIniFile = ""
                            m_HostName = ""
                        Else
                            Dim IP As System.Net.IPHostEntry
                            Try
                                IP = System.Net.Dns.GetHostEntry(value)
                                For i = 0 To IP.AddressList.Length - 1
                                    If IP.AddressList(i).AddressFamily = Net.Sockets.AddressFamily.InterNetwork Then
                                        MyBase.IPAddress = IP.AddressList(i).ToString
                                    End If
                                Next
                            Catch ex As Exception
                            End Try
                            m_HostName = value
                            m_IPIniFile = ""
                        End If
                    End If
                End If
            End If
        End Set
    End Property
 
Exposing your PLC to the internet like this is bad practice. Consider setting up a VPN between both sites instead. That will not only improve security but also allow you to use a fixed IP address in AdvancedHMI instead of a domain name.
 
That did it! Very very much appreciated Archie, hope it wasn't too much trouble.

Point taken about the security issue, I will definitely look into setup up a VPN if we go ahead with the project. At the moment its more of a technology demonstration of a super low cost remote monitoring solution..
 
Most router's only take 4 lines of programming.

DDNS provider's address.
New hostname.
User Name
Password

And your done.
 
Most router's only take 4 lines of programming.
The code posted above was not a program for a router, but a communication driver modification that gives a 3rd option for specifying an IP address. With that above modification, you can now put in an IP Address, INI file name, or a host name in the IPAddress property of the driver.

The power to using a top level open source HMI software is the ability to add features without waiting months for the software company to release a new version. Not counting that it may also cost thousands to get the update.
 

Similar Topics

I’m new to plc programming and very new to HMIs. So this is what I have done so far: I bought a micrologix 1100, I used bootP to set the up...
Replies
17
Views
1,730
So I installed advanced hmi and grabbed an ethernet cable. I have the click C0-12DRE-1-D PLC. I installed the advanced hmi and added the...
Replies
13
Views
2,091
Do I use the ethernet port on the click plc to connect it to my computer. Will advancedhmi work properly? Am I able to start data logging into a...
Replies
1
Views
957
Having a hard time getting the data received when using BeginReadMultiple. Not the most familiar with the ClxDriver and EthernetIPforCLXCom()...
Replies
8
Views
2,353
I am in search of a non-PC based, non-SCADA based HMI and software that allows the ability to dynamically draw graphical objects on the screen to...
Replies
15
Views
5,086
Back
Top Bottom