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.

EQEP Problem with accurate speed estimation

Other Parts Discussed in Thread: CONTROLSUITE

Hi guys,

Recently I've been working on the example of "controlSUITE\device_support\f2806x\v151\F2806x_examples_ccsv5\eqep_pos_speed" for estimation of position and speed. I have a simple DC motor equipped with 2000 ppr encoder. The nominal speed of the motor at 24Volt is 6000Rpm. I tried the example first with simulated Pwm and the result was fine. then I went to connect it to my encoder.

After connection of the encoder (my encoder doesn't have index revolution pulse), and changing the variable "mech_scaler" from 16775 which is for a 1000ppr encoder to (0.9999/(4*2000))*2^26 which is 8387. but the problem is my calculated speed in variable "qep_posspeed.SpeedRpm_fr" is almost half of the current speed of the motor. for example at nominal voltage the speed is like 2800Rpm which should be near 6000, and in low speeds this problem becomes more sensible. 

I also took a look at the excel file provided by Ti for the example, but couldn't find any useful data for my problem. so my question is what should I change and how? 

//###########################################################################
//
// FILE:    Example_posspeed.h
//
// TITLE:   Pos/speed measurement using EQEP peripheral
//
// DESCRIPTION:
//
// Header file containing data type and object definitions and
// initializers.
//
//###########################################################################
// $TI Release: F2806x C/C++ Header Files and Peripheral Examples V151 $ 
// $Release Date: February  2, 2016 $ 
// $Copyright: Copyright (C) 2011-2016 Texas Instruments Incorporated -
//             http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################

#ifndef __POSSPEED__
#define __POSSPEED__

#include "IQmathLib.h"         // Include header for IQmath library
/*-----------------------------------------------------------------------------
Define the structure of the POSSPEED Object
-----------------------------------------------------------------------------*/
typedef struct {int theta_elec;         // Output: Motor Electrical angle (Q15)
                int theta_mech;         // Output: Motor Mechanical Angle (Q15)
                int DirectionQep;       // Output: Motor rotation direction (Q0)
                int QEP_cnt_idx;        // Variable: Encoder counter index (Q0)
                int theta_raw;          // Variable: Raw angle from Timer 2 (Q0)
                int mech_scaler;        // Parameter: 0.9999/total count, total count = 4000 (Q26)
                int pole_pairs;         // Parameter: Number of pole pairs (Q0)
                int cal_angle;          // Parameter: Raw angular offset between encoder and phase a (Q0)
                int index_sync_flag;    // Output: Index sync status (Q0)

                Uint32 SpeedScaler;     // Parameter :  Scaler converting 1/N cycles to a GLOBAL_Q speed (Q0) - independently with global Q
                _iq Speed_pr;           // Output :  speed in per-unit
                Uint32 BaseRpm;         // Parameter : Scaler converting GLOBAL_Q speed to rpm (Q0) speed - independently with global Q
                int32 SpeedRpm_pr;      // Output : speed in r.p.m. (Q0) - independently with global Q

                _iq  oldpos;            // Input: Electrical angle (pu)
                _iq Speed_fr;           // Output :  speed in per-unit
                int32 SpeedRpm_fr;      // Output : Speed in rpm  (Q0) - independently with global Q
                void (*init)();         // Pointer to the init funcion
                void (*calc)();         // Pointer to the calc funtion
                }  POSSPEED;

/*-----------------------------------------------------------------------------
Define a POSSPEED_handle
-----------------------------------------------------------------------------*/
typedef POSSPEED *POSSPEED_handle;

/*-----------------------------------------------------------------------------
Default initializer for the POSSPEED Object.
-----------------------------------------------------------------------------*/
  #define POSSPEED_DEFAULTS {0x0, 0x0,0x0,0x0,0x0,8387,2,0,0x0,\
        100,0,6000,0,\
        0,0,0,\
        (void (*)(long))POSSPEED_Init,\
        (void (*)(long))POSSPEED_Calc }


/*-----------------------------------------------------------------------------
Prototypes for the functions in posspeed.c
-----------------------------------------------------------------------------*/
void POSSPEED_Init(void);
void POSSPEED_Calc(POSSPEED_handle);

#endif /*  __POSSPEED__ */

  • Hi Milad,

    The people most able to answer this question are unfortunately unavailable at the moment.

    I have not used the example, however I believe I see some things that would be worth trying:
    1)  Please note that in the most recent set of examples for the F2806x, the core is run at 90MHz.  These leads to two things, [1] cell C2 in the posspeed xls should be updated and [2] EQep1Regs.QUPRD should be updated to 90M/100 = 900000.
    2) Note that cell C3 should be updated to 2000 * 4 = 8000 (for your encoder)
    3) It looks to me that you've configured mech_scaler appropriately.
    4) With the spreadsheet now configured, cell C15 gives a new value of SpeedScalar.  This should now get put into the POSSPEED_DEFAULTS structure. 

    The new value of SpeedScalar which I received is about half of what the default is, which makes me feel like this may make things work in your system.


    Thank you,
    Brett