Author Topic: Variable for PLC IPAddress  (Read 2785 times)

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Variable for PLC IPAddress
« on: July 27, 2020, 10:59:07 AM »
I have clients that want to be able to change the PLC's IP Address and i was wondering if it were possible to write the ip to a string variable and have the COM object use that instead of manually entering it int he designer.  Any thoughts about a dynamic IP address? Maybe some routine that executes on startup?
Still just trying to figure out this thing called Life.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Variable for PLC IPAddress
« Reply #1 on: July 27, 2020, 11:30:40 AM »
I make use of the INI Files.

I will have a file named CLX.ini with these contents:

[EthernetIPforCLXCom1]
IPAddress=10.65.80.34
ProcessorSlot=0

I then set my driver properties:

INIFileName = CLX.ini
INIFileSection = EthernetIPforCLXCom1


The CLX.ini file is in the root of the AdvancedHMI project and the property Copy To Output Directory is set to Copy To Newer.

This method allows manual editing of the INI file without re-compiling the solution.

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Variable for PLC IPAddress
« Reply #2 on: July 27, 2020, 11:52:53 AM »
You know... i never have made use of those INI files.... seems like a no brainier!
Thanks Archie.  That'll do perfectly.
Still just trying to figure out this thing called Life.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Variable for PLC IPAddress
« Reply #3 on: July 27, 2020, 05:11:11 PM »
I like the comment added feature:

Code: [Select]
; PLC driver: [Section], Keyname, NO SPACEs
;
[PLC]
IPAddress=10.10.10.14
ProcessorSlot=0
PollRateOverride=0
;
[PLC_Slow]
IPAddress=10.10.10.14
ProcessorSlot=0
PollRateOverride=250

;file parsing
; Dim parser As New AdvancedHMIDrivers.IniParser(".\INI_TXT\Settings.ini")
;       Dim myInt As Integer = CInt(parser.GetSetting("Section", "Keyname"))
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

qsiguy

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Variable for PLC IPAddress
« Reply #4 on: February 16, 2023, 05:37:41 PM »
I am attempting to replicate this setup because it is exactly the solution I was searching for. I created an .ini file called CLX.ini, added "INIFileName=CLX.ini" and "INIFileSection = ModbusTCPCom1" to the ModbusTCPCom1 driver. I manually put the file in the root directory in the designer. I publish it and I just get an error "INI File - Unable to locate CLX.ini".  I then tried putting the CLX.ini file in the various folders of the published application and I get the same error.

Any pointers what I may be doing wrong?

Thanks,
Shane

I make use of the INI Files.

I will have a file named CLX.ini with these contents:

[EthernetIPforCLXCom1]
IPAddress=10.65.80.34
ProcessorSlot=0

I then set my driver properties:

INIFileName = CLX.ini
INIFileSection = EthernetIPforCLXCom1


The CLX.ini file is in the root of the AdvancedHMI project and the property Copy To Output Directory is set to Copy To Newer.

This method allows manual editing of the INI file without re-compiling the solution.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Variable for PLC IPAddress
« Reply #5 on: February 16, 2023, 05:50:00 PM »
I am attempting to replicate this setup because it is exactly the solution I was searching for. I created an .ini file called CLX.ini, added "INIFileName=CLX.ini" and "INIFileSection = ModbusTCPCom1" to the ModbusTCPCom1 driver. I manually put the file in the root directory in the designer. I publish it and I just get an error "INI File - Unable to locate CLX.ini".  I then tried putting the CLX.ini file in the various folders of the published application and I get the same error.

Any pointers what I may be doing wrong?

Thanks,
Shane
My first suggestion is to not use Publish if you are using the Visual Studio Publish tool.

https://www.advancedhmi.com/forum/index.php?topic=14.msg37#msg37

qsiguy

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Variable for PLC IPAddress
« Reply #6 on: February 16, 2023, 06:39:30 PM »
My first suggestion is to not use Publish if you are using the Visual Studio Publish tool.

https://www.advancedhmi.com/forum/index.php?topic=14.msg37#msg37

Even before publishing I was seeing that error when I Start the app to test so the publishing wasn't the cause, I made a mistake in the setup.

I believe I have achieved my goal another way. By using a TextBox to enter the IP address as a string and in the MainForm code I made the Modbus IP address = the textbox string. It now uses the IP I enter into the textbox in the runtime screen for the IP.

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Me.ModbusTCPCom1.IPAddress = TextBox1.Text
    End Sub

Is there another way to publish an app for use by clients or my technicians that doesn't require them to have the full development software?  Making a purpose built small app the service tech or client can't modify without his managers permission is one of the most attractive features of AdvancedHMI for my use case.
« Last Edit: February 16, 2023, 08:28:01 PM by qsiguy »

qsiguy

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Variable for PLC IPAddress
« Reply #7 on: March 03, 2023, 12:04:59 PM »
My TextBox IP edit method works but I've ran into an anomaly. On some PCs if the IP isn't pointing to the Modbus device upon startup the display locks up and it won't let me edit the textbox to change it.  I can't click on anything and have to force close it.  On another laptop, it doesn't lock up when I start it with the wrong IP and it lets me edit it and recover the Modbus connection.

Any ideas why it would do this only on some PC's and how I can "Keep it alive" in the event of an incorrect IP?  Perhaps create an object on the display that points to the local machine so it will always be able to see it?  If this sounds logical, how would I do that?

Thanks for any assistance.  Had my eye on AdvancedHMI for a few years, just now finally dove in and started experimenting and so far it is pretty awesome!

Thanks,
Shane