cancel
Showing results for 
Search instead for 
Did you mean: 

STR750 Timers : Encoder mode

xaviooo
Associate II
Posted on June 25, 2007 at 13:38

STR750 Timers : Encoder mode

1 REPLY 1
xaviooo
Associate II
Posted on June 25, 2007 at 13:38

Hello,

I'm using a STR750 microcontroler + an optical encoder whose resolution is 1024 ppr.

I'm trying to count 1024 pulses per rotation but I only get 2048 with TIM_Mode_Encoder1 or TIM_Mode_Encoder2 (ENC = 01 or 10) and 4096 pulses with TIM_Mode_Encoder3 (ENC = 11).

Is it possible to have 1024 pulses per revolution with my encoder ?

******************************************************************

// TIM0 Configuration

TIM_InitStructure.TIM_Mode = TIM_Mode_Encoder1;// resolution x1

//TIM_InitStructure.TIM_Mode = TIM_Mode_Encoder1; // resolution x4

TIM_InitStructure.TIM_Prescaler = 0x0;

TIM_InitStructure.TIM_ClockSource = TIM_ClockSource_Internal; // TIM_ClockSource = CK_TIM

TIM_InitStructure.TIM_Period = ENCODER_PPR - 1; // ENCODER_PPR = 1024

TIM_InitStructure.TIM_IC1Polarity = TIM_IC1Polarity_Rising;

TIM_InitStructure.TIM_IC2Polarity = TIM_IC2Polarity_Rising;

TIM_InitStructure.TIM_IC1Selection = TIM_IC1Selection_TI1; // A input

TIM_InitStructure.TIM_IC2Selection = TIM_IC2Selection_TI2; // B input

TIM_Init(TIM0, &TIM_InitStructure);

TIM_ClearFlag(ENCODER_TIMER, TIM_FLAG_IC1 + TIM_FLAG_OC1 + TIM_FLAG_Update + TIM_FLAG_IC2 + TIM_FLAG_OC2);

TIM_ITConfig(TIM0, TIM_IT_Update, ENABLE);

TIM_ResetCounter(TIM0);

*************************************************************

Thank you,

-Xavier

________________

Attachments :

mode_codeur.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtR8&d=%2Fa%2F0X0000000aPz%2FqooZyPI1KOwpDRpfmUoLRq6k_czmOd83UzOb8PkuQNI&asPdf=false