Unable to run the example drive code in stm32 bluepill

Hello,
I tried using the simpleFOC library to run a BLDC motor in stm32f103C6 blue pill in arduino ide by dumping Standalone driver 6PWM pulses program inorder to check whether can I get pwm pulse output from controller, the pin used are (PA8, PA9, PB6, PB7, PB8, PB9) but was unable to get the output. Kindly suggest on how do I get the output from the test code given. Kindly help.

Are you sure you don’t have fake chip bluepill?STM32 Clones: The Good, The Bad And The Ugly | Hackaday

Welcome.

Your pin assignment seems incorrect and your stm chip too low on memory. Please check other threads for the pin assignments and memory requirements.

Your MCU is not the “STM32 BluePill” that is reffered in the docs, and you have to read the MCU datasheet to map the timers and figure out the pins to use - I can’t look more into this from my phone, but I suspect this is the issue tou are facing.

Take a look at the following two images and you should see that the timer pins are different across the MCUs

https://www.mischianti.org/2022/05/15/stm32f103c6t6-high-resolution-pinout-and-specs/

I have a little more time. Please change the pins to the correct ones and it will work. The pins you use are not on the same motor control timer, these are just some random pins. Also please consider getting a C8 version with 64kb flash.

BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15);

Also, the pins for the C6 and C8 or higher are identical.

The C6 version MCU may not have enough flash to hold the compiled code, and the load may fail due to low flash.

Cheers,
Valentine

Hello
Thank you for your valuable insights. I verified the controller it seems legitimate. I tried using the pins suggested
BLDCDriver6PWM driver = BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15);
but I am not able to get PWM outputs from the pins instead I am getting waveforms in pins PA11 and PA12. I hereby attach the waveforms for your reference.

1 Like

Let me check.

This is indeed very odd. I doublechecked the pins, and confirm that the correct pinouts are

BLDCDriver6PWM(PA8, PB13, PA9, PB14, PA10, PB15)

Below is the pinout for a Blue Pill with the C6 memory

You can clearly see the T1 timer channels are as described above.

There is either something going on with the code you use or the Bluepill itself is having a problem. This is definitely not normal behavior.

Cheers
Valentine

I cross verified with other blue pill board (Stm32f103cbt6) the same result occurs there as well. I have also attached code for your reference.

Could you please try

driver.setPwm(3,3,3);

and try the signals on the six pins on the oscilloscope?

Cheers,
Valentine

Hello,
I tried using the above mentioned line driver.setPwm(3,3,3); still didn’t get pwm signal in any of the pins configured

       However I verified whether the PWM pins are working using normal pwm output code (without simple FOC library) where I found that pins PB13, PB14, PB15 are not giving pwm signal but pins PA8, PA9, PA10, PB6, PB7, PB8, PB9 does give pwm signals.

That is very odd and definitely not normal. Well, if it works on those pins, go ahead, use them but it’s not according to the ST documentation.

Could you please send us a picture close up of the MCU you used? I’m very curious to see which one you got on the blue pill board.

Cheers,
Valentine

Even with the pins capable of giving pwm signal dosn’t produce pwm output when testing with simpleFOC linbrary’s 6 PWM driver example code. I have also affix the image of blue pill board I use.

hey bro, any update using this mcu?

There is no problem using this MCU.

Cheers,
Valentine

1 Like

nicee, i’ve been thinking using this mcu for servo control for a 3d printer x and y axis, using as5048a as an encoder with step/dir listener. i need at least around 160rad/s. can i get away with as5600 encoder instead?

cheers,
Rey

5600 is a potentiometer, not really an encoder, max rad/s about 50rad/s if you are lucky. Also the protocol 5600 is using is very slow and primitive — analog or pwm or i2c. Stick to 5048a or 5047p with an SPI.

Cheers,
Valentine

alright then, thanks for the feed back!