Is there any "easy" way to do brushless DC motor speed control? - Page 1
Forum section: electronics / projects

author: FenderBender
author_rank: Super Contributor
timestamp: April 23, 2012, 01:42:35 pm
content: Hello,I'm trying to get into a bit of robotics and "RC" type stuff for the upcoming semester. (I'm taking an honors Electronics program in High School). I haven't really ever done anything like this before and as I look around getting speed control on brushless DC motors isn't all that simple, and the speed controllers available are definitely not open source and not willing to share this "black magic".A few distinctions that I hope someone can help me make. What's the difference between a 1,2, and 3 phase brushless DC motor. For instance, if I wanted to use this motor...http://www.hobbyking.com/hobbyking/store/__15184__S2030_6570_Brushless_Inrunner_6560kv_.html...How many phases does this have?My main question is...Is there way to control these motors semi-easily? Like interfacing a BLDC ASIC with a microcontroller somehow? Does anyone have any ideas on a simple-ish solution for this?Thanks.

author: IanB
author_rank: Super Contributor
timestamp: April 23, 2012, 02:17:35 pm
content: For the motor you linked to, you do speed control with one of these items:http://www.hobbyking.com/hobbyking/store/__61__182__ESC_UBEC_VR-All_Speed_Controllers.htmlThese ESC's are designed to take control inputs from RC servo systems. I'm sure you could figure out how the control inputs work and control them from your own electronics.

author: Psi
author_rank: Super Contributor
timestamp: April 23, 2012, 02:47:03 pm
content: As i understand those brushless RC motors they're just need 3phase AC.So you could power one (and set/change speed) using a micro, 3 IO lines and 3 fets by generating a 3phase square wave.The AC frequency you generate should set the rotational speed.But i've not actually used one of them before, so i might be wrong.I'm sure it would be easier/quicker to buy a proper RC motor controller from hobby king (see above post) and then interface to its servo input from your micro.

author: FenderBender
author_rank: Super Contributor
timestamp: April 23, 2012, 02:54:18 pm
content: Thanks, both of you.Yeah, I've read that to do brushless DC, you need 3 sine waves 120 degrees apart from each other but I'm not totally sure. I'd like to do it with either an AVR or PIC and eventually learn how to do wireless, whether that is using something like Xbee or something more complex.Thanks.

author: madworm
author_rank: Frequent Contributor
timestamp: April 23, 2012, 03:05:31 pm
content: Atmel and Microchip (AN857) have pretty good appnotes for BLDC control (sensor-less with back emf feedback). Forget about driving these BLDCs open-loop. Once you apply a bit of torque they fall out of sync and stop.By far the easiest way is to get an ESC for a few bucks and be done with it. Unless you badly want the learning experience.

author: IanB
author_rank: Super Contributor
timestamp: April 23, 2012, 03:27:14 pm
content: Generally the best design approach is to delegate power electronics to dedicated hardware and reserve the micro for supervisory control. Much the same way that you shouldn't put a micro in the feedback loop for a regulated power supply but should instead do the voltage and current regulation with analog circuits.

author: FenderBender
author_rank: Super Contributor
timestamp: April 23, 2012, 04:16:07 pm
content: Ugh I don't know what to do. I hate feeling like I'm giving up on something and just taking the easy way out, but that might be more practical as of my current skill set.

author: ejeffrey
author_rank: Super Contributor
timestamp: April 23, 2012, 05:11:11 pm
content: A BLDC motor is generally slow enough that it is fine to use a micro on it. How you use them depends a bit on the wiring and whether it contains a hall sensor, but the basic mode of operation is this:You have three wires connected to three MCU pins. Two of the pins are configured as digital outputs -- one high and one low, while the third is an ADC input. When the analog value reaches a threshold, you rotate the pins: the analog in becomes a digital low, the digital low becomes a digital high, and the digital high becomes the analog sense input.This leaves two problems. First is startup. The sensor relies on the motion of the rotor to generate back EMF. To start the motor you need apply some pulses without knowing the position of the rotor. If you chose poorly it might start moving backwards.Second is speed control. The algorithm I describe will result in the top speed possible. Variable speed is accomplished by PWM. If the motor is going too fast, you reduce the fraction of 'ON' time.Once you get it working, there is a lot of optimization you can do to improve the performance, noise, and efficiency, but it shouldn't be too hard to get a small motor running.

