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.

TMS320F280049: Question about Sin/cos lib

Part Number: TMS320F280049
Other Parts Discussed in Thread: DESIGNDRIVE

Hi Team,

My customer would like to use 280049 in sin/cos sensor part, and I want to know if we have any resource or lib can use in this situation.

My customer only use the sensor TAS2440, output signal is Sin and Cos. And would like to calculate the angle to do the motor control

Question:

  1. First question is if we have such reference code to use in this ?
  2. Second question: if we have no such reference code ,I check the PM_SINCOS_LIB, it use the QEP and sin/cos together. if we can modify the code to use in it? If we can, what we need to modify?

Thanks!

Jenson

  • Jenson,

    This application note on the sin/cos library may help.  I took a look at the application note and it does have information on angle calculation. 

    Unfortunately the author is no longer at TI so our current ability to answer questions is limited.  Please see if it helps your customer. 

    http://www.ti.com/lit/SPRUI54

    www.ti.com

    Regards

    Lori

  • Hi Lori,

    I have few question about this Library,

    1.Since I don't use EQEP, can I just use fine angle?

    2.I found that the input of the data is uint16 (the result of ADC conversion),I would like to know how its input is like? 0~3.3V sin/cos?

    Thanks

    Jenson

  • Hi Jenson,

    Lori is out of the office currently. She'll respond to you later this week once she's back (around the 16th).

    Best,

    KEvin

  • 1.Since I don't use EQEP, can I just use fine angle?

    Jenson,

    In section 1.3.2.2 - Table 1 shows different modes for the library.  In mode 0 and 1 the fine angle and the coarse angle are calculated in software and the eQEP is not used.  

    2.I found that the input of the data is uint16 (the result of ADC conversion),I would like to know how its input is like? 0~3.3V sin/cos?

    A Sin/Cos encoder typically outputs signals as a differential output.  This must be connected to a differential amplifier to produce the single signal to the MCU's ADC. 

    I know of 3 hardware references with these connections:

    1. C2000 DesignDRIVE Development Kit for Industrial Motor Control (https://www.ti.com/tool/TMDXIDDK379D
    2. C2000 Position Manager booster pack (https://www.ti.com/tool/BOOSTXL-POSMGR)
    3. TI design "Interface to Sin/Cos Encoders With High-Resolution Position Interpolation"  https://www.ti.com/tool/TIDA-00176 

    Note: The design guide for #3 includes good information on Sin/Cos encoders.

  • Hi Lori,

    Thanks for your reply.

    Actually, I looked at this code carefully, but still have some question.

    1. What does the offset in the code want to correct?
    For example, my signal input is sin/cos of 0~2048. After running the code, I can get an offset of 1024, which is not wrong. However, when calculating the angle, the correct angle cannot be calculated. My understanding is that 1024 will be used as the center point, that is, 0, 2048 corresponds to the maximum value of 1, and 0 corresponds to the minimum value of -1. Then in the arctangent operation, the correct 0~1 (representing the pu of the angle) can be calculated. value, 0~360 degrees). But I found that when I input 0, the corresponding sincorr=-1.5. And when I input 2048, use sincorr=-0.5. So I think that the correct angle value can be calculated only when the input is (1024~5120), yes Like this?

    PS I am using the following formula to calculate
    // fineAngle = _IQ15frac(_IQ15mpy(_IQ15(4.0), _IQ15atan2PU(p->coscorr, p->sincorr))); // fine angle is 4x to match QEP edge counter
    fineAngle = _IQ15atan2PU(p->coscorr, p->sincorr); // No need EQEP

    2.If I want to use this lib to calculate sin/cos input as 1024~3072, what should I do? (1024 corresponds to -1, 3072 corresponds to 1 to calculate the angle)

    Thanks very much 

    Jenson

  • Jenson,

    Unfortunately the author of this code and application note is no longer at TI.  Our current ability to answer questions is limited.  I will take a closer look and respond early next week if I gain more understanding. 

    Regards

    Lori

  • Hi Lori,

    Thank you very much for your help, I have seriously studied this code.


    I think the problem is this


    The code converts the ADC input.


    If the ADC input is 0~4096, chin corresponds to output -1~1, which is fine. But since our input signal is not necessarily 0~4096 at present.
    For example, the input of sin and cos is 1024~3072, then the output of chin is -0.5~+0.5. This does not meet expectations. I'm thinking how to scale 1024~3072 to 0~4096. Take the input maximum and minimum values as -1~1. Then that should solve the problem. do you have any comments on this

    //code like below. input 0~4096 output -1~1

    ch0in = (_iq15)((long) p->sindata << 4) - _IQ15(1.0); // align MSB in 12-bit mode
    ch1in = (_iq15)((long) p->cosdata << 4) - _IQ15(1.0);

    Thanks for your help

    Jenson

  • Jenson,

    How is the encoder connected to the C2000?  Does the interface amplify and level-shift the differential signals to create a single-ended input to the C28x ADC?  

    Lori