There is a lot of interest these days among hobbyists in controlling brushless DC (BLDC) motors, which have improved performance and better energy efficiency over
traditional DC motors, but are more difficult to use. Many off-the-shelf products exist for this purpose. For example, there are lots of small BLDCs controllers for RC
airplanes that work really well.

For those wanting to delve more deeply into BLDC control there are also many different micro controllers and other electronic hardware intended for industrial users and
these usually have very good documentation. So far, I have not found any comprehensive descriptions of how to do BLDC control with an Arduino microcontroller. Also, if
you are interested in doing regenerative braking, or using a BLDC for power generation, I have not found many products that are suitable for use with small motors or
much information on how to control a 3-phase generator.

This instructable started out as a demonstration project in a class on real-time computing, and which I continued after the class ended. The idea for the project was to
demonstrate a scale model of a hybrid electric vehicle with flywheel energy storage and regenerative braking. The motors used in the project are small BLDCs
scavenged from broken computer hard drives. This instructable describes how to implement BLDC control with one of these motors, an Arduino microcontroller and Hall-
Effect position sensors, in both motoring and regenerative braking modes. Note that having access to an oscilliscope is extremely helpful, if not essential, to doing this
project. If you don't have access to a scope, I have added some suggestions for how it might be done without one (step 5).

One thing that this project doesn't have that should be included in any practical motor controller is any safety features, such as overcurrent protection. As it is, the worst
thing that can happen is that you burn out the HD motor. However, it would not be too difficult to implement overcurrent protection with the current hardware, and perhaps
I will do it at some point. If you try controlling a larger motor, please do add overcurrent protection, to protect your motor, and for your own safety.

I would like to try using this controller with a larger motor that can do some "real" work, but I don't have a suitable motor yet. I noticed an 86W motor for sale on eBay for
around $40.00 that seems like a good candidate. There's also an RC website called "GoBrushless" that sells kits for putting together your own BLDC. These are not too
expensive and building one is a worthwhile experience. Note that the motors from this web site do not have Hall sensors.

Whew! It was a lot of work to write up this instructable. I hope you find it useful and please post your comments and suggestions.

Step 1: Video