author: Kremmen
author_rank: Super Contributor
timestamp: April 23, 2012, 06:22:14 pm
content: My experience is with considerably bigger BLDC motors of the AC servo persuasion so this may not apply exactly on these small motors. Still here goes.The minimum you need is to apply voltage correctly phased to the 3 phase stator to achieve rotation in the first place. The phase info is available either by magnets/hall sensors giving you the 60 degree sector of the nominal rotor position, or by measuring the back EMF from a currently unenergized stator winding. One or the other you have to do or if not, failure is guaranteed.Next, there is a subtle difference between motors that are called BLDC (brushless DC) and motors that tend to be called PMSM (permanent magnet synchronous motors). Both are 3 phase electronically commutated motors (so the DC part is BS as far as the motor itself is concerned) but the magnet circuit (the "iron") in BLDC is optimized for trapezoidal voltage waveform and PMSM is optimized for sinusoidal. You tend to get a trapezoidal waveform from a 3 phase bridge inverter that are the standard power supply for BLDCs.Then the question of how to control a BLDC. Overwhelmingly the most common is an FPGA or ASIC to drive the bridge and a DSP to calculate the necessary transforms. The DSP can of course be a soft processor embedded in the FPGA but often it is not. TI's TMS320 is a popular choice for that.There are "simple" ways to control the driver bridge by just producing approximately correct phase and speed dependent voltage by pwm control. This would probably be enough for a small simple motor that you just need to get turning. For a proper servo with which i am familiar you need to take a considerably longer route. The current state of the art is the space vector control that requires transformation of the 3 rotating current and voltage vectors into a pair of flux vectors (the d and q vector) in a static reference frame fixed to the rotor nominal direction. The d vector then controls the virtual "field flux" and the q vector controls the virtual "armature flux", the latter producing the shaft torque. The calculation is achieved by matrix transforms, often called the Clarke and Park transforms and their inverse transforms.So what you do is you create 2 (PID) controllers for d and q vectors correspondingly. The "d" one takes as command input the virtual field setpoint and the "q" one takes as command input the torque setpoint. From the motor phase voltages and currents you calculate the virtual d and q actual values for the controllers by performing the above mentioned matrix transforms. Once you have the controller outputs for d and q you feed them into the inverse transforms to get the setpoints for the instantaneous phase voltages which in turn are fed to the 3 phase bridge controller.That is in the tiniest possible nutshell how you properly control a BLDC motor. It can be done on certain kinds of microcontroller but not at all by just any random one. I have some experience using Atmel's UC3C devices with hardware supported PWM generation and sufficient kick to do the DSP calculations. The relevant appnotes are easy to find in Atmel's website.A free in-depth paper into all aspects of BLDC motors and their control is the in my opinion unsurpassed MSc thesis work of James Mevey:http://krex.k-state.edu/dspace/bitstream/2097/1507/1/JamesMevey2009.pdf. A warning though - as it is a Master's thesis work there will be math, some of it more than just the elementary kind. Still definitely worth looking into for the general info you will get from there.

author: FenderBender
author_rank: Super Contributor
timestamp: April 23, 2012, 07:04:26 pm
content: Thank you for all of the valuable information. I did actually read what you wrote thoroughly.. I seriously just started looking into motors within the past week on my own so i still have a crapton of learning to do.Eventually someday I would like to be able to build a autonomous robot from scratch but the ETA on that is way in the future...So thank you. I'm currently looming over the pdf.

author: Leo Bodnar
author_rank: Frequent Contributor
timestamp: April 25, 2012, 06:35:37 pm
content: FenderBender,If you get a BLDC with Hall sensors position feedback, you are looking at the code complexity of about a dozen of lines to make it run.This should be rewarding enough to keep you interested.The rest of the code would be exactly the same as for a DC motor.You can leave SVM, torque control, sensorless feedback and flux weakening mode for later.Leo

author: cyberfish
author_rank: Regular Contributor
timestamp: April 26, 2012, 12:44:36 am
content: BLDC with hall sensors are very easy to drive. Essentially just need to read the 3 inputs, and have a lookup table that generates the 6 outputs (high side and low side of each phase).Driving low cost BLDC motors without sensors is A LOT more difficult, and there is some "black magic" on how to start it. Also very hard to debug if you can't get it to start, because you can't really see sensible back-emf without the motor already running.

author: sonicj
author_rank: Frequent Contributor
timestamp: April 27, 2012, 12:03:51 am
content: Quote from: FenderBender on April 23, 2012, 01:42:35 pmRCTimer/Turnigy/Hobbywing ESC DIY Firmware Flashing@ rcgroupsTurnigy/TowerPro/AfroESC/BlueSeries AVR ESC softwarein assembly

author: echu
author_rank: Newbie
timestamp: April 29, 2012, 05:08:24 am
content: TI has a very good BLDC reference design based on their Stellaris controller. it can control sensored and/or sensorless, has PID loops for power and RPM, ethernet interface with a very good PC logging application so you can see real time data and adjust parameters in real time. It is used by several hobby guys in Taiwan that are making RC controllers. You can get the board from Digikey Taiwan (and US, I asssume) and it comes with a sensored motor. You will be spinning the motor and modifying the code in minutes. Code builds with free tools based on eclipse. It is good.

author: Rudolfo
author_rank: Contributor
timestamp: April 29, 2012, 12:43:43 pm
content: For commutation and position sensor you might take a look at this application report:http://www.ichaus.biz/wp_boost_performancedescribing magnetic and optical solutions.Take care!