Jump to content
OMRON Forums

Setting of Motor[x].PhaseCtrl with a user algo


steveneads

Recommended Posts

I'm running some code to pre-process data in the phase interrupt using Motor[0]. I have set Motor[0].PhaseCtrl=1 and used the "User servo setup" under "Realtime routines" in the IDE to select the C code that I've written. The code runs, but have I done all that I should do to ensure that unnecessary calculations are not being performed in the background?

 

I don't really understand the meaning of Motor[0].PhaseCtrl when User Phase code has been chosen (for instance if I set Motor[0].PhaseCtrl=8, my code stops running). Can you clarify this please?

 

When user code is set to run in the servo interrupt for Motor[x], the value of Motor[x].Ctrl is reported as UserAlgo.ServoCtrlAddr[x]. Is there an equivalent to this setting when user calculations are run in the phase? in my case with Motor[0] running user code in the phase, and the system reports Motor[0].Ctrl=Sys.ServoCtrl - which rather surprised me.

 

Thanks

Steve

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

As page 423 of the PPMAC SRM states,

 

"if Motor[x].PhaseCtrl is set to 8, this motor will execute its servo tasks in the phase interrupt, but not execute any phase commutation tasks for the motor. In this case, it is advisable to set Motor[x].pAdc to 0 to disable reading of current-feedback ADCs. (Reading the ADCs in this case wastes processor time, but does not otherwise hurt calculations. The ADC values read are not used.)"

 

So basically your servo algorithm would be running at the phase rate, but the phase algorithm would not run at all.

 

I am not aware of which parameter gets changed upon selecting a custom phase algorithm.

 

Generally speaking, you want to set Motor[x].Phasectrl = 1 if you are running a custom phase algorithm associated with Gate3 ASIC technology, or =4 if you are running a custom phase algorithm associated with PMAC2 ASICS or MACRO transfers. Some amplifiers we make also force you to use PhaseCtrl = 4, so check the manual for your hardware.

 

Lastly, I don't understand your question, "have I done all that I should do to ensure that unnecessary calculations are not being performed in the background?" Can you give a little more context?

Link to comment
Share on other sites

Hi Charles

 

Your reply has given me a clue to my misunderstanding. I had not appreciated the difference between running my user code as a "User Phase" with Motor[0].PhaseCtrl=1 or running the same code as a "User Servo" with Motor[0].PhaseCtrl=8.

 

What I want to do is to run my user code in the phase interrupt without PPMAC performing any unnecessary background tasks that I don't need for this code. The code is processing information and inserting it into the ECT - so I want the code to run before the ECT is processed, but it's not controlling motors directly. Curt previously suggested running code in the phase interrupt to do this.

 

Is running my code as a "User Servo" with Motor[0].PhaseCtrl=8 the right thing for me to do?

 

Thanks.

Link to comment
Share on other sites

That is correct.

 

For example, if I set up my "usrcode.c" in the Realtime Routines folder to be:

 

#include "usrcode.h"
extern struct SHM        *pshm;  // Pointer to shared memory
extern volatile unsigned *piom;  // Pointer to I/O memory
extern void              *pushm; // Pointer to user memory


double user_pid_ctrl(struct MotorData *Mptr)
{
 pshm->P[2000]++;
 return 0.0;
}

 

And "usrcode.h" to be:

 

#ifdef __KERNEL__
#include 
#else
#define EXPORT_SYMBOL(x) // x
#define KERN_ALERT
#define printk printf
#include 
#endif
#include 	// Global Rt/Gp Externals and structures
#include 
#include "../Include/pp_proj.h"

double user_pid_ctrl(struct MotorData *Mptr);
EXPORT_SYMBOL(user_pid_ctrl);

 

Then, associate Motor 0's User Servo with user_pid_ctrl, and place the following settings into "global definitions.pmh" under Global Includes in the Script language folder:

 

Motor[0].PhaseCtrl = 8;
Motor[0].ServoCtrl=1;

 

Then, finally build and download the whole project.

 

I now see P2000 incrementing at the phase rate in the Watch Window.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...