Jump to content
OMRON Forums

Zero variables on download


daves

Recommended Posts

Is there an easy way to zero all Ptr and Global variables on download?

 

I find that I am running a project using lots of variables, then I need to add a new one, so I put it in my pmh file (say in the middle).

 

I think this is then getting assigned a P/M number in the middle of the list (say 8836) which causes all the ones following that in the file to get shifted.

 

I think (my investigations have lead me this far but I could be wrong) this is causing variables to start with unsatisfactory values from the previously preceding variables (in my case this blows up some filters)

 

I know I should be initialising my variables to safe values but I wonder if zeroing the memory on download (like seems to happen on power up) would be a nice safe condition?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

If you have to do it you can use the pp_startup.txt file to send initialization commands. Normally you would put a command like enable plc 4 to make it the plc that runs at startup. You could of course put initialization code in the PLC inside a command statement command"p0,65535=0". Or you could put the command directly into the pp_startup.txt. Something like p0,65535=0. Just remember that this is the last file to load so all other initializations done anywhere else in the project will be overwritten and perhaps in 6 months when you try to initialize a variable in the project and it does not work you will have some trouble remembering why. This is why I prefer to have it in the variable declaration first or in a startup PLC second.
Link to comment
Share on other sites

A more selective way of doing this is to set an initial value in the variable declaration statement. For example, with:

 

global MyGlobalVar = 0;

ptr MyOutput->u.io:$A0000C.8.1 = 1;

 

each time the project is loaded into active memory, whether downloaded from the IDE or copied from the saved version in flash on power-up/reset, the declared variable is forced to the (constant) value used in the declaration.

 

This is also more flexible and better self-documenting.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...