BLDC Motor Control with Arduino, salvaged HD motor, and Hall Sensors

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.
Remove these adsRemove these ads by Signing Up
1-40 of 67Next »
awpe001 month ago

Thank you for idea with scope, have read some forums but never seen someone using scope to align hall-sensors.

cheech_jc2 months ago

I don´t understand why you used pins 1,2,3 of Arduino, and the in the program you write "pinMode(4,INPUT)" // it wrong?


dlginstructables (author)  cheech_jc2 months ago

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!

Hello! that was a great instructable guide! Thanks

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?

I was thinking about using Arduino boards but they are still more expensive than texas launchkits (MSP430 launchpad and stellaris could do the work?).

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.

Ah ok thanks!

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):

Step 1 2 3 4 5 6

Clockwise: CB, AB, AC, BC, BA, CA

Counter Clockwise: BC, BA, CA, CB, AB, AC

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?

sprocketeer3 months ago

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.

pablocv4 months ago

Hello, great proyect! do you know the range of RPM you can achieve with the L6234 and the HDD brushless (sensorless) motor?

Thanks a lot!

dlginstructables (author)  pablocv3 months ago
If I remember correctly, I got up to around 10,000 RPM with my set up. I don't remember the lower limit.
enxp5 months ago


Is it possible to use this setup for controlling bigger motors, like 1KW.?

have made few dc controllers and i was planning to make one blcd
controller but this setup would be much easier . My motor is for e bike and i was planning on using 48V or 72V input (
crystalyte 1,5KW ).

Thank you for your reply.

dlginstructables (author)  enxp3 months ago
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.
edwinjohn1 year ago
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.
Great page by the way. Cheers!
dlginstructables (author)  edwinjohn1 year ago

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.

daleshco1 year ago
Awesome project!
dlginstructables (author)  daleshco1 year ago
Thank you!
mfranco101 year ago

Im using a 24V 200w BLDC motor,
what components here do I need to adjust?
hi! thanks yor this instructable! it is amazing!...
I am working in a proyect, and I wonder if you could help me to figure out how to do one thing...
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...
(I am talking about a 14.8V / 800W / 50A brushless motor)
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.
Do you think this is posible?
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?
tell me what you think!
dlginstructables (author)  lucianorueda1 year ago
Hi, can you answer these two questions?
1. What tolerance do you want for constant speed? For example 500 ±25 RPM
2. How much will the load on your motor vary?

If you use just an ESC, controlling it is like the gas pedal on a car. You can hold the pedal in the same place and go a constant speed, but if you go up or down a hill, then you will have to change the pedal position to keep your speed constant. So, you will need a feedback loop. If you make the Arduino control the motor commutation, like my instructable, that keeps the Arduino very busy, and it may not be able to handle speed control at the same time.

A good way to go would be to use an ESC and then use the Arduino, with hall sensor feedback and a PID controller, to control the speed. I think that most (all?) ESCs for RC airplanes use sensorless control. Does your motor already have hall sensors?
elabz1 year ago
I love to spin these up to 10,000 RPM + myself but just a bit of a warning is in order here I think. Just yesterday I've opened a 2.5" (laptop) HDD in which the platter has shattered to thousand very dangerous looking glass shards. I assume not all HDDs have ceramic platters, especially not very old ones, but if they do, you spin it up high and it breaks from vibration or you've overtightened the bolt(s) or something like this, the result would be very much like an explosion of a grenade and someone will end up in a hospital or dead. For any serious RPMs you need to have some sort of a cover - the HDDs own body is nice or perhaps a cover from a 100-CD blanks box or some such.

Other than that, happy spinning!
dlginstructables (author)  elabz1 year ago
Thanks for the comment. I thought that the hd platters were made of metal, but I looked it up and some of them are in fact glass/ceramic. In my project, I had several of them glued together and they were never screwed down tightly, but, when I get a chance, I will add a suggestion that a clear cover be put over the platters.
CraigHyatt1 year ago
This is one of the best instructables I've seen. I like that you broke down how the Hall sensors and bridge operate in such a detailed day. Bonus that you included regenerative braking. I've read a ton of documents on this topic, and this is the first time I have actually understood what is going on. Thanks!
dlginstructables (author)  CraigHyatt1 year ago
Thank you very much for the compliment! I put a lot of work into describing everything and I like to know that people are benefiting from it. Yeah, regen braking is hard to grasp, and I by no means have it down. I don't know why there isn't more info out there about it. By the way, I recently drove a Nissan Leaf, and when it does regenerative braking it sounds pretty much the same as my little disk drive motors do!
elabz1 year ago
Not sure what you mean by "running the motor as a stepper motor, not as a BLDC" - 9 cog 12 pole BLDC motor is very much like a 36 SPR stepper. Did you mean that his commutation sequence did not include a high-Z state for one of the windings in each step?
E_motor1 year ago
awesome guide this! Just fyi, step 5's first picture tag shows 15 degrees, so does the second last line on that page, and the second line in step 7 also says 15, where they should be 30 degrees apart. Was a bit lost until I saw your exchange with Carl.
guillempq2 years ago
Is it better control 4 brushless motors through receiver or this special chip?
guillempq2 years ago
Can you write an example about the Arduino working with a commercial Brushless Motor, please?

