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.

How to use DMClib's "resolver" software module?

Other Parts Discussed in Thread: CONTROLSUITE

Hi all,

I'm planning to control a motor using TI's DMClib. My motor is equipped with a resolver, but not a common one: It just needs a 5V supply and outputs the sine and cosine signals, which are already demodulated and filtered. It outputs four periods per mechanical turn. Since the motor has four pole pairs, this should be helpful.

When reading the module documentation, which comes with the controlSuite, I was wondering about Figure 1, showing the absolute, demodulated and filtered sine signal. Where is the negative half period of the wave? Was it rectified? If yes, how should you obtain the exact angle of the rotor?

And second question: How do I calculate an appropriat value for the variable "SignalGain"?

So far, I fed the normalized sine and cosine signals directly into the position_speed_calc()-function, bypassing the demodulator_calc() and filter_calc() functions. But the output values are in the dimension of 10^24(!) when watching them in debug mode. And at the moment I'm a bit stuck at this point.

Thanks for your help!

  • Philipp,

    Can you confirm which software/documentation you are looking at?  (a path should be sufficient)

    What C2000 device do you hope to work with?


    Thank you,
    Brett

  • Hi Brett,

    I got my information from the document with ID SPRC178. The pdf I'm referring to is located under

    tidcs\DMC\c28\v32x\lib\doc\resolver.pdf

    I'm using a C2000 F28335 with TMDSDOCK development board. IDE is CCS4.

  • Phillipp,

    This is what I expected, but was not sure.

    The software you are referring to is quite old and we have made improvements to the underlying control software since then.  I would recommend changing to software found in controlSUITE if possible.  Inside, several of these projects work directly with the F28335 device and should serve as a good reference. (this will also be beneficial because more engineers are working on this code base and therefore can provide feedback)

    \controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.0\

    Your 'resolver' seems to me more similar to a SinCos encoder.  (something like this very old appnote: http://www.ti.com/lit/an/spra496/spra496.pdf)  If I'm right, I would bring your sin and cos signals separately to individual ADC input and perhaps also separately through comparators and to a QEP module.

    Hopefully this helps.


    Thank you,
    Brett

  • Hi Brett,

    I read the sine and cosine value with the ADC and internally normalize the values to range from -1... 1 for each signal. Calculation for the electrical theta works fine with the Atan2PU IQ function. But I hoped there would be a ready-to-use module that also outputs the speed and other values like the resolver module does. But speed calculation should be no problem, since the PWM period is know.

    I will look through your posted pdf tomorrow. In germany it's 10pm already.

    Thanks so far!

  • Hi Brett,

    you seem to be right with your Sin/Cos encoder. Unfortunatly, I'm still having some issues here.

    I read the ADC values for the sin and cos trace and normalize both of them from -1... 1. This is working. Then my idea simply was to use the _IQatan2 function. Afterwards I add 2*PI to the result when the sine value is <0 to get a atan2 "ramp" from 0 to 2*PI. Then normalization with division by 2PI.

    This is my current approach (you will find some rudiments from the resolver module ;-):

    Tmp1 = _IQatan2(v->CosIn,v->SinIn);

    // add 2*Pi if angle > 180° (= negative sine value)
    if(v->SinIn < _IQ(0.0))
      Tmp1 += _IQ(6.28318);

    // Normalize from 0 (=0°) to 1 (=359°)
    v->OutputTheta = _IQdiv(Tmp1,_IQ(6.28318));

    However I don't get a correct value for Tmp1. It's always in the dimension of 10^38. Can this be a data type issue? I tried this in Excel to see if my idea would work (theoretically).

    Can you help me in this case?

    Here is a screenshot of the original signals. They are halved before beeing fed into the DSP with an ohmic voltage divider.

    Thanks so far!

  • Philipp,

    I think the issue is a data-type kind of issue.

    What is the data-type of CosIn, SinIn and Tmp1?  Ideally, these will be of some IQ type and should match.  Your task will then be to use the proper IQ atan function (_IQNxxx() or _IQNxxxPU(), where "xxx" is the Function Name & "N" is the Q format of the input/output).

    If this doesn't make sense, I would recommend taking a look at the IQmath_Quickstart.pdf guide found in controlSUITE at the following approximate directory:
    \controlSUITE\libs\math\IQmath\v160\doc\


    Thank you,
    Brett

  • Hi Brett,

    I just had a quick look into the IQmath manual and found the solution... I changed the function parameters for the atan2-function. 

    It's finally working as I expected:

    /* Arctan2 Function (this is where the mistake was) */ 
    v.Tmp1 = _IQatan2(v.SinIn,v.CosIn); 

    /* Add 2*PI for angle > 180° */ 
    if(v.SinIn < _IQ(0.0)) 
      v.Tmp1 += _IQ(6.28318); 

    /* Some low-pass filtering */ 
    v.FilterGain = _IQ(0.95); 
    v.FilterTheta = _IQmpy(v.FilterGain,v.FilterTheta) + _IQmpy((_IQ(1)-v.FilterGain),v.Tmp1); 

    /* Normalize from 0 (=0°) to 1 (=359°) */ 
    v.OutputTheta = _IQdiv(v.FilterTheta,_IQ(6.28318));

    Tmp1, SinIn and CosIn are IQ values.

    Thanks for the suggested solutions! Until next time!

    Philipp