Jump to content
OMRON Forums

How to use pmh file to map to specific P var


Recommended Posts



I want to use the pmh file to define globals that can be used in both script and C programs but that need to map to *specific* P variables.


something like:


global P1000 MyVarName;


where in C code it translates to "pshm->P[1000]" (using script mode preprocessor define) and in script code it translates to "P1000".


I know I can do:


#define MyVarName pshm->P[1000]


and this will work for C code, but I believe it will bomb in the script environment.


Normally I don't want to know what P var it maps to, but in this case I have a block of P vars (P1000-P1999) that gets backed up to disk and I'd like to specify certain globals as Non Volatile by hard coding them to a variable in this range.




Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You're almost there already. The syntax is like this:


#define MyVarName P1000


Then in Script you can access it as either MyVarName or P1000 equivalently, and then depending on your C P-Variable settings, you can refer to it as pshm->P[1000] or pshm->P[MyVarName] equivalently with the default P-Variable mapping, or as MyVarName with the new P-Variable mapping.


Does that answer your question, or did I miss something?

Link to comment
Share on other sites

With the new features of pp_proj.h this is already made. Just do


#define myvar p1


in the .pmh file and after a build look at the pp_proj.h in the directive area for #ifdef _PPScriptMode_ and you will see we ahve made


#define myVar pshm->P[1]


for you. In the other thread you were involved in you alread know to add


#define _PPScriptMode_ into any C program before the include of pp_proj.h that you desire should use thse #defines

Link to comment
Share on other sites

Hi Guys,


Thank you so much. I was sweating a little last night because I had put 3-5 days into the Non volatile memory module that requires fixed mapping to P variables and I didn't see any example code for this. Now we can access the "non volatile" block of P variables from HMI, Script, and C by symbolic name, which was my original intent.


The thing that was throwing me is that I thought I had to incorporate it into the "global" keyword syntax.


BTW, thanks again for implementing the script mode access for P vars, it is very cool. I have one project converted over already and it cleaned up the C code substantially and helps to eliminate mixing up Ptr vars and global vars.


Thank you,


Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...