.

MEIFilterGainPID

Definition

 
typedef	struct MEIFilterGainPID {
    struct {
    float   proportional;     /* Kp */
    float   integral;         /* Ki */
    float   derivative;       /* Kd */
    } gain;
    struct {
        float   position;     /* Kpff */
        float   velocity;     /* Kvff */
        float   acceleration; /* Kaff */
        float   friction;     /* Kfff */
    } feedForward;
    struct {
        float   moving;       /* MovingIMax */
        float   rest;         /* RestIMax */
    } integrationMax;
    long    dRate;            /* DRate */
    struct {
        float   limit;        /* OutputLimit */
        float   limitHigh;    /* OutputLimitHigh */
        float   limitLow;     /* OutputLimitLow */
        float   offset;       /* OutputOffset */
    } output;
    struct {
        float   positionFFT;  /* Ka0 */
        float   filterFFT;    /* Ka1 */
        float   velocityFFT;  /* Ka2 */
    } noise;
} MEIFilterGainPID;

Description

MEIFilterGainPID is a structure that defines the filter coefficients for the PID filter algorithm.

Sample Code


/* setPIDs(...) demonstrates how to set filter PID coefficients. 
Function mpiFilterGainGet(...) obtains a handle to MPIFilterGain 
structure. Then user can use mpiFilterGainSet(...) to write the new 
PID values to controller memory. Note: This function is only showing 
three parameters to be configured, Kp, Ki, and Kd. User can add more 
coefficients as needed. Return values from mpi/mei calls are preserved 
and returned back to the user.  
*/

long setPIDs(MPIFilter filter, float Kp, float Ki, float Kd) 
{
    MPIFilterGain gain;
    long returnValue;
 
    returnValue =  
        mpiFilterGainGet(filter, 0, &gain);

    if(returnValue == MPIMessageOK)
    { 
        gain.coeff[MEIFilterGainPIDCoeffGAIN_PROPORTIONAL].f = (float)Kp;
        gain.coeff[MEIFilterGainPIDCoeffGAIN_INTEGRAL].f = (float)Ki;
        gain.coeff[MEIFilterGainPIDCoeffGAIN_DERIVATIVE].f = (float)Kd;
        gain.coeff[MEIFilterGainPIDCoeffFEEDFORWARD_POSITION].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffFEEDFORWARD_VELOCITY].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffFEEDFORWARD_ACCELERATION].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffFEEDFORWARD_FRICTION].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffINTEGRATIONMAX_MOVING].f = (float)15000;
        gain.coeff[MEIFilterGainPIDCoeffINTEGRATIONMAX_REST].f = (float)15000;
        gain.coeff[MEIFilterGainPIDCoeffDRATE].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffOUTPUT_LIMIT].f = (float)32767;
        gain.coeff[MEIFilterGainPIDCoeffOUTPUT_LIMITHIGH].f = (float)32767;
        gain.coeff[MEIFilterGainPIDCoeffOUTPUT_LIMITLOW].f = (float)-32767;
        gain.coeff[MEIFilterGainPIDCoeffOUTPUT_OFFSET].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffNOISE_POSITIONFFT].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffNOISE_FILTERFFT].f = (float)0;
        gain.coeff[MEIFilterGainPIDCoeffNOISE_VELOCITYFFT].f = (float)0;
    
     returnValue =
        mpiFilterGainSet(filter, 0, &gain);
     }

     return MPIMessageOK; 
} 

See Also

High/Low Output Limits section for special instructions regarding MEIFilterGainPID.
MEIFilterGainPIDCoeff

 

       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2010 Motion Engineering