Page 1 of 1

STM32F401 and Servo

Posted: Mon Jun 13, 2022 12:38 pm
by nawasaqi
Hi everyone. I don't know much about electronics, so I have a question. I have a servo that is powered by 5V. At the same time, I power my stm32 via a 5V pin. If I connect the servo in this way to stm32, will I not burn anything or do I need to use a converter? Thank you in advance for the answers for the layman;)

EDIT:
Second question. Is it possible to supply STM32 directly with 5V as in the picture or is it better to give 3.3v via VBAT?

Image

Re: STM32F401 and Servo

Posted: Mon Jun 13, 2022 2:42 pm
by ag123
for stm32, the 5v input need to goto the LDO, normally it is the 5v pin on the board.

look in the datasheet
https://www.st.com/en/microcontrollers- ... 401cc.html
some pins are 5v tolerant, various are not e.g. the ADC pins.
to be on the safer side you may like to use a buffer such as 74HCT07
https://assets.nexperia.com/documents/d ... CT3G07.pdf
or 74HCT04 etc
https://assets.nexperia.com/documents/d ... _HCT04.pdf
or 74HCT245 etc
https://www.nexperia.com/products/analo ... CT245.html
this would also prevent missed triggering, as the voltage that STM32 can output is only 3.3v

the 74HCTxx chips are ideal for interfacing 5v circuits
edit:
if you can use an 'open collector' circuit, i.e. it is inverting, and you need to pullup with a resistor, uln2003
https://www.st.com/resource/en/datasheet/uln2001.pdf
can be used as well for a buffer
these worked like transistors, these are rather easy to get in the online 'flea' markets
https://www.aliexpress.com/wholesale?ca ... xt=uln2003

Re: STM32F401 and Servo

Posted: Mon Jun 13, 2022 4:27 pm
by GonzoG
I all depends on servo motor.
The ones I used had signal pin pulled to GND (and probably most of them are wired the same), so it's not supplying any power to MCU but they needed ~5V signal to work properly.
They work fine with Arduino Uno, but with STM32 I had to use transistors to supply 5V signal.

As to Vbat pin, it's for RTC battery, not for powering MCU.

Re: STM32F401 and Servo

Posted: Tue Jun 14, 2022 12:05 am
by dannyf
I would put a resistor (10K?) on the data line and find a 5v tolerant pin for that. just in case.

Re: STM32F401 and Servo

Posted: Wed Jun 29, 2022 6:53 pm
by GonzoG
dannyf wrote: Tue Jun 14, 2022 12:05 am I would put a resistor (10K?) on the data line and find a 5v tolerant pin for that. just in case.
It will create voltage divider as signal pin in servo motor is pulled to ground.
And if there a problem with 3.3V signal, you can figure out what will happen with much lower voltage.