3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

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

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
 

Step 1Video

Video

« Previous StepDownload PDFView All StepsNext Step »
28 comments
Mar 30, 2012. 6:43 AMchuvso says:
How can I check operation of Hall sensor?
Can I check it by Sanwa Analog Multitester ?
Nov 4, 2011. 10:54 AMPash1987 says:
I'm relatively new to Arduino and am currently still finding my feet on it.

I am designing a parking sensor and need to use the analogWrite() function to control my sensor as the tone() function is tied up somewhere else.

I was wondering if you could run me through how you altered the frequency of the analogWrite() PWM.

Any help would be greatly appreciated.
Jan 14, 2012. 10:57 AMBradyZ says:
You modify the TCCRnB ('n' is the number of the timer) register for one of the TIMER's. The ATmega328P has 3 timers (TIMER0, TIMER1, and TIMER2). If you want to change the PWM frequency, you just modify the prescaler value for whatever timer you want to change. TIMER0 is used for delay() and millis(), so it's better to use any timer other than TIMER0; but usually nothing bad happens if you modify TIMER0. Your program just wont have/use the correct values in delay() and millis(). To change the PWM frequency on pins 3 and 11 (they use TIMER2) to be ~4kHz (3906.25) you simply place the following line of code in your "void setup()" space:

TCCR2B = TCCR2B & 0b11111000 | 0x02;

- The default for TIMER2 is "0x04"
- If the code is confusing, check out these links for some help:  
      -http://arduino.cc/en/Reference/Boolean  
      -http://arduino.cc/en/Reference/BitwiseAnd  
      -http://arduino.cc/en/Reference/BitwiseXorNot
      -http://arduino.cc/en/Reference/Bitshift

This will work on any 'ATmega' or 'ATtiny' that is supported by Arduino (install ATtiny 'cores' to program them with Arduino 0022 or Arduino 1.0)


I did not figure this stuff out myself. I'm just passing the information onward. Check out this page in the Arduino Playground. It's extremely helpful!
      -http://arduino.cc/playground/Main/TimerPWMCheatsheet
Nov 4, 2011. 2:05 AMNakiros says:
For higher power you should better turn to mosfet bridges(like the irf3704s-77A@10V) and gate drivers (ir2101 or ir2110). Just google 'Open BLDC' and you will find more info.
May 25, 2010. 12:02 PMDemonSpawn says:
 so is the speed of the motor variable? cause im making a autonomus hexacopter and need a speed controller based on a arduino. also dus it use the hall effect sersors for the speed control or only for braking. is there any feedback about the rmp?? ie can you read off the current rpm of the motor any time ??
Oct 28, 2011. 5:01 PMlampuiho says:
the speed of the BLDC motor is determined by the frequency of the pulses of voltage sent to the stator windings. So what you need to do to increase the speed is to reduce the period of the signal and vice versa.
Oct 28, 2011. 4:54 PMlampuiho says:
Are you controlling the field current directly? If not, that's probably the reason why it didn't work well.
Sep 30, 2011. 4:33 AMGnutella says:
My HD motor has 4 contacts . can you please explain how i could make them turn clockwise and counter clockwise? explain it to me like youre explaining it to a Four year Old.
Aug 31, 2011. 10:17 PMrany says:
Thanks a lot for the the nice upload ... superr..
Jun 17, 2011. 12:02 PMcarl says:
It looks to me like the hall sensors need to be 30 mechanical degrees apart, which I think would be 120 electrical degrees. Am I making a conceptual error? My motor has 12 slots and 8 poles, which appears to me to be similar to your motor.
Jun 17, 2011. 1:46 PMcarl says:
Thanks for the reply. I too am trying to learn about bldc motor control by starting small. I wouldn't have questioned the 15 degree spacing except that I couldn't fit my hall sensors 15 degrees apart without overlap on a sketch of the rotor diameter. From your photos it looked to me like your hall sensor holder was built at 30 degree spacing (it looks like an equilateral triangle will fit between the center and the outer two Hall sensors). I thought I'd ask before I started hacking into my holder material. I guess this is the opportunity for learning that I was looking for!
Jun 17, 2011. 10:00 PMcarl says:
I drew a sketch of the poles and sensors, then rotated the poles to try to understand how the signals change during rotation. A 30 degree spacing works. A 15 degree spacing does not work (a 111 and 000 shows up at that spacing since the sensors span 30 degrees and a pole spans almost 45 degrees). It looks like the image in step three shows sensor B output inverted, making it look like the sensors should be spaced 60 electrical degrees apart when they should be 120 electrical degrees apart. That's my story at the moment. I will need to throw something together and put it on the oscilloscope and see what happens.
May 7, 2011. 4:56 PMcarmatic says:
This looks like 'dynamic' braking rather than 'regenrative' braking, as in the motor is basically shorted out, and the energy would be dissipated as heat in the wires... I do not see how the energy is stored from braking?
May 19, 2011. 12:41 PMcarmatic says:
okay yeah, i see the third picture now... for some reason the last time i viewed this, the picture showing current flowing into the battery didnt show up

i think that it is better if there were 2 indepenent circuits between the bridge and the battery, one for driving the motor with the pwm control and back emf sensing as well as controlling the transistors in the bridge, and the other for charging the battery with some form of voltage regulation and maybe some charging circuitry designed for the type of battery being used... and using solid state relays to switch between them when the brake is pressed
Mar 16, 2011. 2:26 AMjaillela says:
Thank you very much for sharing this project.

I´ve got a question. When using regenerative breaking, you are not drawing any current back to the battery, right? and also, for regenerative breaking, are the hall effect sensor necessary?

I am asking you this questions, because I would like to use the energy from the breaking to control the breaking torque and by the way recharge a battery.

Best Regards and thanks again for your work.
Dec 28, 2010. 5:40 AMevaleto says:
Thank you so much for your work!
I read all paper you gave for understand how BLDC work. Unfortunately, I don't know how to find a driver (like L6234) but for motor with higher power 37V/10A.

regards,
oe
Jul 18, 2010. 10:22 PMchaitanyab says:
This is really nice info with great illustration,thanks.
Jun 30, 2010. 8:18 AMAKA the A says:
http://www.hobbycity.com/hobbyking/store/uh_viewItem.asp?idProduct=9821 It's a motor suited for 1:10 RC cars, has sensors built in and (get this) costs $16!!! Quite a nice (and cheap) way to scale up this project...

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
32
Followers
6
Author:dlginstructables
By day I'm a mechanical engineer at a university laboratory. In my free time, I do my own projects.