Jump to content
OMRON Forums

Name -> P variable


JeffB

Recommended Posts

Is there anyway to programmatically lookup a variable's assigned p#? I don't want to hard code the P# in the program because it may change as variables are added. But for some frequently read variables I'm thinking reading a p variable may be more efficient so at the app startup I would like to lookup the p variable from the variable name and use that for the duration of the program.
Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

I agree with Eric, in that I'm not sure why knowing the number would be more efficient than using the name.

 

That said, one other thought is that when you perform a build and download in the IDE to load your project, we should map all global variables to pp_proj.h with their corresponding P-Var number. For instance, if I make a blank project but declare

 

GLOBAL MyFirstGlobalVar

 

In pp_proj.h, I get the corresponding line:

 

#define MyFirstGlobalVar pshm->P[8192]

 

Depending on your application, you may be able to read that file as text, then parse it for your desired variable name.

Link to comment
Share on other sites

Is there a reason reading the P-Variable would be more efficient?

 

Our names tend to be things like scan_distance_mm and we may query 20 at a time so I thought less text being communicated would be more efficient. Also if variables happened to be consecutive I could use the PXXX..PYYY syntax. And I assume on the PMAC side if I send a name there has to be some kind of lookup hash table to find the memory address whereas the memory address can presumably be calculated directly from the P-variable

 

I remember there's an "echo7" command sent at the beginning of our gpascii run. Maybe I can toggle that to see the P variables.

 

Thanks

Link to comment
Share on other sites

I remember there's an "echo7" command sent at the beginning of our gpascii run. Maybe I can toggle that to see the P variables.

Oh, you might not be in the default echo mode.

"echo 7" will give a response that is only the value of your variable.

Try "echo 0" to see the P-Variable, M-Variable or PMAC Structure name in the reply.

Link to comment
Share on other sites

  • 1 month later...

When you enter a P or M variable name in the terminal, this variable number is shown. It should be possible to collect that information from the C environment.

 

Is there a reason reading the P-Variable would be more efficient?

 

From the Power PMAC User manual: "When this is done, the communications application will check command lines against the automatically generated “symbol table” for variable names and substitute the underlying numbered variable name. This process is invisible to the user. It does add some computational overhead to communications, but in most applications, this is not noticeable."

 

Is there a way to access the symbol table?

 

Jeff

Link to comment
Share on other sites

Jeff,

 

You can try to go into those files if you want, but it will be a bit complicated. I can't support making a tool to translate variable names based on this table. As Alex mentioned, pp_proj.h lists P-Variables. For a default project this can be found here on the PC:

C:\Users\[Windows Account Name]\Documents\PowerPMAC IDE\PowerPMAC1\PowerPMAC1\C Language\Include

 

I'd really like to know why you are trying to access these global variables by the P-Variable number in the first place. There has to be a simpler solution than looking up the P-Variable number. PMAC essentially looks up that number for you. Maybe you have an HMI sending PMAC commands over SSH and just need to add the -2 after "gpascii -2" to access global variables by name.

 

Are you trying to enter global variable names in a place where they do not work but P-Variables do?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...