This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Resolver Kit: Understanding the offset calculation

Hi,

I am using the C2000 Resolver Kit (TMDRSLVR). In the initialization there is a routine that calculates the sine and cosine offset. In a for-loop with 32769 cylces mainly the following code is being executed:

rslvr.offsetS += _IQ20mpy((((int32)ADCResult.ADCRESULT0 << 9) - rslvrIn.offsetS), offsetWfT);
rslvr.offsetC += _IQ20mpy((((int32)ADCResult.ADCRESULT1 << 9) - rslvrIn.offsetC), offsetWfT);


Can anyone tell me what is happening there ? Why is there a left shift of 9 bits and a multiplication with the "offset filter constant" ?

Thanks in advance !

- Brian

  • Brian,

    ADC output is 12 bits. This data is converted to IQ20 format by shifting left by 9 bits. 'offset filter constant' corresponds to the cutoff frequency for the low pass filter (LPF). LPF is needed to even out the ripples in offset measurement.

    rgds,
    Ramesh
  • Thank you for the reply !

    Ramesh Ramamoorthy said:
    This data is converted to IQ20 format by shifting left by 9 bits.

    I asked myself why not to convert the data with the IQmath library function so I compared:

    #define GLOBAL_Q 20
    int32 a,b;
    
    a = ((int32)2047 << 9);
    b = _IQ(2047);

    Result:

    a = 00000000000011111111111000000000
    b = 01111111111100000000000000000000

    For me a left shift of 9 bits is not the same as a conversion into IQ20 format.

    In my understanding IQ20 format is looks like 

    S | EEEEEEEEEEE | FFFFFFFFFFFFFFFFFFFF

    According to that, a = 0,9995117188 and not 2047 or am I wrong ?

    - Brian

  • The intent is to work with pu values, which means 1.0 is the max value. IQ(2047) will make it 2047.000 instead of 1.0 (or, 0.999xxxx)

    rgds,

    ramesh

  • Thank you very much ramesh !

    I have a second question. I am testing the library with calculated data instead of ADC samples. For 45° I use the 9 bit left shifted version of

    int32 Samples[8] = {0, 1023, 1447, 1023, 0 -1023, -1447, -1023};

    as rslvrOut.sin_input and rslvrOut.cos_input.

    The problem: Watching the expressions window while debugging shows, that the angle is being calculated correctly (in this case -786435 (integer)) but it looks as if the whole struct rslvrOut is not updating. Except for sin_input, cos_input and sineIndex. I can even change for example the value of cosFIRout to a random number and it is not being overwritten is expected.

    What is the issue here ?

    - Brian

  • It is difficult get to those details, you will have to spend some more time degbugging.

    rgds,
    ramesh