mpiFilterPostFilterGet

Declaration

int32_t mpiFilterPostFilterGet(MPIFilter                   filter,
                            int32_t                        *sectionCount,
                            MPIFilterPostFilterSection  *sections);

Required Header: stdmpi.h

Description

mpiFilterPostFilterGet reads an MPIFilter object's postfilter configuration. It writes to sectionCount the number of sections within a postfilter if sectionCount is not NULL. It also writes to sections the current array of filter's postfilter sections if sections is not NULL.

The MPI calculates the post filter coefficients and takes into consideration the sample rate of the controller at that time. If you change the sample rate of the controller, you will need to recalculate the post filters. This can be done for all filters specified in Hertz by setting the filters again with the MPI. The MPI will calculate the filters using the current servo sample rate.

Postfilters are used to digitally filter the output of a control loop. One common use for postfilters is the compensation of system resonances.

filter the handle of the MPIFilter object whose postfilter configuration is to be read.
*sectionCount the data location where the postfilter's current section count will be written.
*sections the data location where the postfilter's current section configuration data will be written.
Return Values
MPIMessageOK
MPIFilterMessageCONVERSION_DIV_BY_0
MPIFilterMessageINVALID_FILTER_FORM

Sample Code


/*   Count the number of resonator sections in a MPIFilter object's postfilter.   
     Sample usage:   

     returnValue =        
         filterResonatorCount(filter, &resonatorCount);
*/

int32_t filterResonatorCount(MPIFilter  filter, int32_t * count)
{    
     MPIFilterConfig config;    
     MPIFilterPostFilterSection sections[MPIFilterPostFilterSectionCOUNT_MAX];    
     int32_t sectionCount, index;    
     int32_t returnValue = (count==NULL) ? MPIMessageARG_INVALID : MPIMessageOK;    
    
     if (returnValue == MPIMessageOK)    
     {        
         returnValue =            
             mpiFilterPostFilterGet(filter, &sectionCount, sections);  
      
         if (returnValue == MPIMessageOK)        
         {            
             for (*count=0, index=0; index sectionCount; ++index)            
             {                
                  if (section[index].type == MPIFilterPostFilterSectionTypeRESONATOR) ++(*count);
             }        
         }    
      }    
      return returnValue;
}

See Also

MPIFilterPostFilterSection | mpiFilterPostFilterGet | mpiFilterPostFilterSet | meFilterPostfilterSectionGet | MPIFilterPostFilterSectionCOUNT_MAX | Post Filter Theory