cancel
Showing results for 
Search instead for 
Did you mean: 

complementary pwm for 6 step commutation

Bud
Associate III

I am driving bldc motor using my bldc driver, I use stm32f103xx as MCU. Using 6 step commutation the control was ok, and i driven in e-scooter using my driver. But there is a small problem at starting, once the motor gets its motion it goes good. So i thought of applying uni polar complementary pwm technique for it.

  • Coded in stm32f103 using register language.
  • Used timer 1 for complementary 6 pwm.
  • And i complemented 3 channels (ch1,ch2&ch3) shown below.

First generated pwm signal for 10khz and then i coded below..

TIM1->CCER|=TIM_CCER_CC1NE;

(using above line ch1's(A8) signal is complement in chn1 (B13))

TIM1->CCER|=TIM_CCER_CC1NP;

(using above line ch1's polarity can be changed that is low for high or vise versa)

My problem...

I need to enable and disable complementary pwm simultaneously.

But by using this TIM1->CCER|=TIM_CCER_CC1NE;

TIM1->CCER&=~TIM_CCER_CC1NE;

it requires a delay between them to work properly.

So how to activate and deactivate complementary pwm simultaneously (in register language).

4 REPLIES 4

> I need to enable and disable complementary pwm simultaneously.

> But by using this TIM1->CCER|=TIM_CCER_CC1NE;

> TIM1->CCER&=~TIM_CCER_CC1NE;

Doesn't this enable and then disable CH1N? What's the point?

If you want to enable CH1 and disable CH1N, can't you simply write

TIM1->CCER = (TIM1->CCER & ~TIM_CCER_CC1NE) | TIM_CCER_CC1E

?

JW

Bud
Associate III
TIM1->CCER|=TIM_CCER_CC1NE;           // Enabling compl pwm
TIM1->CCER&=~TIM_CCER_CC1NE;        // Disabling compl pwm

Actually the above code works. In my case i want to enable & disable, very fastly & frequently. But it requires time gap (may be few millsec) between enabling and disabling frequently.

> Actually the above code works. In my case i want to enable & disable, very fastly & frequently. But it requires time gap (may be few millsec) between enabling and disabling frequently.

Why the gap? What happens if you don't do it, and how it is different from your expectations? And what's wrong with inserting the time gap?

JW

Bud
Associate III

No no.. Actually i want to enable and disable fastly without any time gap, but when i enable and disable frequency it doesn't works. So by giving some mill-sec delay, it works properly.

Any how ok thank-you for your response friend.