Author Topic: Changing EthernetIPforCLXCom1 IP Address at Runtime  (Read 1272 times)

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Changing EthernetIPforCLXCom1 IP Address at Runtime
« on: April 07, 2020, 02:22:39 PM »
I have two identical automated machining cells. I want to make changes to the PLC and HMI as easy as possible with the hopes that I will only have to maintain one program for both the HMI and PLC. I have a 17" AHMI touchscreen PC running V3.99x with a CompactLogix L32ER PLC.

I have a number of forms all using the same EthernetIPforCLXCom1 driver for communications to/from the PLC. Currently, I'm using a function to return the PC IP address which is then copied to GlobalVariable.IPAddress and used to determine what IP address I should use for the PLC. In all form load events, I have the following code:

 If GlobalVariable.IPAddress = "192.168.8.32" Then
            EthernetIPforCLXCom1.CloseConnection()
            EthernetIPforCLXCom1.IPAddress = "192.168.8.31"
        ElseIf GlobalVariable.IPAddress = "192.168.8.52" Then
            EthernetIPforCLXCom1.CloseConnection()
            EthernetIPforCLXCom1.IPAddress = "192.168.8.51"
        Else
            EthernetIPforCLXCom1.CloseConnection()
            EthernetIPforCLXCom1.IPAddress = "0.0.0.0"
        End If

The only one that gives me trouble is my "MAIN" form. I'm using the MainMenuDriven FormChangeControls and the "Main" form is set to "OpenOnStartup". If I set "OpenOnStartup" to False for the "Main" form, then when I click the button to open the form the comms are set correctly and everything works normally from there. I'd really prefer to have a startup form open which made me wonder if there is another way to do what I'm trying to do.

Basically, I don't want to change the IP addresses on every form for Cell2 every time I make a change to the HMI program. I read something about an INI file, but I'm not familiar with it at all.

Any ideas or other information needed?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #1 on: April 07, 2020, 02:52:50 PM »
My preferred method is to use the INI files for setting the IP address.

https://www.advancedhmi.com/forum/index.php?topic=2665.msg16043#msg16043

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #2 on: April 07, 2020, 02:55:38 PM »
I got in the habit of not using MainForm for anything but a splash screen with a START FormChangeButton and logo's that goes to the home operating screen. The logo's are mine, AHMI & the customers.

That way it doesn't need any driver on it, and I make it the only form that is Sizeable that it can close the application. From the home operating screen I put an EXIT FormChangeButton that goes to MainForm and can then close.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #3 on: April 07, 2020, 08:16:09 PM »
I agree with Archie suggestion to use INI file.
I'd make a Welcome form, on this Welcome form, put your logo, AAHMI logo, customer logo and
add a regular button 'Continue'
Double click the 'Continue'  button  and enter some code:

Code: [Select]
MainForm.Show()
Me.Close()                   

Then,  in Project property, change Startup Form to 'Welcome'
and
Shutdown Mode to 'When last form closes'

Now back to Mainform is where you do your work and driver.
« Last Edit: April 07, 2020, 09:04:09 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #4 on: April 08, 2020, 09:05:29 AM »
My preferred method is to use the INI files for setting the IP address.

https://www.advancedhmi.com/forum/index.php?topic=2665.msg16043#msg16043

I assume this has to be done for every form in the project and then only the IP address in the INI has to be changed? Also the IP address cannot be blank as described in the post above so I'm going to enter 0.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #5 on: April 08, 2020, 09:35:38 AM »
My preferred method is to use the INI files for setting the IP address.

https://www.advancedhmi.com/forum/index.php?topic=2665.msg16043#msg16043

I assume this has to be done for every form in the project and then only the IP address in the INI has to be changed? Also the IP address cannot be blank as described in the post above so I'm going to enter 0.
Yes, you do have to set every driver instance to point to the INI file. When I build applications, I set the properties for the INI file settings on the first form then copy and paste the driver to other forms.

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Changing EthernetIPforCLXCom1 IP Address at Runtime
« Reply #6 on: April 08, 2020, 12:08:13 PM »
My preferred method is to use the INI files for setting the IP address.

https://www.advancedhmi.com/forum/index.php?topic=2665.msg16043#msg16043

I assume this has to be done for every form in the project and then only the IP address in the INI has to be changed? Also the IP address cannot be blank as described in the post above so I'm going to enter 0.
Yes, you do have to set every driver instance to point to the INI file. When I build applications, I set the properties for the INI file settings on the first form then copy and paste the driver to other forms.

Thanks Archie. That's much more manageable.