int motor = 0;
void setup() {
pinMode(motor, OUTPUT); //analog Pin
void loop() {
analogWrite(motor, 255);
analogWrite(motor, 40);
But it doesn't work?
Regards and thanks
dlginstructables (author)  guillempq2 years ago
The arduino digital pins can only output a very small amount of current, so if you have your motor directly connected to the Arduino, I wouldn't expect it to work. What you need to do is use the analogWrite output to control a separate power source.

Here is one instruct able that uses a special chip for controlling motors that will allow you to operate the motor in both directions:

If you only need to run the motor in one direction, then you can use a MOSFETtransistor like this one, which has a link to an arduino tutorial:

Good Luck!
mhyanni2 years ago
Man,You're Great !!
I'm gonna start on the Project thanks for your help my friend !
dlginstructables (author)  mhyanni2 years ago
Thank you. I put a lot of work into this instructable, and I hope it helps you do the project successfully.
tomshirvo2 years ago

Yes they all support 2A but after some troubleshooting I found that the motor only draws .05A from a working 3 phase controller I have. I did find that one of the hall sensors is not working correctly.

I have tested everything;
I tested that the out puts work High, Low and NC they are fine. I am using 24V and not 12V like you did, does that mean that I should have made some changes with resistors. The one thing I did do was connect both the Sense one and two together and then connected the resistor to GND.

The motor just doesn't seem to spin at all.

dlginstructables (author)  tomshirvo2 years ago
There are three Hall Sensors and each one must have its own resistor and its own input to the Arduino.

Have you tried getting the motor to turn by manually powering the phases (see step 4)

Step 1 2 3 4 5 6
Clockwise: CB, AB, AC, BC, BA, CA
Counter Clockwise: BC, BA, CA, CB, AB, AC]

have you tested the Hall sensors? You should be able to make them go high by putting a magnet near them.

Do you have an oscilloscope? It helps to have that to see if the hall sensors are in synch with the motor (you can spin the motor by hand and watch the sensor output
Ok really strand thing, even though my multimeter give me a reading of 24v out of the outputs 1,2,3 when I make output 1 positive and output 2 negative I get a reading out on the multimeter 24v. BUT this is a big but, when I connect just a plane old dc motor to it nothing happens. If I put the motor on the 24v directly it works fine.

I keep thinking that it has something to do with the sense 1 and 2. you did say that you needed a 400ohm from sense to GND but mine is 470ohm.

dlginstructables (author)  tomshirvo2 years ago
Try measuring the voltage of the output while the DC motor is connected. If the voltage goes way down, then maybe not enough current is being supplied.

I don't know if it makes a difference to have 470 or 400 ohms on the sense pins.

I need to go back and read the instructable because I have forgotten so much. I will do that when I have time.

I have done the same and I don't know where I got the 400ohm resister from. I took that out of the system and it WORKS, sort of. It seems to spin some of the time. Some times it will spin for a while and then start to slow down and stop. Some times it will turn once and stop. and so on.

Thanks for your help so far i'm very grateful, but if you have any ideas with the new problem I'm happy to hear it.

Thanks again
dlginstructables (author)  tomshirvo2 years ago
Also, take a look at the Hall sensor calibration, to make sure that it matches the back EMF
dlginstructables (author)  tomshirvo2 years ago
Sorry I haven't replied in a long time. Have you had any progress? Based on your last message, I would take a look at the sequence of the motor's back EMF and make sure that your software is firing the digital outputs in the correct order. Do you have an oscilloscope to look at this?
One hall sensor is dead I'm not sure why but the others all work and my circuit works for that.

If you put the motor on a motor controller I have it works fine.
If you just take two of the phases and put them across the positive and negative terminals the motor moves a fraction.

I have a multimeter and when I put it on the terminals I can get a positive and negative and NC reading from each of the 3 phases of the out pins.

I have gotten this motor to turn just using relays it was slow and very noisy but it worked my point is the motor works.

I will list a few of the voltages coming off the L6234 below;
Vs: 24v
VBOOT: 31.7v
VCP: 4.61v
VREF: 9.24v
Sense 1 & 2: 0

I hope this helps. I'm so stuck right now. I don't understand how I can get voltage out of each output but nothing works

tomshirvo2 years ago

I have been trying to follow this instructable and I just cant get it to work.
I have built the electronics but the nothing works. the only difference is that I am using a 24v 2A BLDC and a Arduino UNO R3

Do you know if the code doesn't work with the UNO R3
dlginstructables (author)  tomshirvo2 years ago
Hi, you are the first person to write that you are trying to do this project :)

I wrote the code for a Duemilanove, but I think it should work fine with an UNO. I did this project three years ago, but I can try and help you troubleshoot.

My first question is: Do all of your electronic components support 2A?

Second, you say that nothing works. Why don't you start with an individual step iin the instructable and describe what is happening.
chuvso2 years ago
How can I check operation of Hall sensor?
Can I check it by Sanwa Analog Multitester ?
1-40 of 67Next »