Hi everyone!
In this short article I will show how I managed to integrate brushless motor with ESC(Electronic Speed Controller) from drone to Raspberry PI.
Some time ago I was given a broken Cheerson Drone with one ESC burned (fabulous swimming pool snorkeling). My first idea was to connect brushless motor to Raspberry PI and potentially build a plane/drone.
My drone had XGW_ESC VER2.4B controller with motor soldered in:
Brushless motor has three wires: red for power, black for ground and yellow for signal transmission.
As a power supply for brushless motor I used 11.1V 2200mAh 25C LiPo battery with pins and terminal output:
Looking at ESC, it has three main wires we should care about: red for external supply power, black for ground and white marked with PPM (in my case).
I soldered pin wires to power supply input and connections in ESC
This is a brief diagram of connection:
We are going to use GPIO4 for signal and ground pin.
Once everything is ready, we can start coding!
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
t1 = GPIO.PWM(7, 50)
t1.start(0)
t1.ChangeDutyCycle(7.5)
time.sleep(3)
t1.stop()
GPIO.cleanup()
quit()
This code uses PMW(Pulse-width modulation) to initialise ESC pin with 50Hz frequency, and change duty cycle to 7.5%, sleep for 3 seconds and stop. It will be enough to spin your motor real quick fast and then completely stop.
Congratulations! We have done it! 🎉
Now, technically, you can try to build your own drone or plane! ✈️
Top comments (4)
Finally something non web on dev!! Great article Nick.
Happy you liked it, Farah! 😁
i used the about code the output is attribute error changeDutycycle as no attribute rpio gpio says stuff like this
Good topic idea, however the red, yellow and black cables of brushless motors are NOT Vcc, Signal and Ground. It is three phase power. Youre confusing brushless motors with servomotors.