Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
P variable value on power up
#1
Could someone clarify what the value of a P variable (global) is on power up? In UMAC it was whatever had been saved in flash.

Is it simply a random undefined value unless it has explicitly set in a file such as global definitions.pmh or PLC 1?

I've had some issues where "nan" and "inf" have appeared in globals, and I suspect that it's because I've not initialised everything that I need to at power up.

If I do need to make sure that key variables are explicitly initialised, is there an easy way to do this for arrays, so that I don't need to use a loop or add loads of lines, ie something like:

global Xvalue(100) = 0;

Maybe it's in the manual somewhere - but I didn't spot it!

Thanks
Steve
Reply
#2
In Power PMAC, “global”s (and “csglobal”s) are not saved. Note that “sys.P[i]” is described under “Sys. Global Non-Saved Setup Data Structure Elements”. A “global” (valid P-variable) should never return “nan” unless explicitly assigned by user startup code. These are initialized to zero by the firmware on reset.

Initializing array elements will require individual assignment, or some type of looping mechanism.
Reply
#3
There is actually an easy way to initialize all P-Variables to 0! Use vscale.

For example to set P0 - P65535 to 0 at powerup:

L0 = vscale(0,0.0,0,65536)


Fundamentally, this just multiplies all P-Variables by 0.
Reply
#4
OK, thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)