I'm struggling with the RESTART statement. I'm attempting to have the PLC set/change it's own IP address. The documentation states:
"To perform a cold reboot of the PLC from within a CusFn. The effect is identical to a power-on-reset except that you execute this command without turning OFF power to the PLC.
RESTART may be necessary for some changes to take effect, such as for the PLC to assume new IP address after executing the SET_IP command."
My observations are that The RESTART statement does not do the job. I find that I still must power off the PLC to get the IP to change.
I am using 2 custom functions for my debug code, "Init" once at 1st.Scan and displays the current IP address using the new Get_IPAddr. The second custom function is "ToggleIP" it runs only in response to an INPUT and attempts to change the IP address back and forth between "192.168.1.16:9080" and "192.168.1.17:9080".
Init looks like this:
' Init
'
Get_IPAddr 1 ' Get PLC IP addres in DM[1..5]
A$ = str$(DM[1])+"."+str$(DM[2])+"."+str$(DM[3])+"."+str$(DM[4])+":"+str$(DM[5])
SetLCD 0,1,"\01" ' Clear LCD display
SetLCD 0,1,Chr$(12) ' No cursor
SetLCD 1,1, "PLC IP Address:"
SetLCD 2,1, A$
[/color]
ToggleIP looks like this:
' ToggleIP
'
Get_IPAddr 1 ' Get PLC IP addres in DM[1..5]
A$ = str$(DM[1])+"."+str$(DM[2])+"."+str$(DM[3])+"."+str$(DM[4])+":"+str$(DM[5])
SetLCD 0,1,"\01" ' Clear LCD display
SetLCD 0,1,Chr$(12) ' No cursor
SetLCD 1,1, "Current IP"
SetLCD 2,1, A$
Delay 4000 ' kill some time so the LCD can be read
' Toggle IP address between 192.168.1.16:9080 and 192.168.1.17:9080
'
if DM[4] = 16
DM[4] = 17
else
DM[4] = 16
endif
A$ = str$(DM[1])+"."+str$(DM[2])+"."+str$(DM[3])+"."+str$(DM[4])+":"+str$(DM[5])
SetLCD 3,1, "Next IP"
SetLCD 4,1, A$
Delay 4000 ' kill some time so the LCD can be read
Set_IPAddr 1 ' Set new IP address
RESET ' Update flash memory that holds the IP variables
RESTART ' Force a cold reboot to restart the PLC and actually configure the
' PLC to the changed IP address.
[/color]
If I toggle the INPUT, I can see on the LCD, that the ToggleIP custom function runs. I am convinced that the RESTART statement does restart the ladder logic scanning mechanism. However, the IP address shown on the LCD after the RESTAT, is not the actual IP address of the PLC. The actual IP address is unchanged!
If I power down the PLC, then the PLC's IP does change to match the value on the LCD.
This is my evidence that RESTART is not the same the ultimate reset caused by killing power to the PLC.
Hardware info: FMD1616 r82A
What am I missing?
Gary D