Controlling a bi-directional brushless motor/ESC using PWM with an Arduino

  Рет қаралды 12,837

Mikey's Lab

Mikey's Lab

Күн бұрын

Пікірлер: 38
@AntonKoba
@AntonKoba 4 жыл бұрын
Thanks for the video! This is exactly what I was looking for for my hovercraft build :)
@yanxiaosun4363
@yanxiaosun4363 4 жыл бұрын
You're amazing, dude!
@MrAwyork
@MrAwyork 4 ай бұрын
You can get rid of that noise by turning on your 20 MHz filter with your o-scope. There should be a setting in one of those menus on the top.
@daijoubu4529
@daijoubu4529 11 ай бұрын
Thanks for the tutorial, very useful, looking to convert forward backward PWM inputs that usually drive a brushed motor controller IC from a stock RC receiver to drive an external ESC, seems like nobody has done this?! Why not let Blheli handle dead zone by its built-in calibration routine? Same for arming by holding throttle down, no?
@CristianSantellan
@CristianSantellan 2 жыл бұрын
Hi, thanks for this video! I am with a project where I precisely need to rotate the BLDC motor in both directions... I have a Emax Blheli-s Bullet 15A, do you know if I could configure it to be bidirectional? Thanks again!
@MikeysLab
@MikeysLab 2 жыл бұрын
All BL Heli escs should be reversible at this point. However if you want precise control over a bldc motor, you probably want to go with a sensored motor and a controller like a vesc. Sensorless bldc has a hard time with slow speed and precision
@CristianSantellan
@CristianSantellan 2 жыл бұрын
@@MikeysLab thanks!
@robotboy3525
@robotboy3525 Жыл бұрын
Hi Mike, I have a question: It is possible to make any ESC bidirectional ?? either software ? Or is it mechanical ? And if mechanical, assuming i have a normal ESC, normally I'd switch the brushless motors pins to achieve a spin to the oppose direction. Is there anything i can to achieve a bidirectional without having to switch pins ??
@MikeysLab
@MikeysLab Жыл бұрын
No, not every esc can handle bidirectional operation. This is a limitation in software, it needs to be able to trigger the poles and sense the induction in both directions. Theoretically you could use a dual pole dual throw relay to change the motor wiring on the fly. If you reverse two of the three wires the motor spins in the other direction. But to be honest this seems needlessly complicated. The two most common firmwares I have found are SimonK and blheli. Both of these have versions that can be reversed. Some cheap option, probably not.
@chadidas5288
@chadidas5288 4 жыл бұрын
Hey Mikey, I thanks for making this video. I have a few questions, as I am trying to implement a raspberry pi for drone motor control (not the best choice of course, but I want to see what i can do with it). By " #define ESC_MIN_THROTTLE 1070 " do you mean a duty cycle width of 1070 microseconds? If so, what frequency is this PWM running at? I have been able to get decent control of my motors using the Pi's PWM (3.3V amplitude @ 580 Hz). I get a starting speed around 44% duty cycle and a final speed around 97% duty cycle. I am also using an op amp to amplify the 3.3V to 5V. Also, how would you recommend about finding the PWM signal to "initialize" the ESC? Learning that there is an initialization makes my tests make more sense now, as sometimes we didnt get any motor response (we must have not initialized properly). Thank you so much for the video!
@DSdvdDS
@DSdvdDS 4 жыл бұрын
Hey, I was watching this video because I am working on a project similar to yours controlling the motor with a raspberry pi. How were you able to edit the ESC's BLHeli settings with the pi?
@MikeysLab
@MikeysLab 4 жыл бұрын
The PWM frequency is just the default for the Arduino, yes with PWM The signal is between 1000 and 2000. I set the minimum micro second to 1070 as that gives a bit of a dead region at the start of the stick, I do the same for the top end. Using an opamp for the 5v conversion is interesting, I would have just used a transistor :) The pattern is usually min-max-min this allows the ESC to learn the signal range :)
@DSdvdDS
@DSdvdDS 3 жыл бұрын
Follow up: I was able to get my ESC driving a motor in bidirectional mode with my Raspberry Pi Zero. I would not recommend doing this as whenever the motor nears 0 throttle, the motor starts to stutter and causes backcurrent to flow into the pi and causes it to reset.
@chadidas5288
@chadidas5288 3 жыл бұрын
@@DSdvdDS I am using a pi 4 and i have no back plow into the rpi, maybe you have a ground loop thats doing that? I was able to get very fine control using a raspberry pi. are you using an amplifier circuit with the pi? if so, what kind?
@MikeysLab
@MikeysLab 3 жыл бұрын
It is also worth noting you should create a dead range in the middle where +/- 10 sends 0. This gives a stop range so if the value fluctuates around 0, the motor does not stutter
@Helder98725
@Helder98725 3 жыл бұрын
Thank you so much for te video! I’m using a NRF24LO1 module to control the throttle do you know how can I implement it in your code? (Just the receiver part)
@MikeysLab
@MikeysLab 3 жыл бұрын
That depends what format you are receiving the data in. It would need to be translated into a value for the pwm signal. So for example if you are getting direction and speed as separate values, you would need to convert that to the pwm value the esc is expecting.
@Helder98725
@Helder98725 3 жыл бұрын
@@MikeysLab Thank you for your answer, I am using a joystick so I want to make it go in a direction from 0 to 450 and in the other using values from 600 to 1023 (these values are maped from 0 to 180) but I don't know how to tell the esc to go in one specific direction by using only pwm signals (generated by the servo.h library). (I have the same esc as yours)
@MikeysLab
@MikeysLab 3 жыл бұрын
Ah, you have to configure the esc for bidirectional mode, they are often not set to that by default. Then the esc will change motor direction around a value of 1000 depending on the settings in the esc.
@MikeysLab
@MikeysLab 3 жыл бұрын
Check out this video: kzbin.info/www/bejne/bHaqfad7mMmieKs
@mickthebass6086
@mickthebass6086 4 жыл бұрын
Hi Mikey, I am working on a project using the Flysky ibus signal to control 3 dc motors and 1 servo by an Arduino nano and TB6612FNG motor drivers. I can understand by your example how the Arduino can read the ibus signal, but how are the channels identified ? example: Ch1 = servo 1 Ch2 = motor driver pwm in, Ain1 and Ain2 etc. I noticed you had included servo library for the pwm signal, but then got a bit lost in the brushless motor esc setup. I could sure use some advise on this subject. Thanks in advance.
@MikeysLab
@MikeysLab 4 жыл бұрын
Of course, he says as he loads the code to remember himself. I am using newer code than what was in this video, since I found some major optimizations, you can find the new code here: github.com/MikeysLab/BrushlessESCviaPWM/tree/master/EscPWMTesting Okay, so the serial data out of the ibus receiver comes in as a byte stream. We listen to the stream until we detect the header of a packet (since we can jump in at any point and the data wont make sense if we are not at the start of the fame. So we are looking for 0x20 followed by 0x40 which is the packet header. At that point, in the new code, we fill a buffer the size of the the full iBus frame, once we have that buffer full we do a mem copy to an array rcValue[IBUS_MAX_CHANNELS]; from there we need to scale the values contained in the array, why? because rc values sent from any type of controllers will have values between 1000 - 2000 micro seconds. But there are dead zones at the beginning and top end of that range, so we scale the value we received to make it a value in a 1000 - 2000 ms range. At this point, we are ready to output the PWM value we just scaled. We do this WriteSpeed() in here we impose both a middle dead zone and an anti-flutter calculation. So essentially, as we receive the values out of the serial stream, we write them to the rcValues[], So channel 1's value is in rcValues[0], Channel 2 is in rcValues[1] ... and so on. I think this answers your question, if not let me know :) also check out the video on controlling a brushless ESC with PWM as I go a little more into this there.
@MikeysLab
@MikeysLab 4 жыл бұрын
The consuming iBus video, sorry got my wires crossed.
@mickthebass6086
@mickthebass6086 4 жыл бұрын
@@MikeysLab ?? Is this a reply to someone else question ?
@mickthebass6086
@mickthebass6086 4 жыл бұрын
@@MikeysLab Hi again Mikey, I have just opened the full text content of the reply, and can see you have given me more detail than the github link. I can understand the working principle, but not know how to set out the code in the Arduino IDE. I tried to use your code from your rover project, and change some details, but could not get past the compiler. A friend managed to arrange the channels into an array, so I type in the output pins in that channel column, change the channel in use number, and is good to go. I use it on a Mega to control 4x tb6612fng motor drivers and operate 8x dc motors on a rc excavator. The project I am working on is an articulated steer 4 wheel drive dumper. The steering motor is servo controlled, and needs the library included, but I cant seem to break into the code without dismantling the whole code to change the pwm output. I wonder if you would be able to find a solution to my trouble. Thanks for your reply.
@MikeysLab
@MikeysLab 4 жыл бұрын
I would love to help, but I am not really sure of your problem. Can you reach out via the Mikeys Lab page on Facebook and share the code you are working with?
@leonardoperalta2932
@leonardoperalta2932 3 жыл бұрын
Thank so much, It is amazing !!, muchas gracias!!
@jonhattan.beatbox
@jonhattan.beatbox 4 жыл бұрын
To switch it to oneshot125, would it work if i just change the min pulse length to 125 and max pulse length to 250, then map the values to 125,250?
@MikeysLab
@MikeysLab 4 жыл бұрын
oneshot is a little more complicated than that. True, that is the first step, but oneshot is only supposed to send updates to all motors when the value has changed. At most frequently at the speed on the control loop in the controller.
@jonhattan.beatbox
@jonhattan.beatbox 4 жыл бұрын
Mikey's Lab how do i use oneshot then? Is there an existing library?
@MikeysLab
@MikeysLab 4 жыл бұрын
I am not familiar with a library, but take a look at the multi Wii source. They implemented it for there flight controllers.
@jonhattan.beatbox
@jonhattan.beatbox 4 жыл бұрын
Mikey's Lab i see. Just an additional question, do you know how to transition between different mixers mid-flight using inav?
@mrtmrf5007
@mrtmrf5007 4 жыл бұрын
can i do that with any other esc? what abut a vesc ?
@MikeysLab
@MikeysLab 4 жыл бұрын
Yes, almost all ESC's understand pwm, it is only once you start using one shot and d shot that you need specific esc's. Sorry about the delayed response, you tube did not notify me of you comment.
Brushless DC Speed Controller
15:11
Hyperspace Pirate
Рет қаралды 389 М.
Brushless Motor - How they work BLDC ESC PWM
16:12
The Engineering Mindset
Рет қаралды 4,7 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Open Source ESC based on Arduino - High Speeds
16:58
Electronoobs
Рет қаралды 181 М.
RC Robot Car - RC Controls and Arduino
47:53
DroneBot Workshop
Рет қаралды 224 М.
DC motor PID speed control
15:29
Curio Res
Рет қаралды 255 М.
VESC (Best Open Source ESC) || DIY or Buy
10:42
GreatScott!
Рет қаралды 628 М.
Simple Arduino Servo ESC PWM
8:07
JustAnotherMakerChannel
Рет қаралды 1,2 М.
Brushless Motor Control with Arduino (slow rotation) Open loop
11:24
Random Access Projects
Рет қаралды 27 М.
How Brushless Motor and ESC Work and How To Control them using Arduino
12:45
How To Mechatronics
Рет қаралды 1,3 МЛН
How PWM works | Controlling a DC motor with a homemade circuit
10:01
8 | Control a brushless motor with a Teensy
6:32
Carbon Aeronautics
Рет қаралды 17 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН