Controlling a Brushless Motor with Arduino
HTML-код
- Опубликовано: 14 окт 2024
- This is an example that demonstrates how to control a brushless motor with a potentiometer and the Arduino Uno.
👉Subscribe for more robotics and engineering tips:
/ @theboredrobotllc
Share this video with a friend:
• Video
Affiliate Links:
Brushless In-Runner and ESC Combo: amzn.to/3omstPS
Flyfun Brushless ESC: amzn.to/3olVDOV
Emax Brushless Out-Runner: amzn.to/3afyRn4
Arduino Starter Kit - amzn.to/3oi0LEq
Disclaimer: This video contains affiliate links, meaning that if you make a purchase from one of the product links, I'll receive a small commission.
Hi, can you please add the detail and specs about material used in description of video. Like Motor (voltage/current) rating, battery (voltage/current) rating, Type of Arduino used etc. Thanks.
The motor/ESC combo are in the description of the video. I used an 11.1v Lipo battery.
Can we use a usb cable in some way to power the ESC or do we need to use a battery if yes link the battery that you used with the blue motor pls
USB cables won't work to power an ESC. You'll need a battery. Here's a link to the battery that I used in the video:
amzn.to/3YO5vUC
It's a NiMH battery, since I happened to have one around. A Lipo battery would also work better and has a better mass to power capacity ratio. Here's an example of one:
amzn.to/3XNWxpg
@@TheBoredRobotLLC ok thanks
Hello, great video, im wanting to use force resistance sensors to activate the motor, 1 for forwards 1 for reverse. Code wise do i need to have 2 servo/pot readings 1 off each sensor, 1 at 0-90 and the other at 90-180? Tia
And ofcourse the correct esc
If I understand your problem correctly, you want to have one sensor control the speed in the forward direction and the other in reverse. You'll only need one servo output to the ESC. If sensor 1 is reading a force, then send a "forward" servo value to the pin, and if sensor 2 is reading a force, then send a "reverse" servo value to the same pin.
@@TheBoredRobotLLC thanks for the help!
Hi,, excelent video ! a problem here, with low values of potentiometer, i have high speed of my motor controlled by ESC, cant understand that..can you help me ?
I would check to see how you're mapping the potentiometer values to the ESC output values in your code. Use some print statements to debug what those values are.
can i know what kind of battery you are using
I used a 6 cell NiMh battery, in the video, but you can also use a Lipo battery. Just check the voltage rating of your speed controller.
So... Could I use an analog 5v signal as an input instead of the pot? Program a cutoff for the 0.5v/4.5v range. Control the ESC, which gives me 12v+ output for... A stupid cheap and capable PWM fuel pump setup. Could also add MAP sensor, temp, and relays, to have a fallback of wide open off the fuel pump relay if the fuel pumps don't like playing below 50% DC
Using an analog signal instead of a pot is essentially the same thing, so it should work. For the ESC and motor/pump, I would have to know more about the specs to answer the question of whether it would work or not. But fundamentally, I don't see why it wouldn't work as well.
How do you power your motor? I want to use it for a stationary project so i dont want to use lipos i read online that powering a motor via a power supply is a bad idea, so i wonder how manufacturers are doing it.
I don't see a problem with powering a motor with a power supply, as long as you set the correct voltage and current. You just need to make sure the power supply is capable of delivering enough current for your application.
@@TheBoredRobotLLC My Problem is the Powerspike when the motor is slowing down. With a battery it seems to be no issue but i read that power supplys can shut off or even blowup/Break
hmmm , would it be possible to wire an encoder to use this kind of setup for a robotics project i am working on? o-drive seem like the only solution but they are WAY TO EXPENSIVE
Using a rotary encoder does seem like it would be possible. I believe there are several inexpensive options. You would also have to figure out a way to couple the output shaft of the motor to the encoder.
Great video, how do you initialize yours to 90? Do you say int speed=90 instead of int speed =0?
It depends on the electronic speed controller. If you use an ESC that's generally used for drones, then you'll have to initialize it to 0, since it doesn't go in reverse. If you're using an ESC that is usually used for RC cars, you'll initialize to 90. It really can depend from one ESC to another. I recommend testing out with a potentiometer and listening to hear when the ESC sends out the initialization beeps.
@@TheBoredRobotLLC Interesting...when i use a potetiomter everything works fine, but if i add speed values by hand into the software it won't reverse...maybe i broke my arduino...lol
@@Chupria Keep in mind that the ESC starts by waiting for a "zero speed" condition when it first gets power. Then you can move it to a specific speed. If you're simply changing a number and re-uploading the Arduino every time, it may not work. You sometimes need to initialize to a zero speed with every upload to the Arduino, even if you didn't cut power to the ESC. Start by sending the zero speed signal in the setup(), delay it for about a second, then in the loop(), write your desired motor speed.
@@TheBoredRobotLLC Yup, apperannly the ESC needs a constant stream of data, this is why the potentiometer worked in changeing the direction. If you want flip the direction only using Arduino IDE, you need to send values constanly in a loop to the ESC and then it will reverse it just like with the potentiometer.
In the serial monitor it spits out numbers acording to the Potentiometer but my esc doesent do anything
I am completly new to this topic. Can you help me ?
The first steps to debug this would to write a simple sketch to run the motor only with hard coded values. Then you can see if it's something with how your setting up your motor movement. After that, then you can incorporate the analog read code to control the speed.
Would this setup work with a group of 18650 batteries?
I've never tried it with those types of batteries, but I wouldn't expect any problems. Just make sure the battery voltage doesn't exceed the maximum voltage and the ESC.
hello sir,
my motor does not respond to potentiometer. then i adjust the potentiometer to 90 as you suggest, but i dont hear the beep and the motor still does not respond to the potentiometer.
i am using the built-in esc from the rc off road car.
how should i do to solve this problem ?
It may not be 90 that initializes your particular ESC. If it was me, I would first double check that I am receiving or sending the appropriate signals to/from the Arduino. Then I would slowly adjust the pot until I see or hear something happen. Or, if you have have an RC transmitter and receiver, you can try getting the motor running without the Arduino first. Then you can measure the signal coming from the RC receiver using the pulsein command. That should give you an idea of the pulse width that the ESC is expecting.
Is it possible to use brushed motor esc? For brushless motor?
No, you are going to want to use a brushed ESC with a brushed motor, and a brushless ESC with a brushless motor.
I really need help. How can i control the brushless motor with Arduino code and app inventor via wifi?
I've never used app inventor before, but I'd happy to discuss the project with you in further detail. Feel free to contact me here:
www.theboredrobot.com/contact
This is so good thank you
Thank you!
hello sir. Can we reverse the motor by code ?
If you have an electronic speed controller that can go in reverse (usually the ones for RC cars), then you should be able make the motor spin in reverse from the code.
@@TheBoredRobotLLC great video! how should we change the code to reverse the motor? thanks
@@jirivchi In this video, I used the servo library. Assuming that you have a reversible ESC, the "90 degree" output should be a zero speed. Sending a "0 degree" signal will spin the motor full speed in one direction and "180 degrees" will move the motor full speed in the other direction. Anything in between will be a speed less than full speed in the respective direction.
Hi can we add a reverse button ?
For the motor to go in reverse, you need to make sure your electronic speed controller is capable of changing the direction. To use a button to control the direction, you can wire up the Arduino to read if a button is pushed or not from one of the digital pins. Then from this you can decide if you want to send servo values between 0 and 90 (reverse) or 90 and 180 (forward).
Can 2 esc plug into arduino?
Yes, you can connect two ESC's to the Arduino. Just make sure they are getting power from an external source.
@@TheBoredRobotLLC can you make a video 2 esc connecting to arduino?
@@TheBoredRobotLLC by the way..where should I plug the 2nd esc?
@@wannistelrooy You can plug the signal wire of the ESC into another digital output on your Arduino. The power and ground can be from the same source as your other ESC.
😃 you are grait at teaching
Thank you!
can I use the do the same thing with bigger brushless motors?
@@scooterboom4157 Yes, this can be done with bigger motors, assuming that you have the proper ESC to power them.
@@TheBoredRobotLLC so you mean that I can use the same motor driver?
ESC is short for electronic speed controller, or what you're referring to as the motor driver. You need to make sure the ESC/motor driver can handle the bigger motor.
More visible on expalining code pls, it's hard to see from my phone cell '(
I apologize for that. In my later videos, I made the font larger.
no body's telling the value of the pot. 10k, 50k , 100k on ytube.
For this example, I used a 10k pot.