steveneads Posted May 16, 2016 Share Posted May 16, 2016 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 Link to comment Share on other sites More sharing options...
steve.milici Posted May 16, 2016 Share Posted May 16, 2016 In Power PMAC, “global”s (and “csglobal”s) are not saved. Note that “sys.P” 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. Link to comment Share on other sites More sharing options...
Clopedandle Posted May 19, 2016 Share Posted May 19, 2016 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. Link to comment Share on other sites More sharing options...
steveneads Posted May 20, 2016 Author Share Posted May 20, 2016 OK, thanks for the help. Link to comment Share on other sites More sharing options...
Recommended Posts