Resolver project, Matlab library set for MPC 5748G

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Resolver project, Matlab library set for MPC 5748G

403 Views
jzhang1
Contributor II

Hi, I'm trying to use MPC5748G for my Resolver-to-Digital-Converter project. Basically reading the Sin and Cos waveform from the resolver of DC motor by ADC module, and calculate the angle by Atan of (sin/cos). I'm also planning to implement PI control and FIR filter later, so I choose to use Matlab library set. Then I have the problems as below.

There are two types of function available in Matlab library, which are "GFLIB_Atan" and "GFLIB_AtanYX". This time I use "GFLIB_Atan_F16" as an example:

     tFrac16 GFLIB_Atan_F16(tFrac16 f16In, const GFLIB_ATAN_T_F16 *const pParam);

where the input "f16In" range is [0,1). When I physically connected the resolver to the board, the result of this function remains unchanged. The reason causes the problem is the quotient of 2 ADC readout is always greater than 1, and it causes saturation(at lease this is what I saw in the Expressions windows when I pause). While EWL_C library doesn't have such this issue, but AMMCLIB and EWL_C can not use together. Does anyone have a solution?

 

void ADC1_Read_Chan (void) { /* Read conversion results */
    Result_sin= ADC_1.CDR[8].B.CDATA; /* Read channel 9 conversion result data ; channel 8 ->PD8 */
    Result_cos= ADC_1.CDR[7].B.CDATA; /* PD[7] */
}

while(1) {
if (ADC_1.ISR.B.ECH) { /* If normal scan channels finished converting */
    ADC1_Read_Chan(); /* Read conversion Results */
    f16Input1 = (tFrac16)(Result_sin);
    f16Input2 = (tFrac16)(Result_cos);
    f16Angle = GFLIB_Atan_F16(f16Input1/f16Input2,GFLIB_ATAN_DEFAULT_F16);
    ADC_1.ISR.R = 0x00000001; /* Clear End of CHain (ECH) status bit */
}

 

Labels (1)
0 Kudos
0 Replies