Jump to content
OMRON Forums

How I can watch lokal C-Variables


MartinOphey

Recommended Posts

How I can watch lokal C-Variables form rticplc.c?

Regarding the folowing sample: stiffness1

 

 

#include #include #include #include #include #include "../../Include/pp_proj.h"const double pi = 3.1415926535;void simulation(void);void realtimeinterrupt_plcc(){simulation();	}void simulation(void){//input variables for simulation double mass, freq1;       //output variablesint feedback1;//simulation constantsdouble stiffness1;       ....       //copy parameters from P-variables  to double variables       mass = GetGlobalVar (pSimMass);       ...      stiffness1 = 2 * pi * pi * freq1 * freq1 * mass;      feedback1=....       ....      //set the simulation output parameters: feedback positions       SetPtrVar (mSimMotor1FeedbackPos, feedback1);}

 

 

 

Thanks

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

One way you can monitor the local variables in C is to store the value in a P-Variable and put the P-Variable into a Watch Window in the IDE. For example, you could modify your code as such:

 

 

#include #include #include #include #include #include "../../Include/pp_proj.h"const double pi = 3.1415926535;void simulation(void);void realtimeinterrupt_plcc(){   simulation();    }void simulation(void){   //input variables for simulation   double mass, freq1;       //output variables   int feedback1;   //simulation constants   double stiffness1;       ....       //copy parameters from P-variables  to double variables       mass = GetGlobalVar (pSimMass);       ...      stiffness1 = 2 * pi * pi * freq1 * freq1 * mass;      feedback1=....       ....      //set the simulation output parameters: feedback positions       SetPtrVar (mSimMotor1FeedbackPos, feedback1);pshm->P[1000] = mass;pshm->P[1001] = freq1;pshm->P[1002] = stiffness1;pshm->P[1003] = feedback1;       return;}

 

 

Now just place P1000 through P1003 into a Watch Window to monitor what's in the associated variables.

Link to comment
Share on other sites

For the variables you want to monitor globally, you may also consider just defining those variables in your global definitions.pmh file, and then using them directly from C, rather than declaring a local variable in your C program and copying to a P-Variable. For example, in global definitions.pmh, you could define:

 

 

global stiffness1;

 

 

Then, in any of your C programs, refer to that variable like this:

 

 

pshm->P[stiffness1]

 

 

For example, you could assign a value of 5.3 to stiffness1 globally like this:

 

 

pshm->P[stiffness1] = 5.3;

 

 

This will take effect in the C program, and you can monitor it globally in the IDE with Watch Windows. This works because PMAC will take all of the global P-Variables you define in the global definitions.pmh file and actually create and download a header for its own C programs, defining the number of the P-Variables used. In this case, if your global definitions started with P8192 and stiffness1 is the first global variable you have defined, the C header that would download to PMAC would include:

 

 

#define stiffness1 8192

 

 

Thus when you use stiffness1 as an index in your C program to access the P-Array in the pshm structure, you get access directly to the P-Variable itself.

 

Link to comment
Share on other sites

For the variables you want to monitor globally, you may also consider just defining those variables in your global definitions.pmh file,

 

+1

 

The only down side is that every value is a double, but I've found this to be insignificant for my work. YMMV.

 

KEJR

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...