STM32F401 and Servo

Post here first, or if you can't find a relevant section!
Post Reply
nawasaqi
Posts: 20
Joined: Wed Dec 22, 2021 7:06 pm

STM32F401 and Servo

Post 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
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F401 and Servo

Post 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
Last edited by ag123 on Tue Jun 14, 2022 4:08 am, edited 1 time in total.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: STM32F401 and Servo

Post 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.
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: STM32F401 and Servo

Post by dannyf »

I would put a resistor (10K?) on the data line and find a 5v tolerant pin for that. just in case.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: STM32F401 and Servo

Post 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.
Post Reply

Return to “General discussion”