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.

using qep_theta_drv for a tms320f2812 based dsp board



I am working on motor control using LQG/LTR method. I am using a 3rd party dsp board. this board to be specific " http://www.gaotek.com/index.php?main_page=product_info&cPath=118_17&products_id=86" . 

I want to read encoder using this board. I have figured out how to use the qep_theta_drv subroutine in DMC library from TI. my question is regarding defining the qep defaults

 

#ifndef __F281X_QEP_H__

#define __F281X_QEP_H__

 

#include "f281xbmsk.h"

 

/*------------------------------------------------------------------------------

Initialization states for T2CON and CAPCON 

------------------------------------------------------------------------------*/

#define QEP_CAP_INIT_STATE    0x9004

#define QEP_TIMER_INIT_STATE (FREE_RUN_FLAG +          \

                          TIMER_DIR_UPDN +         \

                          TIMER_CLK_PRESCALE_X_1 + \

                          TIMER_ENABLE_BY_OWN +    \

                          TIMER_ENABLE +           \

                          TIMER_CLOCK_SRC_QEP +    \

                          TIMER_COMPARE_LD_ON_ZERO)

 

/*-----------------------------------------------------------------------------

Define the structure of the QEP (Quadrature Encoder) Driver Object 

-----------------------------------------------------------------------------*/

typedef struct {int16 ElecTheta;        // Output: Motor Electrical angle (Q15)

                int16 MechTheta;        // Output: Motor Mechanical Angle (Q15) 

                Uint16 DirectionQep;    // Output: Motor rotation direction (Q0)

                Uint16 QepCountIndex;   // Variable: Encoder counter index (Q0) 

                Uint16 RawTheta;        // Variable: Raw angle from Timer 2 (Q0)

                Uint32 MechScaler;      // Parameter: 0.9999/total count (Q30) 

                Uint16 LineEncoder;     // Parameter: Number of line encoder (Q0) 

                Uint16 PolePairs;       // Parameter: Number of pole pairs (Q0) 

                 int16 CalibratedAngle; // Parameter: Raw angular offset between encoder index and phase a (Q0)

                Uint16 IndexSyncFlag;   // Output: Index sync status (Q0) 

                void (*init)();         // Pointer to the init function 

                void (*calc)();         // Pointer to the calc function 

                void (*isr)();          // Pointer to the isr function  

                }  QEP;

 

/*-----------------------------------------------------------------------------

Define a QEP_handle

-----------------------------------------------------------------------------*/

typedef QEP *QEP_handle;

 

/*-----------------------------------------------------------------------------

Default initializer for the QEP Object.

-----------------------------------------------------------------------------*/

// Applied-motion PMSM motor: 24-v, 8-pole, 2000 line encoder, CalibratedAngle = -1250

// MechScaler = 1/8000 = 0x00020C4A (Q30) 

 

// PacSci 1-hp PMSM motor: 320-v, 4-pole, 1000 line encoder, CalibratedAngle = -2365

// MechScaler = 1/4000 = 0x00041893 (Q30)

 

#define QEP_DEFAULTS { 0x0, 0x0,0x0,0x0,0x0,_IQ30(1/240),0x0,1,-1250,0x0,  \

                (void (*)(Uint32))F281X_EV1_QEP_Init,            \

                (void (*)(Uint32))F281X_EV1_QEP_Calc,    \

                (void (*)(Uint32))F281X_EV1_QEP_Isr }

 

/*-----------------------------------------------------------------------------

Prototypes for the functions in F281XQEP.C                                 

-----------------------------------------------------------------------------*/

void F281X_EV1_QEP_Init(QEP_handle);                                              

void F281X_EV1_QEP_Calc(QEP_handle);

void F281X_EV1_QEP_Isr(QEP_handle);

 

#endif // __F281X_QEP_H__ 

 

 

 

 

 

i have a 240 pulses per revolution encoder with A,B and Z outputs. How should i find the calibrated angle value for my particular application? I thought of connecting the encoder output A and Z to the oscilloscope and rotate the rotor with hand (after providing 5 v power supply to the encoder) and measure the number of pulses of A before the pulse of Z is visible on the oscilloscope. Since i have one pole pair motor i can find out the corresponding angle which i need to subtract or add by just converting the number of pulses into angular position. Is it the right way to do it? If there is any simpler method i am open for suggestions

Girish