System INPUT signal

I am using system input signal " startmain" to start the main program from PLC. When we start main from PLC would it erase all my variables to their default value or their values will be retained?

Dear Natalia

By my experience, “StartAtMain” would not erase/reset the variables as long as we don’t declare something which can reset them on the “main” procedure.
For example:

PROC main()
VAR num Stack:=0;

Stack:=0;

MoveL…

But be careful for using VAR type, because some variables can be erased to their default value after controller is shutdown.

BR

Hey, Thanks Dhyan. I am using it to start Home move from PLC, I will let you know how it works.

The part of my code is like this,
var num count =0; ! defined in user.sys

proc main()
LOOP:


myproc1;
Goto LOOP;
endproc

proc myproc1()
count=count+1;
endproc

When the program is stopped from the PLC and started again from main (StartMain) by the PLC, I still need the count variable to remember its value it has when the program was stopped.

Hi Natalia,

You need to define count variable as persistent.

PERS num count:=0;

BR.

Yea thank you very much , I did that and wanted to confirm it. Thank you very much