cancel
Showing results for 
Search instead for 
Did you mean: 

Hall Handling TIM2

patrickbuchbauer9
Associate II
Posted on February 19, 2009 at 15:35

Hall Handling TIM2

4 REPLIES 4
patrickbuchbauer9
Associate II
Posted on May 17, 2011 at 10:15

Hello,

I working on a new motor control with the STM3210B-MCKIT and the sw library 2.0. I want to run a PMSM machine with a very low speed.

Now I want to go down to a speed of 500rpm, but I still come down only to 1600rpm before it began to stop.

So I want to modify the sw, by changing the electrical angle calculations from 3 states to 6 states.

I write three new states in the TIMx_IRQHandler in the stm32f10x_hall.c.

Now I should have six informations per rotation instead of 3 informations.

So I have to change the TIM2 Init ,too.

So I want to changeit from falling edge to rising and falling edge.

I find these defines:

/* TIM Input Capture Polarity ----------------------------------------------*/

#define TIM_ICPolarity_Rising ((u16)0x0000)

#define TIM_ICPolarity_Falling ((u16)0x0002)

#define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) ||

((POLARITY) == TIM_ICPolarity_Falling))

First I thought that I can write it in the code like the last definition.

But when I run the motor, I can see on GPIO, which toggles that the program is only running in 3 states and not in all 6 states.

And in the refernce manual of the STM32F103x (RM0008)I can see only that you can choose rising or falling, but not both.

Perhaps someone had the same problems and can help me.

Because it is very important for me to come down to 500rpm.

Thanks in advance.

Patrick

patrickbuchbauer9
Associate II
Posted on May 17, 2011 at 10:15

Hello,

I solved the problem by changing the polarity at the end of every state.

Because like I see in the document it is not possible to react on both edges.

Now I`m at the calculation of the electrical angle and the speed.

I have to modify it, because now there are 6 informations per rotation instead of 3 informations. If someone have made this modification it would be very helpful for me.

Thanks in advance.

Patrick

stello
Associate II
Posted on May 17, 2011 at 10:15

Hello Patrick,

try by changing line 37 on stm32f10x_hall.c mudule from

#define ROTOR_SPEED_FACTOR ((u32)((CKTIM*10)) / 3)

into

#define ROTOR_SPEED_FACTOR ((u32)((CKTIM*10)) / 6)

but if it works, then I've to ask you to share with us this new nice module :D

Ciao,

Billino

patrickbuchbauer9
Associate II
Posted on May 17, 2011 at 10:15

Hello Billino,

Thanks for your answer. I`ve already tested it, when I looked at the measured electrical angle at PB1 it looks better than the picture you get from over roman.

I can see that it depend also to the pwm frequency.

The problem now is, the motor is running, but not very smooth and not under 800rpm (nominal speed 40`000rpm of the PMSM).

I can see that the measured speed is changing +/- 15% of the target speed.

The problem is that the duty cycle of the hall signals are not exact 50% and this is a problem when you reacting on both edges.

For the calculation of the rotor_frequency and then the speed, it is a problem when the captured value of the timer is varying in this way.

Reacting on falling or rising edge like it is now in the sw-library is no problem because the length of the whole period is always the same.

So I`m trying to solve the problem. If someone has an idea it would be very helpful and if I solve the problem I will let you know.

Thanks in advance.

Patrick