cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 FOC SDK - how to swap high/low side of power stage :-)

Sergey Vasyliev
Associate II
Posted on October 14, 2017 at 14:40

https://community.st.com/tags♯/?tags=foc

‌ 

https://community.st.com/tags♯/?tags=stm32f303

 

https://community.st.com/tags♯/?tags=foc%20sdk%204.3.0

 

Problem was in my PCB - it was error during PCB routing. How to correct similar mistake you can read in last post

Can be any difference beetween

STM32F303VCT6  and STM32F303RBT6 except form factor?

I'm working with STM32FOC SDK 4.3 for my project 

https://community.st.com/docs/DOC-1423-my-project

  

I have working custom PCB with STM32F303VCT6 rev Y  (LQFP-100) and it works as expected. 

Also I've created a new PCB with STM32F303RBT6 rev Y (LQFP64), which uses same pins configuration as 

STM32F303VCT6. 

I'm using three shunt configuration with embedded PGA's for current control and overcurrent protection.

1) Both PCBs have same configuration for power stage - high side active low, low side active high

I just use compiled firmware from

STM32F303VCT6 

 in STM32F303RBT6 and have really strange behaviour od deadtime logic:

- in STM32F303VCT6 

 deadtime works as expected. Yellow high side pulse switches from active (zero) to inactive(''one'') before blue low side pulse switches from inactive (zero) to active active (one)

0690X00000602VKQAY.bmp

- in STM32F303RBT6 same firmware gives me ''inverse'' deadtime.

Yellow high side pulse switches from active (zero) to inactive(''one'') after blue low side pulse switched from inactive (zero) to active active (one). It's really bad situation, which will damage power stage under normal conditions

0690X00000602VFQAY.bmp

2) I tried to test firmware with both high and low sides ''active high'' configuration (I turned off power stage power supply). With this configuration both controllers work correct - there is deadtime beetween pulses

- Both ''active high'' sygnals for STM32F303VCT6

 0690X00000602SCQAY.bmp

- Both 

Both ''active high'' sygnals for 

STM32F303RBT6

0690X00000602VGQAY.bmp

3) I tried this firmware with 2 different STM32F303RBT6 rev Y: one I've bought from Arrow.com few days ago, and second from my local distributor in Ukraine. The behaviour is same for both mcu's.

Here are my mcu's - first from local distributor, second from arrow.com

0690X000006046sQAA.jpg

Maybe the problem is in firmware, but why same firmware has different behaviour in same family of STM32F303? Is the difference only in form-factor, or not?

#foc #stm32f303 #foc-sdk-4.3.0
1 ACCEPTED SOLUTION

Accepted Solutions
Sergey Vasyliev
Associate II
Posted on October 16, 2017 at 20:02

Ok, it was my stupid mistake - i've just swapped channels during PCB routing. But what can you do if you did the same mistake?

Below some tips how you can resolve this problem:

It's not problem to swap high and low sides in firmware. You should do 2 steps:

1) For example, for my three-shunt topology, I changed ''R3_4_F30X_PWMnCurrFdbkClass.c'' (if you have other topology, you should find correct class for your case - see lib's docs).

in ''R3_4_F30X_TIMxInit'' function change 

TIM_OCMode_PWM1 to TIM_OCMode_PWM2:

/* Channel 4 */

TIMx_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;     //(string 1023)

to 

/* Channel 4 */

TIMx_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; 

2) Modify you Motor control workbench project in part of power stage - you should inverse polarity of high and low side of power stage. For example, for my project:

Before:

0690X00000608cvQAA.png

After modification:

0690X00000608dFQAQ.png

That's all - now you can use your PCB with wrong routing without changing electrical connections.

View solution in original post

2 REPLIES 2
Sergey Vasyliev
Associate II
Posted on October 16, 2017 at 10:34

I've found, that problem not in deadtime at all. 

According to ST Motor Workbench I should connect PWM signals with this map:

0690X00000608ZYQAY.png

I don't know why, but in STM32F303RBT6 mcu firmware swaps high side with low side of power stage. My PCB works only if I reconnect top side signals to low side of power stage driver, and visaversa - low side signals to top side of power stage driver

0690X00000603yRQAQ.jpg

My correct working connection map is (I tried it for motor 2 - TIM8):

CH1 - C10

CH2 - C11

CH3 - C12

CH1N - C6

CH2N - C7

CH3N - C8

It seems that my mcus have swapped OCx and OCxN of TIMER1/TIMER8. 

Is it problem in FOC SDK, or it's error inside silicon of STM32F303RBT6 series?

Does anybody know how to fix this in firmware?

Sergey Vasyliev
Associate II
Posted on October 16, 2017 at 20:02

Ok, it was my stupid mistake - i've just swapped channels during PCB routing. But what can you do if you did the same mistake?

Below some tips how you can resolve this problem:

It's not problem to swap high and low sides in firmware. You should do 2 steps:

1) For example, for my three-shunt topology, I changed ''R3_4_F30X_PWMnCurrFdbkClass.c'' (if you have other topology, you should find correct class for your case - see lib's docs).

in ''R3_4_F30X_TIMxInit'' function change 

TIM_OCMode_PWM1 to TIM_OCMode_PWM2:

/* Channel 4 */

TIMx_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;     //(string 1023)

to 

/* Channel 4 */

TIMx_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; 

2) Modify you Motor control workbench project in part of power stage - you should inverse polarity of high and low side of power stage. For example, for my project:

Before:

0690X00000608cvQAA.png

After modification:

0690X00000608dFQAQ.png

That's all - now you can use your PCB with wrong routing without changing electrical connections.