Controling servomotor from 3.3V GPIO: optocoupler, level translator? - Page 1
Forum section: electronics / beginners

author: Watth
author_rank: Frequent Contributor
timestamp: October 31, 2023, 09:07:30 pm
content: Hey EEVfolks,As the title hints, I'm looking at how to control a servo motor (a simple 9g thing) from the 3.3V GPIO of a ESP32.So I see options include going through a level translator, or an optocoupler. What is to be prefered? Are there other options?Thanks for reading.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 31, 2023, 09:24:46 pm
content: Are those using PWM? A simple transistor and a pullup will do it, frequency is usually pretty low, around 100Hz.Just like this. R1 can be way higher, like 22K. If you need isolation, then yeah, you'll have to use an optocoupler.

author: langwadt
author_rank: Super Contributor
timestamp: October 31, 2023, 10:00:03 pm
content: Quote from: DavidAlfa on October 31, 2023, 09:24:46 pmyou might want to make it common-base instead of common-emitter to avoid the inversion

author: Watth
author_rank: Frequent Contributor
timestamp: November 02, 2023, 10:21:33 am
content: Quote from: langwadt on October 31, 2023, 10:00:03 pmWhat would that look like?

author: Ian.M
author_rank: Super Contributor
timestamp: November 02, 2023, 10:33:24 am
content: Disconnect emitter from ground and connect to GPIO. Feed base resistor from +3.3VHowever check your servo specs - it may already supportTTL input levels*so be fine with a 3.3V logic high level.* 'Classic' bipolar TTL outputs couldn't drive all the way up to the 5V rail.

author: Zero999
author_rank: Super Contributor
timestamp: November 02, 2023, 12:26:26 pm
content: Level shift bi-direc BJT 3.3V 5V.asc

author: Watth
author_rank: Frequent Contributor
timestamp: November 05, 2023, 08:57:14 pm
content: Quote from: Ian.M on November 02, 2023, 10:33:24 amWell that was a good idea, because it works. Although, I'm not sure on the models off servos I'll use. As I'm trying to make this project inexpensive, I worry I might end up with servos unable to work with 3.3V on the signal.

author: Ian.M
author_rank: Super Contributor
timestamp: November 05, 2023, 10:44:18 pm
content: Note that 'works' isn't sufficient - you really need written confirmation of the logic 1 level from the servo manufacturer - otherwise it could stop working unexpectedly for any one of a number of reasons.Quote from: Watth on November 05, 2023, 08:57:14 pmThat's why you put in a footprint for a real level shifter e.g. 74LVC1T45, but solder a jumper across its A and B pads instead of fitting one. If you ever need a full 5V signal, remove the jumper and fit one.OTOH if planning to sell assembled boards, better do it right in the first place and also consider how to protect it if the idiot user connects the servo pin to the main battery voltage!

author: Watth
author_rank: Frequent Contributor
timestamp: November 13, 2023, 05:58:00 pm
content: Quote from: Ian.M on November 05, 2023, 10:44:18 pmThat's a good idea, because as much as this isn't meant for sale, it's better to have the option of adding a level shifter if the servomotors that are later picked don't work with 3.3 signals.