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.

TMS320F2812 MC reference code and IQMath questions

Other Parts Discussed in Thread: TMS320F2812

 

Hello,

Can you please help answer these questions for my customer?

I’m trying to figure out the cause of noisy spikes on motor current in one of our products. The motor control processor on this product is TMS320F2812. When I dive into the motor control part of the code, I’ve noticed that the motor control code is based on TI’s reference code designed by TI’s Digital Control System Group. I was able to find  the corresponding reference sprc177.zip on your web site. However, I’ve some questions regarding your C2000 motor control reference code. In the function F281X_EV1_QEP_NO_INDEX_Calc() of f281xqep_no_index.c, what does __qmpy32by16(p->MechScaler, p->RawTheta, 31) really do?

 

In addition, I also have some questions regarding IQMath as following:

1.       Both inputs A and B to the function _IQ15mpy(A, B) in IQMath Library should be in _iq15 format according to the document. What will be the consequence if both of the inputs are not actually _iq15 format (for example, A is in _iq30 format, B is an int32)?

2.       What will be the data format of the result by adding two different _iq format numbers together (for example, _iq15 (IQ17.15) and _iq30 (IQ2.30))? Will it generate a result of _iq15(IQ17.15) format?

 

I would really appreciate if you could provide some answer to these questions.

Thanks

  • Jacqueline,

    From the processors wiki:

    "Q: Where is the function __qmpy32by16 documented?

    This function is a compiler intrinsic and is documented in the TMS320C28x Optimizing C/C++ Compiler User's Guide (spru514)."

     

    1) In the case that the function inputs are not in the right format the result of the computation will be garbage.  For the library to compute meaningful results, arguments passed to the function must match the types that the function was designed for.  Conversion utilities are provided in the IQ math package to make translation between types easy.

    2) Once again adding two differently formatted numbers will yield garbage.  Floating point numbers are stored as a sign bit, exponent, and fractional part.  Different IQ formats have different sized exponent and fraction fields.  Doing a bitwise add will mix the fields and when interpreted will yield a value that is incorrect.

    Trey