Red Lion G310 Change IP at Runtime

OkiePC

Lifetime Supporting Member
Join Date
Mar 2005
Location
ENE of Nowhere Oklahoma
Posts
11,794
I am working on an application in which it would be beneficial to be able to change the IP address of the HMI at runtime. This will allow me to use a single file for all 14 machines as we upgrade them.

I found an old thread with an example of using DevCtrl to change a device IP address and this feature works fine. I have not been able to make it work with the G310 ethernet port, however.

Has anyone done that and can you give me some advice?

Thanks.
Paul
 
This is possible but a little bit tricky because after changing the HMI IP address you have to restart it.

How do you plan to select the IP address for a given HMI at boot-up and then have it stick (ie. not ask to choose it again when it reboots?)

I did this once with two IP subnets so my field tech could use it in two places for checkout in a system without a permanent display. On bootup, he chose the system and it compared the selected IP with the installed IP and if it was the same it just ran normally, otherwise it saved the new IP (waited a few seconds - REQUIRED) and then rebooted.
 
I have a screen with a button for each possible installation. I intend to attach complex code to each button. This screen will be triggered on power up if the machine name has not yet been chosen. Once chosen, the user can access that screen by touching the machine name which appears on all pages (and then security will be checked before the page is accessed).

I have not had success yet. The HMI retains the IP address as set on the communications page after a power cycle. I have tried waiting up to several minutes both before and after setting the IP address.

I am not sure if this is done with DevCtrl, or if I have made a mistake in one of its parameters or syntax.
 
I have a screen with a button for each possible installation. I intend to attach complex code to each button. This screen will be triggered on power up if the machine name has not yet been chosen. Once chosen, the user can access that screen by touching the machine name which appears on all pages (and then security will be checked before the page is accessed).

I have not had success yet. The HMI retains the IP address as set on the communications page after a power cycle. I have tried waiting up to several minutes both before and after setting the IP address.

I am not sure if this is done with DevCtrl, or if I have made a mistake in one of its parameters or syntax.

There are probably other ways to do this, but here is what I did (and I know it could be simplified a little)
I created logic to provide the operator with feedback as to what was happening but I left it our to simplify this post.

1. Create Internal Retentive Tags for IP Address (called G310_IP_ADDRESS), Mask, and Gateway (my mask and gateway could change). These are integer tags. Place these tags in the Network Settings Boxes.
2. Create sets of string tags with called IP_ADDR1, IP_ADDR2, etc. (and for the masks and gateways too). In them, put the values (like "192.168.1.100") in quotes.
3. Create a tag G310_IP ( source is GetNetIP(1) ).
4. Create an integer tag called MachineName and give it Multitext with the machine names configured for the integer values to represent which machine is selected.
If it is machine 1 it will contain 1 and the multitext will say "Machine 1256", if machine 2 it will contain 2 and the multitext will say "Machine 1958" , etc.
5. Behind the button you use to set the IP use logic like this (the only thing that will change is the MachineName and the suffix for G310_IPx):

MachineName := 1;
if (G310_IP == G310_IP1) {
GotoPage(OVERVIEW);
}
else {
IP_Change_Logic();
}


5. The following is IP_CHANGE_Logic()
switch (MachineName){
case 1:
if (G310_IP != G310_IP1) {
G310_IP_ADDRESS := TextToAddr(G310_IP1);
G310_MASK := TextToAddr(G310_MASK1);
G310_GATEWAY := TextToAddr(G310_GATEWAY1);
CommitAndReset();
}
break;
case 2:
if (G310_IP != G310_IP2) {
G310_IP_ADDRESS := TextToAddr(G310_IP2);
G310_MASK := TextToAddr(G310_MASK2);
G310_GATEWAY := TextToAddr(G310_GATEWAY2);
CommitAndReset();
}
break;

default:
break;
}

6. Here is the Startup Program, too...

MachineName := 1;
if (G310_IP_ADDRESS == 0) {
G310_IP_ADDRESS := TextToAddr(G310_IP1);
G310_MASK := TextToAddr(G310_MASK1);
G310_GATEWAY := TextToAddr(G310_GATEWAY1);
CommitAndReset();
}

int Start = GetNow() + 8;

while(GetNow() < Start) Sleep(1000);
if (G315_IP_ADDRESS == TextToAddr(G315_IP1)) {
DevCtrl(MACHINE,1,MACHINE1_IP);
}
else {
DevCtrl(MACHINE,1,MACHINE2_IP);
}

The startup program should be where you set your DevCtrl IP address. You need the delay after starting before running this logic. My logic only had two locations, but you can use switch logic based on the MachineName rather than the If, then, else logic.

I know this may be confusing, but after you have played with it, let me know if you have any questions. (Not responsible for typos)
 
Thanks, JHarbin.

I believe I see what I was doing wrong. I used string tags (which worked in the DevCtrl statement for changing a device IP, but can't be used on the comms settings page).

Also, I didn't know about the CommitAndReset() instruction. That is much better than having to power cycle the HMI.

I will let you know how it works out.

Paul

EDIT: Worked like a charm. In summary, I simply use a retentive integer tag for the IP address on the communications settings tab, assign the IP address to said tag using the TextToAddr instruction in my button command script, and the CommitAndReset() command to make it happen.

Thanks.
 
Last edited:
Thanks, JHarbin.

I believe I see what I was doing wrong. I used string tags (which worked in the DevCtrl statement for changing a device IP, but can't be used on the comms settings page).

Also, I didn't know about the CommitAndReset() instruction. That is much better than having to power cycle the HMI.

I will let you know how it works out.

Paul


Again, if you set the DevCtrl in a startup program, you need to wait for it to complete bootup before making the change. That is a gotcha if you don't know about it.

Jim
 
Yes, thanks, Jim.

I am not going to use the DevCtrl now. I was going to keep the SLCs connected to the plant LAN via Digi One IAP modules, but that would require me to add a cheap switch to each installation and use the DevCtrl instruction to assign the G3 to the correct ethernet address of the Digi. Sitting up here in the office, that method was great for allowing me to test all the screens and buttons and animations.

Now, I have opted to eliminate the Digi modules, connect the G3 to the SLC serially, and have the G3 do the simple data collection (by sending data to tags in a Logix PAC on our LAN).

So, with your help, I can have one application for all 14 machines and don't need the DevCtrl instruction since I am not changing the device settings, only the target tags for the data collection and the IP address of the G3.

Paul
 
Last edited:

Similar Topics

Hello, We are currently running a bunch of g310's connected to their SLC5 PLCs through ethernet. I've attempted to upgrade the program from 2.0...
Replies
1
Views
1,122
Is it possible to print a file from a Red Lion G310 HMI to a networked printer over ethernet?
Replies
1
Views
1,284
Hi. We are currently experiencing slow loading or response time on our Red Lion G310, at about 5-10 seconds delay once we press a button or even...
Replies
0
Views
1,622
This is my first time using these two, and I have picked it up fairly well. I don't have much programming experience(very, very little), but I...
Replies
5
Views
1,633
I currently have RS Logix set up with a ladder logic program, when I force inputs from RS Logix I can get it to update the Red Lion G310 HMI...
Replies
5
Views
2,061
Back
Top Bottom