Author Topic: PLC Dynamic IP Address  (Read 13332 times)

Lorne Van Dusen

  • Jr. Member
  • Posts: 93
  • I'm a old guy
    • View Profile
PLC Dynamic IP Address
« on: January 05, 2017, 12:43:14 PM »
I am wondering if there is any way that the PLC can shown what Dynamic IP address it is given say from a router.
The PLC IP address was set as 0.0.0.0 in order to allow for a dynamic address.
So when you do a GET_IPAddr 100 of course you will see 0 0 0 0 9080

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:PLC Dynamic IP Address
« Reply #1 on: January 05, 2017, 10:05:30 PM »
You just need to allow some time for the DHCP to work and then run the PRINT #4 "<IP>"  command and use the INPUT$(4) to obtain the dynamic IP address assigned by the DHCP server.

One simple example is during initialization to wait for the IP address for up to 10 seconds:

FOR P = 1 to 10
  PRINT #4 "<IP>"   ' Get IP address of this FServer as a string
  B$ = INPUT$(4)
  IF LEN(B$) <> 0 AND STRCMP(B$,"0.0.0.0") <> 0
   EXIT
  ENDIF
  DELAY 1000
NEXT


A$ = "IP=" + B$ + "       "

SETLCD 1,1, A$
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Lorne Van Dusen

  • Jr. Member
  • Posts: 93
  • I'm a old guy
    • View Profile
Re:PLC Dynamic IP Address
« Reply #2 on: January 12, 2017, 10:58:28 AM »
Thanks a lot
I just found this reply today I guess I forgot to check off to notify me.
I tried your example and it works perfectly.
What I needed this for is that I intend on providing our customers with physical disabilities a web app for their phone or tablet.
So to make life simple for our dealers I needed a simple way for them to find the assigned IP address which I now will show on one of the screens in the FP4020MR text display.
 :D