Debug startup of PLC

Hey there,

i got two questions which i need help for:

  1. I can’t find a way to debug the startup of my PLC. Is there any?

  2. Also we have a bug that the PLC isn’t available over it network ports but it seems to run. The help mentions from AR V4.33 there is no way to debug over serial and only over TCP/IP . How can we debug this behaviour?

Thx for your help.
Best Ben

Welcome !

What PLC and which Automation Studio Version are you using ?

1.) if you mean how to work with debugger breakpoints:
you can use a workaround by copying the initialization code (_INIT) to the _CYCLIC and use an additional boolean flag, e.g.

PROGRAM _INIT
   startup := TRUE;
END_PROGRAM


PROGRAM _CYCLIC
   IF startup THEN
      startup := FALSE;
      // initialization code
   ELSE
      RETURN;
   END_IF

   // cyclic code

END_PROGRAM

2.) not a simple answer possible. Here what to check: Online connection

1 Like

Depends on what you mean by “the startup of the PLC”.
If you mean the _INIT phase of tasks, there is a solution for that: implement an endless loop that will only be left if a PV is set, transfer the task and restart the PLC. After the restart, start the debugger and use breakpoints after the loop. Break the endless loop by setting the variable and you will be able to debug through the _INIT part.

void _INIT ProgramInit(void)
{
	while (start)
	{		int temp = 1;  	}
	//stuff to debug
}
2 Likes

Thx you, Thomas.
This is exactly what i was looking for!

Thank you.

I’m using a X20CP1685 and AS4.12.

  1. This should work.

  2. I’ll look into it.

if you are up to date with AS and AR and use Tcp/Ip, then the way described by Thomas is better.

1 Like