I want to build a simple FOC on STM32 to drive a PMSM motor (servo with ABI encoder 2000ppr). because I will control using step/dir. and coincidentally simple foc supports, previously I had tried with another foc it was successful only there was an error (and the person who made it was no longer active) now I tried on simple foc.
For now I have all the hardware. just change the pin used. I will use 6pwm to control the mosfet (igbt chip) is it permissible to use 1 shunt low side resistor with a value of 0.22ohm??
for a 2000ppr encoder is it safe to use quadature on stm32f103c8t6???
for now i will use 40v only for motor control.
And to upload code from Arduino, any idea whether to use Stlink or via USB (by installing the Stm32duino bootloader)?
And does Stm32 support the Simplefoc utility with Anaconda Python?? Because I tried to install it, I got a problem like the one below. @runger
You need at lease 2 or 3 low side shunt resistors. The value used has to match the expected amps, the watt rating of the resistor and the gain of the current sense amplifier.
It will be a high interrupt load if you use the normal driver. If the F103 has an encoder mode in its timers, and you use the right pins, then you could use the hardware encoder driver from our drivers repository. This would work, even at higher RPMs.
You can use either one. If you have an ST-Link, you don’t have to bother with the bootloader and gain a few KB extra flash space
Owh oke sir, so this mean it need the apli sir?? No chance without ampli? Only shunt resistor and some resistor sir?? Like this, from the lowside, with resistor 0.22ohm to gnd. Betwenlowside to resitor(0.22ohm) i connect with 47kohm resistor and come to adc pin stm32.???
Amd what is the best resistor sir??
I have shunt 0M50(2W), R005(2W), (R0.22, 0.47,0.5ohm(5W)) wichone is the best??
I get this recomendation pin for stm32f103 from st enginering.
STM32F103CxTn PINOUT +
ENABLE ADC12_IN6/PA6 (tim1 break pin, max 3.3V!!!)
STEP SPI1_MOSI/PB5 (5v tollerant)
DIR SPI1_MISO/PB4 (5v tollerant)
ENCODER_A SDA/PB7 (5v tollerant)
ENCODER_B SCL/PB6 (5v tollerant)
ENCODER_Z BOOT1/PB2 (Optional, 5v tollerant)
B_EMF ADC12_IN1/PA1 (Optional, need C_EMF)
C_EMF ADC12_IN0/PA0 (Optional, need B_EMF)
DC_LINK ADC12_IN2/PA2 (Optional for stabilization)
B_SENSE ADC12_IN3/PA3 (Single current sense)
C_SENSE ADC12_IN4/PA4 (Optional for FOC, need B_SENSE)
TIM1_CH1N TIM1_CH1N/PA7 (Better choice than PB13 due to minimal delay)
TIM1_CH2N TIM1_CH2N/PB0 (Better choice than PB14 due to minimal delay)
TIM1_CH3N TIM1_CH3N/PB1 (Better choice than PB15 due to minimal delay)
STATUS_LED JTDO/PB3 (PC13 should not be used for LED)
ERROR_LED JTDI/PA15 (PC14 should not be used for LED)
USB_DM USB_DM/PA11 (Obvious)
USB_DP USB_DP/PA12 (Obvios)
SW_DIO SWDIO/PA13 (USE SWD WHERE POSSIBLE)
SW_CLK SWCLK/PA14 (USE SWD WHERE POSSIBLE)
Owhh okee i will used stlink sir, i will try today with encorder first. Thank you.
Nope, sorry! We support current sensing with a minimum of 2 shunts, and especially for low side sensing, 3 shunts are recommended. One for each phase.
And the current measurement is a differential measurement across the shunt resistor. So you need 2 ADC channels to measure one phase, and 6 ADC channels (if used in a differential configuration) to measure all the phases.
Perhaps you could tie the GND-sides together and get by with 4 ADC channels.
You would have to centre the ADC signals using appropriate voltage dividers, and then, just in theory, you may be ok for low side sensing directly with the MCU. In practice, especially if you’re using 40V and IGBTs I think your common mode voltage will be outside the MCU’s range, and the voltage spikes that might be seen on these wires could damage your ADC or the whole MCU.
So I would strongly recommend to use some robust current sense amplifiers, to ensure the output is always within the range of what the MCU likes, and to be able to use a single ADC channel per phase.
Hi sir, i see your library are suport for esp32 also.
I want to build step/dir for pmsm motor, do u recomend stm32 bluepill or esp32(ex NodeMCU) sirr.
Because i see with 240MHZ, and blue pill are 72MHZ sir. Or with stm32f407vet6( this is i have now, but i dont see this suport with your library)
For use 2000ppr encoder, and inline U, Vcurent sensing with acs712 sir.
But i see esp32 lower cpu speed than stm32 right?? It will make problem? Like a reading encoder or something???.
Yess, but stm32f407 are expensive if i get new one (if working i want make more than one). I see stm32f401ccu6 with 64ram, 256rom and 84Mhz.
Did u recomend esp32 or stm32f401 sir??
Because the price almost same in my country sir.
No, usually ESP32 is 240Mhz, and only the very fast expensive STM32s run at this kind of clock rate (or faster).
Anyways, MHz is not everything. The ESP32 also has 2 cores and a RISC V architecture, it’s a very fast chip.
STM32F401 is also fine. It’s also a very fast chip. Just make sure you get one with 128kB flash or more.
A consideration is that for STM32 you will need an ST-Link programmer to use it best. For ESP32, if you take the ESP32 then normally all you need is a USB cable.
Yes, ESP32 has ADCs, but the STM32’s ADC is much better.
But really, either one will work well with SimpleFOC.
If you have any other questions about these MCUs, I’d suggest you read their documentation, or consult some other resources online - there are posts and videos specifically dedicated to comparing the benefits of different MCU boards…