Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Non Volatile [retentive] Global variables?
#1
Hello,

In many systems there is provision for special global variables that maintain their value after a power cycle. The best ones (in my opinion) use the global variable facility with a special type modifier in front of them, such as "Preserve", "NonVolatile" or something like that.

Usually in application you are only maintaining a handful of counters and position values, but it may also involve things like boolean flags that store whether or not a part was loaded into a mechanism, etc for recovery code and what not.

Is there anything like this built into the Power PMAC, or do we need to write a custom server for interfacing to files on the user flash?

Thank you,
KEJR
Reply
#2
In PPmac all the Structures, Global and CSGlobal variable can maintain their values. We use the on-line command SAVE to do this. What is saved is controlled by the file /var/ftp/usrflash/Project/Configuration/pp_save.tpl. In this file you just add the PPmac on-line command needed to get the variable desired. Since this file is on the ftp side after you change it you must issue SAVE for changes tp it to become permanent.

The basic idea is that on power-on/reset the files in /opt/... are copied to the ram disk /var/ftp/... and these are the files used for all operations while running. Only on a SAVE command is data written from /var/ftp/... back to the permanent opt/... locations. The longer answer is:

Everything in Power PMAC, such as your project files which get parsed and loaded at power-on reset are stored in files . If the important Global Vars (P-vars) are stored and initialized in your project they will always have that value at power-on reset. The basic process is like this.
A. When PPmac boots the stored files get copied from OPT/... to Var/Ftp... Var/Ftp is the working area and all changes happen here. Only on a Save command do these files get written to the Opt/... area.
B. The file pp_save.cfg gets loaded into PPmac.
C. The project files (var/ftp/usrflash/Project/) get parsed and loaded toPPmac. This uses the projpp program.
D. The file pp_startup.txt is loaded to the PPmac. This is the last file loaded. It is where you put commands to start and stop PLC, etc to make your initial startup configuration.

In the configuration directory of the Project the file pp_save.tpl controls
what commands are sent to PPmac when SAVE is issued. The responses to these
commands are stored in pp_save.cfg.
Reply
#3
If I am interpreting your reply correctly we can do the following:

- Add a command for each global variable to the "pp_save.tpl" file.
- issue an online "save" command to save these variables.
- Variables last saved values are loaded automatically at project startup.

Is there a special command or other means of only saving the Global variables? I'm thinking of the scenario where you want to issue a "save" command on everything after downloading your project from the IDE, but not wanting to save the programs and parameters every time you want to save the "retentive" global variables. I prefer not to save the servo parameters once they might have been changed during runtime. That is to say I want to make sure that at power up the programs and setup parameters for the servos are exactly what they were when they were downloaded from the development environment.

Thank you,
KEJR
Reply
#4
There are many on-line commands to get variables. pp_save.tpl needs to have native ppmac commands which means you have to use p1 or p100 or q10 and not the names from the global and csglobal definitions. There are many formats to get ranges of variables back p0,65536 or p0,10,100 or p0..1000,3000..350 you can find these in the on-line command manual.

From a C program you can just issue the command to get the variables desired pshm->P[index] or p0,65536 and write them to your own file. From the script or terminal there is only the save command so you would have to do something terrible like having multiple tpl files and using a system command to copy and name the one you want to use to pp_save.tpl and then do the save. That sounds like a mess to me.

In the above post remember the opererations in steps B and C because this means anything in the project overrides what has been saved.
Reply
#5
I think we will probably just read/write a block of memory to/from a file in our Capp as you said, it is seeming simpler for what we want to do.

I think I'll reserve a lower block of P vars (say, P0-P255 e.g.) to be saved/recalled and then we can use the IDE's builtin global variable naming mechanism to access these from either Capps,HMI,or scripts.

Since we are writing our own C API anyhow I'll just add another set of function calls to save and recall these "static" P vars and call them on on power down / power up respectively.

Thank you for the detailed response.

KEJR
Reply
#6
I know this is an old thread, but I just wanted to update it with new instructions:

Here is a method in which you can save custom parameters in Power PMAC using a SAVE command.

To do this, pp_save.tpl file should be modified. The pp_save.tpl file includes a series of Power PMAC Script commands which are executed upon reception of SAVE command and the result of these commands are stored in a file called pp_save.cfg which is saved to EEPROM as a part of your project.

The pp_save.tpl file is usually on the Power PMAC version of the project and not the windows side. If user wants to modify this file, then the following steps should be followed:

1. In the solution explorer, right-click on the Configuration folder in the project and select “Upload Config Files”.
   
2. The pp_save.tpl file is uploaded from Power PMAC into the project Configuration folder on the PC.
3. Edit the pp_save.tpl file using Wordpad or any other text editor.
   
4. In the solution explorer, right-click on the Configuration folder in the project and select “Download Config Files”.
   
5. Issue a SAVE on Power PMAC in Terminal window.
Sina Sattari
Hardware Engineering Manager
Delta Tau Data Systems, Inc.
Reply
#7
Delete the file pp_save.tpl this fie corrupt the configuration...in next release is going to disapear ( I change to next release 1.6.1.1 and did not disapear/change)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)