MartinOphey Posted February 21, 2011 Share Posted February 21, 2011 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 More sharing options...
Omron Forums Support Posted February 21, 2011 Share Posted February 21, 2011 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 More sharing options...
MartinOphey Posted February 21, 2011 Author Share Posted February 21, 2011 Ok, that means there is no way to look c-variable directly?!Because the discribed way takes a lot of time if my code is big and i have a lot of variables. Link to comment Share on other sites More sharing options...
Sina.Sattari Posted February 21, 2011 Share Posted February 21, 2011 Martin, You can also use the C-debugger to watch through your background C programs and check the value of each variable in debugger watch window. But of course this is only useful if you want to debug the code. Regards, Link to comment Share on other sites More sharing options...
Omron Forums Support Posted February 22, 2011 Share Posted February 22, 2011 Martin, I just want to clarify: Do you actually mean local variables declared in the C language, or do you mean actual PMAC C-Variables that are used, for example, locally in kinematics calculations? There is a significant difference between these two in PMAC. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted February 23, 2011 Share Posted February 23, 2011 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 More sharing options...
KEJR Posted February 23, 2011 Share Posted February 23, 2011 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 More sharing options...
Recommended Posts