Hi Capo.Ferrari,<br><br>The instructable already has instructions for the regenerative braking.
<p>Thanks for the fast reply Diginstructables,<br>My ebike controller comes with an High level input cable that automatically turns the motor Off when the brake levers are pressed. Also has an output cable thar is conected to the speed meter. This output goes from 0 to 5v when motor is at max speed.<br>Is it possible to add this input and extra output, one for the brake levers and other to the speed meter?<br>I saw in the code that the Regenerative state acts when throttle is at certain position, what is great.<br>May be you can help with a few codes lines to make this possible. I know that you make it time ago. Sorry if im worring you.<br>I really think that this amazing instructable could be scalable to others levels if we think in future transports vehicles and be very helpfull to those who are innovating in this technology.<br>The credit is yours!<br>Thanks again for the helpfull assistance.<br>Best regards,<br>Capo.Ferrari.<br>P/D: I promise to post photos of your desing and the power bloc that im using (the old chinese controller power bloc) all working together.<br>Thank You very much!</p>
<p>I might be way off on this but could you scale this model up for an electric bike application or will the Arduino not be capable of that?</p>
Hi Aaron,<br>That's great that you got your motor working! Yes, it could be an over-temperature sensor that is stopping it, so I would try heat sinking. Also,you could be exceeding the current or voltage specs of the driver. Look on the data sheet for the maximum ratings. I think you just need to use ohm's law to figure out the current you need. First, measure the resistance of one of the motor phases. For example, if the phase is 10 ohms, then I = 24/10 or 2.4 Amps.
<p>I agree with Aaron. I think that this amazing instructable is able to control an ebike prototype. Is&acute;t possible to add an input for a break?. I mean, when you press the break in the ebike, turn motor off and regenerative state On?</p><p>Would you please explain how to do that? Sorry for my bad english and my poor knowledge in arduino.</p><p>Thanks!</p>
I don't think the Arduino would have any trouble with that, but you would want to beef up the power electronics.I don't think the L6234 could handle those kinds of currents/voltages (look at the datasheet to be sure).<br><br>If you do start working with larger motors, be sure to educate yourself on the safety issues involved, both for your own safety, and for the care of the electronics components.
<p>So got the full project working with the 24v motor but I'm having trouble figuring out what to scale up. I can only get the motor to run for a short period of time. Is it necessary to add a heat sink or am I forgetting to upgrade the power electronics? Additionally for upgrading the power elections is there a resource to figure out how much to change each component?</p>
<p>Thank you! I know you were asked this prior but do you have a schematic for this circuit by chance?</p>
<p>This motherboard can control 2 bldc hubmotors 36V...i don't know how to connect it to an Arduino though.</p><p>A Roboteq fbl-2360 can do the job though, also by Arduino but you'll have to ask Roboteq for the special firmware on their forum.</p>
<p>Hi,</p><p>That sounds like a very interesting project. I have no experience with RC, but in terms of motor control, yes, I believe an Arduino (16 MHz clock speed) could handle controlling two motors at the same time. I suppose you would alternate the commutation between the two motors, and your algorithm would vary the motor speeds depending on the position of the joystick. Good luck!</p>
<p>Is there a way to control 2 brushless motor in a differential steering method?</p><p>I am working on a project that need two hub motors and have two brushless drivers.</p><p>What I want to do is to have the RC communication handled by an arduino which sends signals to the controllers to mix 2 channels to create steering using one joystick.</p><p>I found a few forums <a href="http://forum.arduino.cc/index.php?topic=172581.0" rel="nofollow">http://forum.arduino.cc/index.php?topic=172581.0</a></p><p><a href="http://forum.arduino.cc/index.php/topic,157967.0.html" rel="nofollow">http://forum.arduino.cc/index.php/topic,157967.0.h...</a></p><p>but the don't have any brushless motor control techniques.</p><p>the brushless motor controller I would like to use is </p><p><a href="https://www.aliexpress.com/item/DC-12V-24V-36V-500W-Brushless-Motor-Controller-Hall-Balanced-Car-Driver-Board/32482717212.html?spm=2114.01010208.3.10.DBYu6X&ws_ab_test=searchweb0_0,searchweb201602_4_10056_10065_10055_10068_10067_10054_10069_10059_10073_10017_10070_10060_10061_10052_10062_10053_10050_10051,searchweb201603_1&btsid=d5d985f6-44e0-4af3-87c9-a89523b8d7db" rel="nofollow">https://www.aliexpress.com/item/DC-12V-24V-36V-500...</a></p><p>The motors I would like to use is</p><p>https://www.aliexpress.com/item/2pcs-1pair-DIY-Motor-for-2-Wheels-8-inch-8-Smart-Self-Balancing-Electric-Unicycle-Scooter/32596302582.html?spm=2114.01010208.3.48.ut8BBp&amp;ws_ab_test=searchweb0_0,searchweb201602_4_10056_10065_10055_10068_10067_10054_10069_10059_10073_10017_10070_10060_10061_10052_10062_10053_10050_10051,searchweb201603_1&amp;btsid=1c00995a-ca82-4379-9808-f940f1df515f</p>
<p>could you please share the all schema? i think have some connection mistakes. I couldn't understand all connections from the photos and codes</p>
<p><a href="http://www.instructables.com/member/dlginstructables/" style="">dlginstructables</a> perfect project.<br>i want to ask if can i use Arduino UNO, if i can, what i need to change in your schematic project?<br><br>thank a lot </p>
<p>hi i need to know how i can make the ir2101 HIGH AND LOW SIDE DRIVER works with an arduino uno and what kind of programming i need for the arduino uno so that ir 2101 works</p><p>thanks...!!!!</p>
<p>Nice project</p><p>I have three questions:-</p><p>1. Can we run brushless dc motor in both directions that is, clockwise and anticlockwise? (with some modifications)</p><p>2. Can we use Gyroscope(MPU6050) instead of potentiometer to control the speed and direction of bldc motor?</p><p>3. Why only 12 volts?, because L6234 can handle upto 52V??</p><p>thanks in advance</p><p>( Basically i want to control a 24 volt Brushless dc motor with arduino uno and gyroscope(MPU6050) i.e. whenever we tilt gyroscope in one direction, motor should run in clockwise direction, and whenever we tilt gyroscope in another direction motor should run in anticlockwise direction, and whenever gyroscope is at 0 degree angle to ground, motor should stop. Its the same principle of Self balancing robot, but can it be done with brushless dc motors?? )</p>
<p><a href="http://www.instructables.com/member/dlginstructables/" rel="nofollow">dlginstructables</a> nice project.</p><p>This project is bigger bit than I chew; I don't have the equipment to test it and calibrate it.</p><p>Can you direct me to someone who has this type of controller for sale. </p><p>I have a BLDC motor with six windings connected the same way as in your diagram and 3 hall sensors at 120 degrees apart, a rotor has four permanents magnets (N S N S).</p><p>Thank you.</p>
How can I check operation of Hall sensor? <br>Can I check it by Sanwa Analog Multitester ?
<p>You can check it with a DMM or a scope. Put any magnet near it and it should change the output from 0V to your source voltage. The best way is to put the magnet ring that will be used next to the senor and rotate it. You should see a square wave.</p>
The best way to test the Hall sensor is with an oscilloscope, but you can use a multitester (we call it a multimeter in the U.S.). <br><br>First, connect the sensor as shown in my instructions, and then move a magnet slowly across the sensor. When the sensor works, you will see the voltage go high when it senses the magnetic field. A refrigerator magnet is useful for this, because it has stripes of magnets and as you move it across the sensor, the voltage will go high-low-high-low...
<p>Thanks a lot. Using Your information, I made mine adaptation for driving BLDC at very slow speed:</p><p>http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/</p>
<p>Awesome! Glad my project was helpful to you.</p>
<p>why are we using hall sensors ..i&quot;ve seen some running them using arduino without the hall sensors ...what is the advantage</p>
<p>As I explain in the Instructable, the two most common ways to control a BLDC are with hall sensors, and &quot;sensorless&quot;, which uses the back EMF waveform for feedback on the motor's position. The easiest approach, and what I suspect you are referring to, is to buy a sensorless motor controller that is made for RC airplane motors, which can easily be controlled by an Arduino. The use of hall sensors in this project was the easiest way for me to do it from scratch. I did also spend a lot of time trying to develop a sensorless controller. I got close, but I wasn't able to make it work well enough.</p>
<p>Would it be possible to use a BLDC motor almost like a stepper? That it, to accelerate carefully,run for a counted number of cycles, deccelearate, and stop at a specified location (ie: move exactly some number of cycles, or partial cycles).</p>
<p>In principle, the answer is &quot;yes&quot;. I have run one of these motors very slowly, so I could see each individual step. However, at faster speeds, I would think that inertia would cause the motor to overshoot the exact angular location that you wanted. I think it's worth experimenting with.</p>
<p>Nice Tutorial!</p><p>But, why you use PWM for Enable pin in L6234 IC? not for Input pin?</p><p>Thanks!</p>
<p>And then, can i use the PWM for Input pin and give the Enable pin HIGH state (in this case, i just give 5volt to Enable pin, just for enabling)? can i use the same code as you use (pin declaration change too)?</p>
<p>Do I understand correctly that a BLDC/PMSM motor differs from an AC induction motor, in that you vary the current going to the BLDC's stator, which causes the magnetic field to move the dc permanent magnet on the rotor?</p><p>For trepezoidal commutation, the current is driven in only 2 of the 3 stators at a time.. and sinousoidal commutation drives current on all 3 windings. The former is good for high speed while the latter for low speed.</p><p>If so, how does field oriented control work and can it be used on a BLDC/PMSM? Also how are these system generally closed - using ((fuzzy) pid ? state space lq? </p><p>Is there any kit recommendations? I'd love to play with simulink or octave and see how this all works!</p>
<p>Hi peeps,I m about to build this circuit but I have doubt bout drain sign(arrow) at SENSE2 output.What is is actually?where should I connect to it? Thanks </p>
Hi, it's been a long time since I built this, so I may not remember correctly, but I think that I didn't use the current sensing capability in my circuit. If you are going to use it, then I think the arrow would go to an A/D converter, to measure the voltage across the resistor. Then you would use ohm's law to calculate the current and, if it goes above your cutoff value, your software would shut down the motor. If you are going to be using a larger motor with a real load on it, then I would recommend using this feature.
<p>Thanks Sir for your answer..One more thing,if want to make it sesorless,what your I do?just ignore all the sense pin at L6234?</p>
<p>Hi,I'm doing a project on BLDC motor controller using a 24v RS 5366024 brushless motor <a href="http://uk.rs-online.com/web/p/dc-motors/5366024/" rel="nofollow">http://uk.rs-online.com/web/p/dc-motors/5366024/ </a> and Arduino uno. Can anyone help with a circuit diagram and schematic on how best I can build up the circuit. I've tried looking through this project but seem to have a diagram with reference to this. <a href="http://prntscr.com/5zdjax" rel="nofollow">http://prntscr.com/5zdjax </a> ,thank you.</p>
<p>Thank you for idea with scope, have read some forums but never seen someone using scope to align hall-sensors.</p>
<p>I don&acute;t understand why you used pins 1,2,3 of Arduino, and the in the program you write &quot;pinMode(4,INPUT)&quot; //hall3......is it wrong?</p><p>thanks</p>
<p>Yes, I believe that my diagram is mistaken and it should show connections to pins 2,3,4. Pins 0 and 1 on the arduino are needed for serial communications, and I think I did use serial commands for troubleshooting. You're the first person to ask a question about the software! Good luck!</p>
<p>Hello! that was a great instructable guide! Thanks</p><p>I'd like to control 3x L6234 IC's (3x BLDC motors) with the cheapest microcontroller/board/lauchpad but i'm a bit confused about the requirements needed for the microcontroller. As i understood each motor needs 3 PWM control signals so i'd need 9 PWM's, but i'd also need 9 timers in the microcontroller right? Or can i use just 3 combined with prescalers? </p><p>I was thinking about using Arduino boards but they are still more expensive than texas launchkits (MSP430 launchpad and stellaris could do the work?).</p>
You don't need any timers, just the 3 pwms per motor. The prescalers are used to set the pwm frequency of the ATMEL microcontroller. I don't know how cheap the TI kits are, but there are Arduino clones that are pretty inexpensive and also online instructions for using the ATMEL microcontrollers by themselves. You might also investigate the use of a programmable logic controller, which I mention in the last step of this instructable.
<p>Ah ok thanks!</p><p>I also understood you used the INs and ENABLE pins to control the 6 sequence steps (to specify which phase was or was not being used):</p><p>Step 1 2 3 4 5 6<br> <br>Clockwise: CB, AB, AC, BC, BA, CA<br> <br>Counter Clockwise: BC, BA, CA, CB, AB, AC<br><br>but on the boards i have the ENABLE pin is only one (the 3 ENABLEs are shortcircuit to each other =/. I can control the PIN but on the 3 pins in separate. Is there a way to rotate the motor with the board like this?</p>
<p>Hi, is there any chance of a schematic of the power circuitry you used? I'm demoing this to some of my students and it would be much easier than ficuring it out from the photos. Thanks for such a good instructable by the way, really useful.</p>
<p>Hello, great proyect! do you know the range of RPM you can achieve with the L6234 and the HDD brushless (sensorless) motor?</p><p>Thanks a lot!</p>
If I remember correctly, I got up to around 10,000 RPM with my set up. I don't remember the lower limit.
<p>Hello.</p><p>Is it possible to use this setup for controlling bigger motors, like 1KW.?</p><p>I <br> have made few dc controllers and i was planning to make one blcd <br>controller but this setup would be much easier . My motor is for e bike and i was planning on using 48V or 72V input ( <br> crystalyte 1,5KW ). </p><p>Thank you for your reply.</p>
The L6234 can handle up to 52V and 5A, so you would need to find a three phase motor driver that can handle 1.5 kW, and also a set of transistors that can handle high voltage and current. Chances are that this driver will not use the same logic control as the L6234, so you would have to adapt your microcontroller program accordingly. If you are going to work with that much power, please make sure you are familiar with proper safety precautions.
Hi. <br>I am doing a project based on the speed control of a bldc motor by pulse width modulation using an Arduino board. However, my motor does not have a hall sensor to provide the feedback on speed to the arduino. My set up involves using an esc (electronic speed controller) to link the bldc with the arduino. Can you suggest some method to achieve the required results with my components. <br>Great page by the way. Cheers!
<p>Hi, I thought I had replied to you already. Anyway, The ESC is controlled by using PWM at a certain frequency (I forgot the value, but you can look it up). You will need some method of measuring the rotational speed of the motor, to give your control system feedback. I tried measuring the back EMF period from a motor with an ESC, but the act of measuring it interfered with the ESC (which uses sensorless control). So, you either need an encoder on your motor, or a hall sensor. Both of these are fairly straight forward to implement, if your motor geometry permits either or both.</p>
Awesome project!
Thank you!
Hello, <br> <br>Im using a 24V 200w BLDC motor, <br>what components here do I need to adjust?
hi! thanks yor this instructable! it is amazing!... <br>I am working in a proyect, and I wonder if you could help me to figure out how to do one thing... <br>I want to be able to set the speed of a BLDC motor, mecanicaly, I mean imagine that you manually give speed to the motor and then it keeps the speed for it self untill you stop it, actually I would like to use regenerative breaking to stop it... <br>(I am talking about a 14.8V / 800W / 50A brushless motor) <br>I was thinking about hall sensors for determinate at what speed is the motor mecanicaly rotating, and then use an arduino to set that speed as the constant speed for motor. So the only inputs for this sistem should be the hall sensors (no other input to set the speed of the motor) and the break. <br>Do you think this is posible? <br>I only need one direction in the motor, so could I use a standard ESC to control the motor speed? or you think that is better to make my own ESC like you did? <br>tell me what you think! <br>thanks!

About This Instructable




Bio: By day I'm a mechanical engineer at a university laboratory. In my free time, I do my own projects.
More by dlginstructables:Low Power Solar Electric Kettle-Thermos DIY Bicycle Pannier (Saddle Bag) Programmable Smart Solar Oven 
Add instructable to: