cancel
Showing results for 
Search instead for 
Did you mean: 

FOC SDK 3.4 with STM32F303CB

joe2
Associate II
Posted on March 28, 2014 at 00:53

Hi,

I successfully used the 3.4 Library to drive a small brushless motor using an STM32F103 and 3 current shunt resistors. My new design uses the STM32F303CB and onboard PGA for current sensing. This new 303 version does not work, the motor spins during startup but as it switches to FOC it gives a ''Start-up Failure'' error. All of the other library settings (motor parameters, pwm freq etc) remain the same so I can only think it is a problem with the current sensing.

I am a bit confused by the onboard current sensing. I select 3 shunt resistors, but it only assigns 2 op amps per motor. Was I supposed to use an external op amp for the 3rd phase?

I have attached my STMCWB project and the current sense waveforms for motor 2. Do these current sense waveforms look as expected, am I missing something obvious? I have also attached the schematic showing which pins I hooked up and the current sensing resistors.

Any help would be greatly appreciated, thanks.

#foc-3.4-stm32f303
6 REPLIES 6
joe2
Associate II
Posted on March 29, 2014 at 04:58

Found the bug that was at fault. I have selected PB5 as the motor 2 phase 3 low side pwm, but the library sets the alternate function register incorrectly. The alternate function for TIM8 on PB5 is 3.

GPIOB_AFRL is set to 0x00244000, it should be 0x00344000.

The problem is with STMCWB, not the library. It generates the following incorrect line in ''Control stage parameters motor 2'':

#define PHASE_WL_GPIO_AF2                GPIO_AF_2

Workaround for now is to edit the template file to GPIO_AF_3

joe2
Associate II
Posted on March 29, 2014 at 20:03

Now that I have it working, I have another question. When I used the STM32F103, I was able to go to much higher pwm values which worked well for my small motor. I found that 32 - 36 kHz worked well.

With SMT32F303 I can only go up to a maximum of 27500 Hz, after which I get an error:

ERR   12:02:09  1       511  Maximum resulting modulation index clamped to minimum allowed (81%) for motor M1

ERR   12:02:09  2       511  Maximum resulting modulation index clamped to minimum allowed (81%) for motor M2

Are there any other parameters I can change to get to a higher PWM, or is this a limitation of using the onboard current sensing amplifiers?

joe2
Associate II
Posted on March 30, 2014 at 22:53

Another question: now that I have 2 motors running I cannot figure out how to get them to run simultaneously. I can start motor 1, but it stops as soon as I start motor 2. I can start motor 2 but it stops as soon as I start motor 1. No errors are received over the UART protocol, just a successful acknowledge of the start command.

The library clearly says simultaneous control of dual motors. What am I missing here? Please help.

Gigi
Senior
Posted on March 31, 2014 at 11:27

Ciao Joevn,

thank for you valuable feedback.

As you probably already understand just two embeded OPAMP are sufficient for the three shunt current sensing because the three inputs are multiplexed inside.

I reported the issue you submited to the WB designer for the next version. The workaround you popose is ok.

The maximum modulation index (MMI) is calculated by WB according PWM freq, Dead time, Tnoise/TRise and selected current sampling time. Is used to avoid the noise caused by the 6-PWM switching. There is a limitation in the minimum MMI supported by WB/Lib. that is 81% and this don't depend on the microcontroller used but by the algorithm. You can try to reduce the mentioned paramenters in order to use higher PWM frequencies.

The behaviour you mention for the dual drive is not the one expected. Dual drive means dual simultaneous. Probably you are facing with some issue related to an high FOC rate, in this case you can try to increase the execution rate to 2 or 3 PWM period. Or it is just an issue related to the serial communication, please verify that the ''All motor'' check box is chceckd in the monitor page of WB.

Ciao

Gigi

joe2
Associate II
Posted on March 31, 2014 at 20:10

Thank you, changing the execution rate to 2 pwm periods did the trick. Now both motors spin simultaneously.

Laurent Ca...
Lead II

The question has been moved from the section "Motor Control Hardware" to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards