A multirotor drone’s propellers accelerate air downwards. The air pushes back on the propellers, producing an upward force called thrust. In a level hover, their combined thrust balances the drone’s weight. Turning the propellers faster produces more thrust: increasing the total above the drone’s weight makes it accelerate upwards. Increasing the thrust on one side relative to the other makes it tilt, directing some of the thrust sideways so it can accelerate across the ground.
The flight computer continually adjusts the thrust needed from each propeller to control the drone’s motion. The motors must change speed quickly enough to make those adjustments, while wasting as little battery power as possible in heat. This article follows what happens between a request for a different speed and the currents which make a motor respond.
Each propeller is turned by a brushless motor. In the common drone motor used here, the rotating part, called the rotor, carries a ring of magnets around a set of fixed coils. A steady connection to a battery cannot keep that motor turning: the currents in its coils must change as the magnets move. Between battery and motor sits the electronic speed controller, a circuit board with six transistor switches and a processor. Three wires run from the board to the motor. Tens of thousands of times each second, the processor chooses how long to connect each wire to each side of the battery. This controls the currents, and therefore the motor’s turning effort.
Field-oriented control is one method for making those decisions. It describes the currents relative to the magnetic field of the turning magnets. This lets the controller adjust the strength and direction of the coils’ field as the rotor turns, to produce the turning effort needed.
Here is such a controller at work. It runs in your browser against a simulated motor of the size used on a multirotor of a few kilograms, with a 15-inch propeller and a battery of six lithium cells. Move the first slider to ask for a different speed. The figure is slowed down so that the propeller can be seen to turn: at the speed it opens with, a real one would turn 62 times each second.
This controller has no sensor on the motor’s shaft. It combines measurements of the three currents with the voltage it applies and a model of the windings to estimate where the rotor is and how fast it turns. At the opening speed, the simulated propeller produces enough thrust in still air to balance the weight of 1.00 kilograms, while the battery supplies about 115 watts.
The figures use three colours. Orange shows current: the current in the motor’s coils and wires, and the readings which the controller takes of it. Blue shows the controller’s estimates, above all where it believes the rotor to be. Green shows what a model of the motor predicts or implies. Neutral marks, white or dark depending on your display theme, show the simulated motor itself and values which are simply known, such as the speed asked for or the voltage which the controller applies.
We will start with a magnet and a coil, then build up to the three currents which keep a motor turning. Describing those currents from the rotor’s point of view gives the controller two steady targets. We will see how voltage changes the current, and how feedback keeps it at its target. Then we will build the parts that apply the voltage, read the current and measure the winding’s properties. With those in place, we can find the rotor without a position sensor, start it from rest and control its speed. The final figures follow one complete control calculation and let you try the controller’s settings.
A magnet and a coil
A current in a coil of wire makes a magnetic field. Inside the coil the field points along the coil’s axis. In our model, its strength is proportional to the current, and it reverses when the current is reversed.
A magnet which is free to turn in that field tends to line its north pole up with it, as a compass needle does in the Earth’s field. This turning effect is called torque. Torque combines a force with its distance from the axis of rotation: one newton acting sideways on a one-metre arm gives one newton metre. For a magnet in a uniform field, torque varies as the sine of the angle between them. It is zero when they line up, largest at a quarter of a turn, and zero again when they point in opposite directions. That last position is unstable: a small disturbance makes the magnet turn away from it.
The figure shows one coil of the fixed part of a motor, the stator, and a magnet which can turn, the rotor. The orange arrow is the coil’s field: change the current to lengthen it or to reverse it. Drag the rotor to different angles and watch the torque. Then . It swings into line with the field and stays there.
Two things follow from this simple model. For a given current, torque is largest when the field is a quarter of a turn ahead of the rotor. Using the simulated motor’s magnetic constants, the contribution from one set of coils carrying 10 amps at that angle is 0.15 newton metres. A coil carrying a steady current cannot keep the rotor turning: with some damping, it settles in line with the field. To keep producing the largest forward torque, the field must move on as the rotor does.
Three coils
The motor has three sets of coils, called phases and named A, B and C. In this simple two-pole drawing, their axes are a third of a turn apart. We assume a star connection: one end of each phase joins the other two at a common point inside the motor, and the three free ends are the motor’s three wires.
Because the phases are joined, whatever current flows into the motor through one wire must flow out through the other two. The three currents always add up to zero. So although there are three currents, only two of them can be chosen freely: the third follows.
Each phase makes a field along its own axis, and the three fields add up to one. In the figure the thin arrows are the three contributions, laid end to end, and the thick arrow is where they lead. That arrow can point in any direction. Drag it, and watch the three currents which are needed to make it.
Three currents which add up to zero, and one arrow on a flat surface, hold the same information: two numbers. We will call the arrow the current vector. Its direction is the direction of the stator’s field. Its length is given in amps, on a scale which makes it equal to the largest current in any one wire as the arrow turns. The step from three currents to the two components of the arrow is called the Clarke transform, after the engineer Edith Clarke.
Now . Each current rises and falls as a sine wave, and the waves are separated by a third of a cycle. Three alternating currents make one field which turns smoothly. A rotor can follow that field if the torque is enough to accelerate it and turn its load; the faint rotor here simply illustrates that motion.
A real motor
The simulated motor, like most drone motors, is built inside out compared with these figures. Its coils are in the middle. Its magnets are fixed inside a steel cup, the bell, which turns around the coils and carries the propeller. There are 12 coils, four for each phase, and 14 magnets.
The magnets alternate: north, south, north. To a coil, the passing of one north and one south magnet is one whole cycle, the same as one turn of the simple rotor above. Fourteen magnets are seven pairs, so the cycle repeats 7 times in each turn of the bell. The position within a cycle is called the electrical angle. It is the angle of the bell multiplied by the number of pairs.
Everything said so far still holds if “angle” is read as electrical angle, and from here on that is what the figures show: the simple rotor, at the electrical angle. Speeds in turns per minute are always those of the bell and the propeller. At 3700 turns per minute, the speed at which the first figure opens, the currents go through 432 cycles each second.
Keeping a quarter turn ahead
To make torque steadily, the controller must keep the current vector ahead of the rotor as the rotor turns. Many simple speed controllers do it in six steps. They pass current in through one wire and out through another, and leave the third unused. That allows six combinations, and so six directions for the field, a sixth of a turn apart. The controller moves on to the next combination each time the rotor has turned through a sixth of a turn.
Between steps the field stands still while the rotor moves on. The angle between them shrinks from a third of a turn to a sixth, and then jumps back. The torque follows the sine of that angle, as in the first figure: it falls to 87% of its best value at each end of the swing, six times in every electrical turn.
The field-oriented controller aims to turn the current vector smoothly, in step with the rotor and a quarter of a turn ahead. in the figure, and the torque no longer dips. With equal phase resistances, a current vector of the same length produces the same winding heat in both cases. In this comparison the six steps therefore give 95% of the average torque for the same heat.
The torque curves depend on the motor’s magnetic shape. Motors designed for six-step drive can produce flatter torque with those currents, and real currents take time to move between phases. Overall efficiency also depends on switching and iron losses. The drawing isolates the effect of field angle; smoother torque reduces one source of vibration and motor noise.
To aim the field continuously, the controller needs two things. It must be able to make a current vector of the required strength and direction, and it must know where the rotor is. The rest of the article builds both.
The view from the rotor
Seen from the stator, a current vector which keeps pace with the rotor turns hundreds of times each second, and the three currents which make it alternate just as fast. A controller which worked with those currents directly would be chasing targets which never stand still.
Field-oriented control takes its name from the way round this. The controller describes the current vector along two axes which turn with the rotor, in place of axes fixed to the stator. The first axis, called d for direct, points along the rotor’s own field, from its south pole to its north. The second, called q for quadrature, is a quarter of a turn ahead of the first. Along these axes, a current vector which keeps pace with the rotor does not move at all. Its two components are steady numbers.
Both halves of the next figure show the same rotor and the same current vector. In the first view we stand on the stator and watch them turn. Its fixed axes are called α and β. In the second we ride on the rotor, with axes d and q. The components along α and β rise and fall, while those along d and q stay where they are.
In this motor model, torque is proportional to the q current: 0.022 newton metres for each amp. The d current lies along the rotor’s field and adds no torque, although it still heats the windings. Put and the torque is zero. Put it and the torque is the most this current can give. Put it and the torque acts in the opposite direction, braking a rotor which is turning forwards.
The controller’s task is now simple to state: hold the d current at zero, and hold the q current at the value which gives the torque that is wanted. At the opening speed of the first figure, the propeller needs a q current of 11.3 amps.
The step from the stator’s axes to the rotor’s is called the Park transform. It needs the electrical angle of the rotor, which we will write as θ:
d = α cos θ + β sin θ
q = β cos θ − α sin θ
Holding these currents requires feedback. The voltage needed to sustain a current changes as the rotor speeds up, and raising the current requires extra voltage. The controller therefore measures the currents, uses the Clarke and Park transforms to find their d and q components, and compares them with the targets. It adjusts the applied voltage to correct the difference. To see how that correction works, we first need to follow what happens when voltage is applied to a winding.
Making a voltage
The controller cannot set a current directly. What it has is six transistors, used as switches, in three pairs. Each pair serves one motor wire: the upper switch connects it to battery positive, and the lower switch connects it to battery negative.
The winding’s resistance causes a voltage drop proportional to current and dissipates energy as heat. Its inductance opposes changes in current: the voltage left after the resistive drop makes the current rise or fall gradually. A moving rotor also generates a voltage as its magnets pass the coils, called back-EMF. The current’s rate of change depends on the applied voltage after both the resistive drop and back-EMF are subtracted.
The controller switches each wire between the two sides of the battery many thousands of times each second. If a wire spends a quarter of a period on the positive side, its average voltage, measured from battery negative, is a quarter of the battery voltage. That share of the period is called the duty, and varying it is pulse-width modulation, or PWM. The winding currents depend on the voltage differences between the wires: the common point inside the motor is not connected to battery negative. When switching is fast enough, inductance keeps the currents close to those that the average voltages would produce.
The next figure holds the simulated rotor still, keeps wires B and C on the negative side, and switches wire A. The upper plot shows the current from the moment the switching starts. It climbs towards the current which a steady voltage of the same average would give, and takes a few thousandths of a second to get there: that slow climb is the inductance at work. How fast it climbs depends on the winding’s inductance and resistance. In this motor the current covers about two thirds of the distance still to go in each 1.0 thousandths of a second.
The lower plot shows what the switching leaves behind: a small saw-tooth, the ripple. At 40 thousand periods each second it is 0.21 amps from bottom to top. and each period gives the current five times as long to climb and fall: the ripple is 1.0 amps. to see the difference.
With the rotor held still, little voltage is needed to sustain a substantial current. Here a 6% duty on A, with B and C held low, gives an average current of 8.8 amps in A. After the initial rise, winding resistance limits the average current. As the rotor turns faster, its back-EMF grows, so the controller must apply more voltage to maintain the same driving current. A fixed duty would let the current fall.
Holding a current
The current controller chooses that voltage from the difference between the current wanted and the current measured. Its targets for d and q are called setpoints. A current below its setpoint calls for more voltage along that axis; a current above it calls for less. The controller repeats the comparison and correction every switching period, 40,000 times each second.
Voltages can be described along d and q just as currents can. Together, the two voltage components form a voltage vector, whose available length is limited by the battery voltage. For the next figure, the rotor’s angle is supplied to the controller, so we can concentrate on how it holds the current.
The winding model contains resistance and inductance, plus voltage terms due to rotation. Once those rotation terms are accounted for, each axis behaves like a resistance and an inductance in series. A step in the remaining voltage makes the current approach that voltage divided by the resistance, as in the figure of the switched wire.
On each axis the controller adds two corrections. The proportional part produces a voltage in proportion to the error between setpoint and reading. The integral part accumulates that error over time. Once the error is zero, it retains the voltage needed to sustain the current, including the steady voltage needed to overcome the rotor’s back-EMF. Together they form a PI controller.
Two gains set the strength of these parts. A chosen bandwidth sets the desired response speed. Following the model-based tuning described by Harnefors and Nee, the proportional gain is 2π times the chosen bandwidth in hertz times the inductance; the integral gain uses the resistance instead. The factor 2π converts hertz to radians per second. In an ideal model with exact motor parameters, continuous updates and no voltage limit, these gains cancel the winding’s slow response. The predicted current approaches its setpoint without overshoot, with a response time set by the bandwidth. Sampling delays, errors in the motor parameters and voltage limits make the implemented response depart from that prediction.
In the figure, the rotor is turned from outside at a fixed speed. The q setpoint steps from 2 amps to a higher value. The green curve is the response predicted by the model, and the orange line is what the readings show. With a bandwidth of 1000 hertz the model predicts 63% of the step after 0.16 thousandths of a second. The simulated current takes 0.15.
Change the bandwidth to or to , and compare the simulated current with the ideal prediction. A higher bandwidth gives a quicker response, but leaves fewer switching periods in which to make the correction. Return to .
The rule depends on knowing the motor. Tell the controller , and its first gain is half what it should be: the current starts slowly and then goes past the setpoint. Tell it , and the current arrives early. .
Two more details matter at speed. A current vector that stays still relative to the rotor is still turning relative to the windings. Inductance therefore requires voltage to keep it turning: in the rotor’s coordinates, current on each axis creates a voltage requirement on the other, proportional to electrical speed. The controller uses its speed estimate and current readings to supply these voltages directly, rather than waiting for an error to build up. This is called decoupling. , and the step along q disturbs the current along d. .
The second detail is the limit on the voltage. The controller cannot ask for a longer vector than the battery allows. : for a moment the controller wants more voltage than there is, and the current climbs more slowly than the model predicts. While the voltage is held at its limit, the part of the controller which builds up must be held back as well. Otherwise it goes on building, and the current overshoots when the limit is left behind. , and the overshoot is 9% of the step; with it held back, 1%. .
Three wires, one arrow
The current controller has chosen a voltage along d and one along q. The inverse Park transform turns this voltage vector back to the stator’s axes. The next task is to turn it into three duties, so the switches produce the requested average voltage at the motor.
As with the currents, the three phase voltages can be represented by a vector in the stator’s frame. Only voltage differences between wires drive current through the windings. Shifting all three terminal voltages by the same amount leaves those differences unchanged.
At any instant each wire is on one side of the battery or the other, which gives eight combinations. Six of them put a voltage across the motor, and their vectors point to the corners of a hexagon. In the other two, all three wires are on the same side, and there is no voltage across the motor at all.
To make a voltage vector inside the hexagon, the controller spends part of each period on the combination at either end of the nearest edge, and the rest on the two with no voltage. The thin arrows in the figure are those two shares, and they add up to the vector that is wanted. Drag the arrow and watch the three duties which result.
This is space-vector modulation. Dividing the time without voltage between its two combinations does not change the average voltage across the windings. This controller splits it equally and centres each wire’s pulse on the switching period. It can produce a vector as long as the battery voltage divided by the square root of three in every direction, while keeping all duties between 0 and 100%.
A simpler method makes the three terminal voltages follow sine waves around half the battery voltage, without shifting them together. and the reach shrinks to half the battery voltage. Space-vector modulation gives 15% more voltage-vector length. That can permit a higher speed from the same battery when voltage is the limit; the actual increase also depends on the current and load. before reading on.
Measuring the current
The feedback correction depends on the current readings. Errors in those readings become errors in the current it maintains. The electronics must measure the three wire currents accurately while the same wires are being switched between the battery terminals.
Each wire’s current is measured with a shunt: a resistor of a thousandth of an ohm or so, between the lower switch of the pair and the negative side of the battery. Current through the shunt makes a small voltage across it. An amplifier enlarges that voltage, and a converter turns it into a number. The simulated converter gives a 12-bit number, so its readings come in steps of 24 thousandths of an amp, and each has a little random noise.
A shunt in this position can measure its wire’s current while the lower switch conducts. This controller samples at the start of each period, in the middle of the interval when all three lower switches are on. With these centred pulses, the sample closely approximates the current with the switching ripple removed. The approximation becomes less accurate during rapid changes in current.
A wire whose duty is close to 100% has its lower switch on only briefly, and the amplifier needs time to settle after switching. In this simulation, sampling too soon gives a reading that is too small in magnitude. The three currents add up to zero, so two good readings are enough. The controller leaves out the reading from the wire with the highest duty and works that current out from the other two. The switching pattern must leave enough settling and sampling time for both readings.
At 3700 turns per minute the readings which are left out would have been good ones: the rings in the figure lie on the line. , which is more than this battery can give. The duties now reach their limit, and the rings fall visibly short of the true current.
Measuring the motor first
Current readings tell the controller how far it is from its target. The winding’s resistance and inductance determine the gains used to correct that error. These properties differ from one motor to the next, so the controller can measure them before starting. The next figure runs that procedure; the other figures use the parameters supplied in their settings.
It applies a small voltage vector which turns too fast for the rotor to follow. With little rotor motion, the winding behaves approximately as a resistance and inductance. The ratio of the voltage and current amplitudes gives the magnitude of its impedance: its opposition to an alternating current. At very low frequencies this approaches the resistance. At higher frequencies the inductance increasingly limits the current.
The controller makes four such tests, starting at 2.5 thousand turns of the vector each second and halving the frequency each time. In a fifth test it holds the vector still, and the impedance is the resistance alone. For each test it first doubles or halves the voltage until the current is large enough to measure well and small enough to be safe. The whole sequence takes 0.5 seconds.
The square of the impedance is the square of the resistance, plus a part which grows with the square of the frequency and of the inductance. , and the curve becomes a straight line. The controller fits a line to the four turning tests, and the steepness of the line gives the inductance. The resistance it takes from the test with the vector held still. .
For the simulated motor the resistance comes out 0.7% low and the inductance 1.1% low. Neither test is perfect. The inductance calculation assumes a smoothly turning voltage, while the controller changes it once per switching period. In the final test, the stationary vector pulls the rotor into alignment. The rotor swings as it settles, generating a voltage which changes the measured current. Try or , and the controller measures them in the same way.
Finding the rotor
The current controller also needs the rotor’s angle to place its d and q axes. We supplied that angle in the current-control figure. A shaft sensor could provide it on a real motor, but this controller estimates it from the applied voltage, current readings and winding properties we have just established.
The back-EMF that the controller must overcome also reveals the rotor’s position. Its magnitude is proportional to rotor speed. For forward rotation, its vector points along positive q, a quarter of an electrical turn ahead of the rotor’s field; reversing the rotation reverses the voltage. At 3700 turns per minute the simulated motor’s back-EMF vector is 5.6 volts long.
This controller estimates the back-EMF from the voltage vector it applied and the current which flowed. It subtracts the voltage drops predicted by the winding’s resistance and inductance. The remainder is its estimate of the back-EMF. Errors in those motor parameters also enter the remainder, which is why measuring them matters.
It calculates this voltage balance along its estimated d and q axes. When the axes are aligned with the rotor, the back-EMF lies along q. If they are turned too far ahead, some of the back-EMF appears along d. With an accurate back-EMF estimate, the angle between that vector and q gives the error in rotor angle. The observer uses this error to correct its axes and its speed estimate, so they follow the rotor as it turns.
The figure pushes the estimate 60 degrees off and lets the observer bring it back. : the part of the back-EMF along d jumps up, the axes swing back, and after 7 thousandths of a second the estimate is within 3 degrees of the rotor again. and it still returns.
The observer is only as good as its model. . Its sum now leaves a little voltage along d which is not back-EMF at all, and the estimate settles 10 degrees ahead of the rotor. The current vector is then not quite a quarter of a turn ahead, and a little of the current is wasted. .
The relationship between speed and generated voltage is often expressed as a motor’s speed constant, Kv. Here it is 380 turns per minute per volt of peak back-EMF measured between two wires.
The observer also estimates the rotor’s flux linkage, which describes how strongly its magnetic field links the phase windings. In this model it equals the back-EMF vector’s magnitude divided by electrical angular speed. A larger flux linkage gives more voltage at the same speed, and therefore a smaller Kv. The observer keeps a running estimate of it.
Starting from rest
A rotor at rest generates no back-EMF, and a slow one generates very little. This observer therefore needs the rotor to be moving before it can find its position. The controller starts by turning its own axes, slowly at first and then faster at a steady rate, while holding a fixed current along its q axis. The rotor is pulled round after the current vector, as in the figure of the three coils. During this blind start, the axes follow a planned motion rather than a measured rotor position.
During this stage the controller’s axes are not where the rotor’s are. The rotor trails some way behind the current, at the angle where the torque is just enough to keep up, and it swings back and forth about that angle like a weight on a spring. The next figure shows this from the controller’s axes, with the rotor drawn where it truly is.
The controller hands over when its axes reach the electrical speed corresponding to 670 turns per minute of the bell. If the rotor has kept up, its back-EMF is now large enough to estimate its position. The controller turns its axes in one step to align with that estimate, and lets the observer track the rotor. : at 233 thousandths of a second the change of viewing axes makes the rotor appear to jump onto d. Its physical position remains continuous. The current is now controlled relative to the estimated rotor position. In this run, the requested 2000 turns per minute is reached and held from 324 thousandths of a second.
The current does not rise to its limit at once after the handover. While the back-EMF is still small, a large current would make a voltage across the resistance of the windings much larger than the back-EMF, and a small error in the resistance would then be enough to hide the rotor. The controller lets the current grow only as the back-EMF does.
The blind stage can fail. , which is much harder to get moving. The rotor cannot keep up with the axes. They turn past it again and again, and the error of the angle runs round and round. The observer takes over on a rotor which is hardly turning, and finds too little back-EMF to follow. The controller notices, stops, and starts again. The second attempt succeeds, because the first has left the rotor turning. and the first attempt succeeds. .
From a speed to a thrust
We can now start the motor, follow its rotor and control the torque through q current. To meet the flight computer’s thrust request, we must choose how much q current to ask for.
For a fixed propeller in still air, thrust grows approximately with the square of rotational speed, as does the torque needed to turn it. The simulation uses that relationship: its propeller gives 9.8 newtons at 3700 turns per minute and 13.9 at 4400. With a model or measurements of the propeller, a thrust request can be converted to a speed request.
The speed controller turns that request into a torque. It compares the speed asked for with the observer’s estimate of the speed, and it sets the q setpoint for the current controller: more current to speed up, less to slow down. It is built like the current controller, with a part which acts on the present error and a part which builds up.
The motor’s torque must first overcome the aerodynamic torque resisting the propeller. Any torque left over accelerates the rotor and propeller; their rotational inertia determines how quickly the speed changes. The current limit sets the largest motor torque available. At higher speeds, the available voltage also limits how much current the controller can maintain.
To reduce thrust, the controller can bring the q current to zero and let air resistance slow the propeller, or it can make q current negative and actively brake it. During braking the motor converts rotational energy to electrical energy. When that generated power exceeds the winding and controller losses, current flows back into the battery.
With a q-current limit of 30 amps in each direction, the simulated thrust completes nine tenths of its rise after 40 thousandths of a second, and nine tenths of its fall after 25. On the way up, the measured current briefly falls below its setpoint: the available voltage is insufficient to overcome the back-EMF and raise the current at the requested rate. On the way down, up to 7.4 amps flow back into the battery. , and the same fall takes 88 thousandths of a second. .
A multirotor controls its attitude by changing the balance of thrust between its propellers, so both rising and falling thrust affect how quickly it can respond. Braking current has a separate limit. Abrupt braking can loosen some propeller fastenings, and regenerated energy raises the supply voltage. The battery model here accepts returned current, with a voltage rise set by its internal resistance. A real battery has charging limits; a power supply that cannot absorb current needs another way to handle the returned energy. This controller reduces braking current when the supply rises above 26 volts.
This simulated motor, propeller and battery reach about 4950 turns per minute. At that speed, the voltage needed to keep the current turning with the rotor and overcome the back-EMF and winding resistance reaches the controller’s available voltage. Asking for more speed cannot produce the extra torque.
One control period
All the parts are now in place. In every switching period, which lasts 25 millionths of a second, the controller makes one complete calculation in nine stages.
- Read the three shunts.
- Leave out the reading from the wire with the highest duty, and work that current out from the other two.
- Take the three currents to the stator’s two axes, with the Clarke transform.
- Take them to the rotor’s two axes, with the Park transform, at the estimated angle.
- Work out the back-EMF, and update the estimates of the rotor’s angle and speed.
- Compare the speed asked for with the estimate, and set the q current setpoint.
- Compare the currents with their setpoints, and choose a voltage along each of the rotor’s axes.
- Take that voltage back to the stator’s axes.
- Turn the voltage vector into three duties.
The current readings are taken at the start of a period. The duties calculated from them take effect at the start of the next period and last for the whole of it. In stage 8, the controller therefore uses the predicted rotor angle at the middle of that next period, one and a half periods after the reading. In stage 5 it uses the voltage applied during the period that has just ended.
The next figure follows the numbers through these stages for one switching period of the simulation. The plot shows the q current as the speed asked for steps up. Move the marker to choose a period.
Try it
The last figure runs a short motor test each time a setting changes: a start from rest, a step up in speed and one down, a brief increase in load, and a stop command. The load increase represents a gust by adding a resisting torque for a tenth of a second. The chart shows one view of the test at a time. Drag the time marker, or press play, to pick a moment. The drawing below shows that moment from the controller’s axes: the rotor’s true position, the measured current, the commanded voltage and the estimated back-EMF. The table summarises the run.
The settings mean the following.
- Propeller: its diameter. A larger propeller of the same shape needs much more torque at a given speed, and is much harder to speed up.
- Battery: its voltage with no current flowing. Six cells give from about 25 volts when full to about 20 when nearly empty.
- Driving and braking current limits: the largest q current in each direction.
- Speed gain: how much current the proportional part of the speed controller asks for per unit of speed error. The integral part continues to correct any persistent error.
- Current bandwidth and observer bandwidth: how quickly the current controller and the observer respond.
- Reading noise: the random part of each current reading.
- Resistance told and inductance told: what the controller is told about the windings, as a share of the truth.
Try these changes, starting each comparison from :
- . This supplies the true angle and speed, so it can skip the blind start and reach the first speed in about a third of the time. The later speed steps change little.
- . The step down in thrust takes more than three times as long, and the propeller slows much more slowly after the stop command.
- to 19.8 volts. The step up in thrust takes longer, because the voltage reaches its limit sooner. The other steps hardly change.
- . The effect is the same as that of a weaker battery: less voltage at the top.
- . The angle estimate goes wrong whenever the current is large, most of all just after the start.
- to 20 hertz. Its angle estimate falls behind during acceleration, directing the current away from the angle that produces the most torque.
- to a tenth. The response to a speed error is weaker, and the brief extra load causes about four times as much speed loss.
- . Holding the first speed now takes nearly all the current the controller is allowed, so that speed is reached late, and the higher one is beyond what the motor can turn.
at any time.
What the simulation leaves out
The figures run the controller against a simplified motor model. Its phase back-EMFs are sinusoidal, and its torque is proportional to q current. Inductance is constant and equal along d and q; resistance stays constant as the windings heat. Real motors have magnetic harmonics, saturation, iron losses and temperature changes. These affect torque, efficiency and the accuracy of the controller’s model.
The drive’s d-current setpoint stays at zero. Other drives use negative d current to reduce the total flux linking the windings and reach higher speeds within the available voltage. Motors with different inductances along d and q can also use d current to increase torque per amp.
The switches are ideal as well. Real transistors take time to switch, and each pair must be given a short pause between one switch turning off and the other turning on. That pause distorts the voltage a little, most of all at low speed. The simulated shunts have noise and a limited resolution, but no offset. A real controller measures the offset of each amplifier before it starts.
The propeller model uses fixed thrust and power coefficients for still air. Aircraft motion and changing airflow alter both coefficients. The brief load increase in the last figure is an added shaft torque; the simulation contains no aircraft dynamics or changing airflow.
The battery has a fixed open-circuit voltage and internal resistance. Its voltage falls when supplying current and rises when absorbing current, but it has no model of charge level, temperature or charging limits. The optional position sensor supplies the exact rotor angle and speed.
At the end of a stop, below the speed at which the observer can track the rotor, the controller applies zero voltage with all three wires switched together. This effectively shorts the phases, dissipating the remaining rotational energy in the windings. The braking-current setting governs the controlled slowdown above that point.
This controller has no procedure to detect and take over a rotor already spinning at power-up, no field weakening for higher-speed operation, and no protection against overheating or short circuits. A controller intended for hardware needs those protections and a startup strategy suited to its motor and load.
Sources
The controller is based on ideas used in thiemar/vectorcontrol, firmware for sensorless speed controllers for drone motors. The controller and simulation use ordinary C++, with a simulated motor, propeller, battery and sensors. They are compiled to WebAssembly and run in your browser.
Among the differences, the firmware’s command loop turns a voltage command into a current request using the difference from the previous applied voltage along q; this controller accepts a speed command. The firmware’s observer uses the d-axis voltage residual to correct its angle. This implementation uses the direction of the full estimated back-EMF vector and includes the voltage due to changing current.
The simulated motor uses representative constants for an outrunner of the size used with a 15-inch propeller. The propeller’s thrust and power coefficients, 0.10 and 0.04, are within the range measured for small propellers in the UIUC Propeller Data Site; see J. B. Brandt and M. S. Selig, Propeller performance data at low Reynolds numbers, 2011.
For the motor equations and the roles of d and q current, see Microchip’s field-oriented control application note. Its space-vector modulation section explains the voltage limits. Analog Devices’ Motor Control Feedback Sample Timing describes sampling near the midpoint of a zero vector.
Papers behind the method:
- R. H. Park, Two-reaction theory of synchronous machines: generalized method of analysis, part I, 1929.
- W. C. Duesterhoeft, M. W. Schulz and E. Clarke, Determination of instantaneous currents and voltages by means of alpha, beta, and zero components, 1951.
- H. W. van der Broeck, H.-C. Skudelny and G. V. Stanke, Analysis and realization of a pulsewidth modulator based on voltage space vectors, 1988.
- N. Matsui, Sensorless PM brushless DC motor drives, 1996.
- L. Harnefors and H.-P. Nee, Model-based current control of AC machines using the internal model control method, 1998.
- T. Wang, S. Dong, Y. Tao, Y. Wang and Z. Chen, A high dynamic performance PMSM sensorless algorithm based on rotor position tracking observer, 2015.
Article inspired by the works of Bartosz Ciechanowski.