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.

mech_scaler question in Example_posspeed.h

Other Parts Discussed in Thread: TMS320F28335

Hello all, I am using a TMS320f28335 ezdsp and I am trying to get a 2048 line quadrature encoder to work. I am goin over the example code from the DSP2833X examples and inside Example_posspeed.h there is an int called mech_scaler. The comment says .9999/total count, total count = 4000. It is then initialized to 16776. However on line 146 of Example_posspeed.c it says that mech_scaler is the total count in 1 revolution. I would think that this value for me should be 2048*4, but this isnt consistent with the header. For one thing, .9999/total count should be less than 1,  and where 16776 came from eludes me anyway. Can anyone help? Thanks

Gideon

 

ps,

Sorry for the length, but two other quick questions if anyone has the time.

1) Is base rpm discussed in the example the maximum rpm the motor can produce?

2) What are the references to Q in the comments (ie, Q26 or Q26->Q15) ?

 

Thanks again

  • Gideon-

    I'm not an expert on Q math and the IQ library, but the numbers are not making sense because they are in Q-format  (common format used for fixed-point math esp. for values less than 1). To convert from Q0 (normal number with values less than 1 after the decimal point) to Q26, you multiply a number by 2^26. Likewise to convert from Q26 to Q0, you divide by 2^26. You convert between low Q #'s and high Q #'s to maintain the resolution of numbers less than 0 without truncating values. (Q math moves values normally after the decimal point before the decimal point to do the math, then converts back to the original format)

    The eQEP examples use the IQMath library which defines common IQMath fixed-point math functions (see the IQMath user guide for more information).

    Now concerning the eQEP example.  The 16776 = 1/4000 *2^26, which is 1/4000 in Q26 format, as noted in the example.

    1) Yes, base rpm is maximum speed (noted in Example_2833xEqep_pos_speed.c description.

    2) Explained above.

  • Thank you for your reply. That makes a lot of sense. Do you know of any qep examples using a floating point processor?