It wasn’t so long ago when BLDC motor controllers were cumbersome and expensive. Their difficulty to implement, inability to start reliably (without extra position sensing help), and overall cost kept the BLDC option off of the table. The inverters used to drive the windings alone were prohibitive in cost and in size.
Thanks to Moore’s law (and the Power MOSFET derivative of it), the cost and size of these components have dropped dramatically. So much so that folks are looking seriously at those aforementioned applications and thinking positively. When performance and reliability go up, at the same time that costs comes down, the folks that count the pennies begin to smile. I think that we’re there.
There are many microcontrollers that can easily control a brushless motor. Some are more capable than others at doing this task. A lot has to do with their peripherals. Some have the right kind of analog to digital converter controls allowing synchronous sampling of an analog voltage.
Others have dedicated motor control peripherals allowing for efficient Back EMF sensing, proper timing of different key moments in a brushless control algorithm. Since there are several different micros to choose from, we will begin by focusing on the tasks at hand, controlling a brushless motor, and then start getting a bit specific as we get into the design of the controller itself.
Typical motor configurations
A brush-type permanent magnet motor has the magnets in the stator, or the stationary part of the motor, and the windings in the rotor. As the rotor rotates between the brushes, the commutation, or switching from one phase to the next, naturally happens. It’s a mechanical thing. It is a simple and somewhat reliable solution although brushes are the weakest link in the durability « chain. »
Brushless motors are just that, brushless. They have to commutate the windings by some other means other than brushes and commutator bars. We hope to do it using semiconductors. Things are a bit switched around in a brushless motor. In a permanent magnet brushless DC motor, the magnets are in the rotor and the switched, or commutated, windings are in the stator.
|Figure 1. Wye and Delta winding configurations|
This takes a fairly simple design, brushes and commutator bars, and makes it much more complex (resistors, MOSFETs, capacitors, a microcontroller, Voltage regulator), more reliable, easier to use, cheaper and better » we know it will be better… It has to be.
The difference is that a wye wound machine has one end of all of the phases connected together in the middle. If there are three phases then this looks like a « Y »; hence the « wye » nomenclature. A delta wound machine ties the ends together such that, for a three phase machine, the configuration looks like a triangle, or a delta.
Phases and Poles
Phases refer to the number of separate sets of windings in the stator. Within a phase there may be a number of poles. Poles are typically referred to in pairs of 2, 4, 6, 8, or more (or it can be expressed in pole pairs such as 1, 2, 3, or 4 pole pairs).
Each phase will have the same number of poles. In a 3 phase 2 pole motor going around the 360° (electrical) corresponds to the actual or mechanical 360° rotation.
As poles are added, the number of electrical degrees is multiplied to create the same mechanical or rotational degrees. For example, a 4 pole machine will take 720° (360°x2) electrical to obtain one full revolution of the rotor.
Other than this subtle difference, the number of poles does not change how the motor is driven. It only changes the actual speed of the motor with a given « electrical speed. »
Back Electro-Motive Force
Take a brushless motor of any kind, stick an oscilloscope across any two leads and spin the rotor. You will see a periodic voltage oscillating at a frequency proportional to the motor rotational speed (see « Phases and Poles » above).
This is the basic result of passing a winding through a magnetic field (or B-Field). The changing B-field causes a voltage to appear across the windings. This voltage is called Back Electro-Motive Force, Back EMF, or BEMF for short.
|Figure 2. Back EMF voltages in a spinning motor (Top: Three Phases; Bottom: Three Phases Overlap)|
A motor can be wound such that the waveform you get when you spin it is either sinusoidal or more trapezoidal. Figure 2 above illustrates a more trapezoidal configuration. Driving a sinusoidal wound motor with a pure three phase sinusoidal signal provides the smooth control needed for applications like electric power steering.
However, the applications addressed here do not require such finesse. These applications just need to spin at a given speed. A little torque ripple due to not being driven optimally is not a big issue. As a result, this discussion is limited to trapezoidal wound / controlled motors.
Driving the Phases
A trapezoidally driven three phase brushless motor traverses 360 degrees electrical through a six step approach as shown in Figure 3 below. Each phase is driven for 120 degrees electrical then tri-stated for 60 degree electrical.
At any given point, one phase is driven high and another is driven low with the third phase left floating, or tri-stated. That tri-stated portion of the waveform is where the BEMF is transitioning from one polarity to the other. The rotor position information for commutation timing is found during this transition time.
|Figure 3. Driving a three phase brushless motor|
Position Sensing – When to Commutate
Sensing the BEMF generated during normal rotation of the rotor is a « free » solution to knowing rotor position. An easy reference point is where the BEMF transits from one polarity to another, or the « zero crossing point. »
The « zero crossing point » occurs during the 60° electrical time when the phase is floating. Commutation does not occur at this point; rather it is used as a reference point to get a good idea as to where the rotor is positioned.
|Figure 4. A simplified illustration of the three phases of a driven motor.|
The BEMF information used to discern rotor position is essentially the voltage from the center point to the motor lead of the floating phase. To measure this voltage, we have to know what the center point is.
One typical method is to fabricate this neutral voltage by tying three resistors together, one from each phase. Another common method is to tap into the neutral point directly. The method to be discussed here will do something altogether different » and better.
|Figure 5. One phase during normal PWM switching|
As stated earlier, in a trapezoidally driven BLDC motor, at any given moment one phase is pulled high, and other is pulled low while the third is floating and in transition from either high-to-low or low-to-high. If the MOSFET that is pulling the one phase high is chopped, then motor inductance will cause that phase voltage to fall to just below ground as the lower transistor conducts on that phase in the reverse direction (see Figure 6 below).
|Figure 6.Inductance causes the current to continue to flow when the high-side switch is turned off.|
Starting from when the Phase A upper switch is off and the lower switch is conducting from ground (Figure 6 above), the following equations can be generated:
From phase A, we can derive the value of the neutral voltage Vn:
From phase B, we can derive the value of Vn in a different way:
For the unused Phase C we can derive the value of Vn in a third way:
From (1) and (2), we derive a value of Vn that is independent of motor inductance or resistance:
In a balanced three-phase system the sum of the phase EMF voltages is equal to zero:
Incorporating equation (5) into equation (4) yields
Using equations (3) and (6) the terminal voltage Vc can be expressed:
A few observations can be made. First, the voltage seen at VC is zero when the BEMF on phase C is crossing zero. Second, the gain of the BEMF signal is 150% of the actual BEMF.
From this it is apparent that the sensitivity of this sensing method is superior to anything that has to attenuate the sensed voltage prior to bringing it into a control circuit.
The ability to sense BEMF is the key factor in fast and reliable starting. This is the fastest way of starting a brushless motor. With this, you can even drive any higher voltage motor without any signal attenuation.
Figure 7 below illustrates what the micro sees when sensing BEMF in this way. Note that the zero crossing information is well within the 5V range of the micro input.
|Figure 7. BEMF signal sensing at the micro – capped at 5V.|
Since there needs to be an « off-time » to discern the BEMF on the unused phase, the PWM duty cycle is limited to a maximum. This limits the amount of power the motor can deliver since the phases can never be fully turned on.
At this point the BEMF is quite high. During this time, the sensing method can change from sensing only when the upper phase is freewheeling to when the upper phase is on.
This requires dynamically adding a voltage divider on the phase sense inputs and changing the zero crossing reference point (see the « high-side Sensing » block in Figure 8 below). Using three micro ports and three resistors the system can, on demand, begin to attenuate the BEMF signal such that the micro can « read » the unused phase voltage when the high-side switch is on.
This changes the zero crossing point from something close to zero volts (according to Equation 7 above) to something close to half of the battery voltage. If we go back through the equations with the Phase A high-side switch still on, the resulting neutral or center point voltage looks like this:
Now using this new reference point (1/2VDC) when the other two phases are active (one driven high and the other low) and attenuating the phase voltage appropriately, the motor can be driven with no PWM-ing or chopping.
This provides for a full-on condition. Attenuation of the BEMF signal at this point is not critical. The motor is already spinning fairly quickly and generating a healthy amount of BEMF.
|Figure 8. A running motor at full duty cycle.|
Starting a sensorless motor
There is only one minor catch with sensing BEMF to determine rotor position. In order to rotate the motor properly, and in the right direction, the position of the rotor must be known first.
But that information is not available until the rotor is spinning. So, the rotor is pulled into a known position by powering two phases and holding them for a while. This provides a known electrical positioning of the motor.
|Figure 9. Current and motor speed information at start-up.|
From that position, the phases can be stepped blindly as a stepper motor would be but in a way that smoothly accelerates the rotor up to a « sense-able » speed. At that point, the BEMF sensing can be used to determine when to commutate the stator.
Having reviewed the basics of BLDC motor control in Part 1, the design effort can begin.. The first quest is to select a microcontroller. Looking in the marketplace there are several microcontrollers that might be able to do the job.
One comes to mind that has the brushless motor peripheral set built in for just such a task we have before us, the ST7MC family of micros. As a result the following design of a simple brushless motor control will be based on the ST7MC motor control microcontroller and some additional supporting hardware.
Using a different microcontroller will mean some changes in how BEMF is sensed and how different timers are used. In general the same tasks discussed here using the ST7MC can be ported over to other, less adapted to this application, micros.
Even the most basic of control modules have four basic components, brains (a micro), muscles (outputs), senses (inputs), and some sort of voltage regulation (for the micro).
|Figure 10. Basic Three Phase Motor Control Block Diagram.|
This circuit will drive each phase winding bi-directionally, sense zero crossings, discern when to commutate, and then perform the commutation. Other options include taking input commands and translating them into speed or current control information.
To drive the phases bi-directionally, a 3 phase inverter is implemented using FET pre-drivers and 6 MOSFETS. The inverter is the muscles of the system. For the brains, the ST7MC motor control micro was selected.
This micro has a built-in 3 phase brushless controller cell making this job fairly simple to implement. The software passes the cell a few parameters and the cell does most of the work.
|Figure 11.The schematic|
The schematics shown have several things that probably need some explanation. Other stuff such as the reset circuit or the oscillator needs little or no explanation. Each function will be explained as to why it is there and how it will be used to drive a brushless motor.
The ICP Interface provides a method of flashing (programming) the micro while in the application circuit. The Speed command input circuit just buffers the input commanded voltage to protect the micro from adverse or damaging voltages.
This input is designed to interpret a PWM duty cycle so it is connected to an input capture timer pin. There is an op-amp built into the micro for the purpose of sensing over-current (these are realized in pins OAP, OAN, and OAZ). R30 is a current sensing resistor. It is attached to the Inverter low-side MOSFETs .
The inverter is driven by ports MC00 through MC05. These pins are connected to the three FET pre-driver ICs. The motor BEMF voltages are sensed by the ports MCIA, MCIB, and MCIC.
Also included is an external reference voltage set up on MCCREF. Resistors R17-R19 connect the micro directly to the phase outputs for the purpose of sensing the zero crossing events. Resistors R10, 11, and 13 are used switch the type of BEMF sensing – low-side or high-side of the PWM.
The inverter consists of three bootstrap MOSFET pre-drivers, the MOSFETs, and the relevant supporting circuitry. The bootstrap is preferred to a charge pump because a charge pump can inject EMI into a system.
The limitation a bootstrap system has is keeping the upper MOSFET gate charged in DC conditions. For a brushless system, there will always be commutation, and thus, a charging source for the high-side gates.
The Voltage regulator is a simple 5V regulator with a power on reset function. Some extra resistors are placed to provide a battery voltage input to one of the micro’s A to D converter pins.
A 15V zener diode (D6) is needed to protect the L6387 from voltage exceeding 17V. The L6387 supply must not exceed its absolute maximum voltage of 17V. This added protection may not be necessary if a different FET pre-driver is chosen.
The software is broken down into functional blocks depending on what state in the cycle the motor is in. First there is the alignment phase. During alignment, the rotor is forced to a known position. Then, in switched mode, the rotor is stepped blindly like a stepper motor causing the rotor to the ramp-up in speed while BEMF is monitored.
Since the rotor position is not known, it must be placed in a position that can be reliably used as a reference point. The controller aligns the rotor to a known position by powering two phases. That is, by pulling one phase to supply and one phase to ground. There are two things to worry about.
The first is motor resistance. There is very little motor resistance in a non-spinning motor. This translates to a huge amount of current flow and resulting torque, which leads to the second issue.
Too much torque applied all at once can cause the rotor to oscillate as it pulls into position way too quickly. The steady state point of two-phases-on is the lowest torque point in the rotational position.
Pulling a rotor into position too quickly will cause it to overshoot and oscillate. This is especially the case if there is not a lot of friction in the system. Just turning these switches full-on can cause the rotor to oscillate and draw enormous amounts of current.
Depending on the motor / system being driven, the alignment phase is a gradual stepping up of the stator current. This is done by PWM-ing the stator current with an increasing duty cycle until the rotor is in a known position.
This gently moves the rotor into position without a lot of mechanical overshoot / oscillation and limits the current in the motor. If there is a lot of « stick-tion » or static friction in the motor assembly, the algorithm can be modified to provide a high current pulse for a few milliseconds to break the rotor free.
Once the rotor is freed, the current can then be dropped back down and slowly ramped up to the hold position prior to starting. The software routine which controls the alignment ramp-up is
This routine is a two-state state machine. The first state initializes some RAM variables, determines the maximum PWM duty cycle based on battery voltage, and places the motor control cell into direct access mode.
The direct access mode allows setting up the output registers for the starting position. Once the outputs are set to the desired start position, the direct access mode is exited.
The second state of the state machine controls the ramp-up and hold stages of the alignment phase. This part of the state machine increases the PWM duty cycle until the maximum duty cycle is reached.
The maximum duty cycle is maintained until the hold timer expires, ending the alignment phase. This routine is graphically depicted by the flowchart in Figure 12 below.
|Figure 12. Start-up algorithm.|
The BEMF voltage seen on the unused phase can be used to determine how long the alignment time should be. Zooming in on the lower voltage of the unused phase with the oscilloscope will show some dampening oscillations. These oscillations must settle before the micro starts into the « Stepping Blindly » , or switched, mode.
|Figure 13. Start-up alignment phase.|
The PWM duty cycle and the battery voltage are factors that must be considered when determining the alignment time. The battery voltage and PWM duty cycle are inversely related.
That is, with higher battery voltages, the PWM duty cycle should be lower and vice versa. The intent is to minimize the oscillations for a given voltage range. This can be found in the software under the following function:
UInt16 Determine_VBAT_PWM( void )
This function scales the PWM duty cycle based on the battery voltage measured by the A/D converter. The PWM duty cycles for a given range, and the battery voltage points can be adjusted to minimize the alignment oscillations for a given system.
Switched and Auto-Switched Mode
Once the rotor is put into a « known » position, the controller can now start stepping through the phases in a known direction at a predetermined increasing rate continually looking for BEMF. There is a gradual increase in commutation speed as the rotor begins to rotate faster with each step.
At some point, there will be adequate rotation to generate enough BEMF to sense. At that point, the control algorithm can switch from blindly stepping and searching for BEMF to auto-switch mode using BEMF zero crossings as a rotor position reference.
The controller software monitors three events which occur during rotor rotation. These three events are Commutation, Demagnetization, and Zero Crossing. These events always happen in a set sequence.
The Commutation event (C-event) occurs when the controller steps to the next phase. The act of commutating to the next step will cause a voltage spike in the just-turned-off phase to appear due to the winding inductance.
For a low-side driven phase, the spike is positive – a diode above the supply voltage. For a high-side driven phase, the spike is clamped to just below ground. The voltage is limited by the intrinsic diodes of the inverter MOSFETS.
The voltage spike will remain as long as the current in that phase is decaying. The controller waits until this inductive current has dissipated before monitoring this phase for BEMF.
Otherwise, this inductive spike looks like a zero crossing event has already occurred and messes up everything. This wait time is the Demagnetization event (or D-event).
|Figure 14. Relationship between Commutation, Demagnetization, and Zero Crossing Events.|
The next event in the sequence is the Zero Crossing event (or Z-event). The controller monitors the unused phase to determine when the BEMF crosses zero (or near zero) Volts. This event tells the controller where the rotor is.
With timing based on rotor speed, the controller determines when to perform the next commutation (or C-event). The controller repeats the sequence of C-event, D-event, Z-event (and back to C-event) to keep the rotor spinning.
Motor control timing considerations
Before continuing with the explanation started in Part 2 of the switched-mode operation, the timer and timing system for the ST7MC motor control cell needs explanation. All motor timing is driven by one central up-timer/counter clocked via a pre-scaler.
The pre-scaler value is determined by a 2n+1 factor, with n being the pre-scale register value. Therefore, a pre-scaler register value of 4 will select a pre-scale value of « divide by 32 » (24+1) of the peripheral clock.
Once the timer is started, the mechanism to change the pre-scaler value is limited to a single increment/decrement at the time the timer is reset and cannot be directly written by software. This is an important point when discussing the method used to blindly step the motor during the switched-mode.
The central timer is not simply a free running timer. This timer is reset to zero at certain points depending upon the mode of operation: switched mode or auto-switched mode.
During switched mode there are no reliable zero crossing events so the rotor position is not known. As a result the timer is based on and reset by the commutation event interrupt.
Once the rotor is spinning and reliable zero crossing events are occurring the commutation timing is transferred to auto-switched mode. During auto-switched mode the timer is based on and reset by the Z-event controller interrupt
When changing from switched mode to auto-switched mode, special considerations must be made as the timer’s reset point will change between the two modes.
Each of the three events (Commutation, Demagnetization, and Zero Crossing) has a corresponding timing register. These registers are not actual timer/counters but rather contain time values that are related to the central timer.
The timing registers are called timers in the sense that they set or measure a length of time based on the time base of the central timer. The Commutation timer sets a time when the controller should step to the next phase.
When the central timer matches the time value in the Commutation timer, a commutation event occurs. The Demagnetization timer sets a time value when the controller should expect the current in the unused phase to have decayed after a commutation event.
When the central timer matches the time value in the Demagnetization timer, a demagnetization event occurs. The Zero Crossing timer measures a time value when the controller detects a zero crossing event. When a zero crossing event occurs, the value of the central timer when the event occurred is stored in the Zero Crossing timer register.
At start-up, the motor will begin spinning by controlling the active phase and time duration « manually » for each step. A commutation event will occur when the programmed step time has elapsed.
At that point the central timer is reset and a new value is loaded into the commutation timer register. The Demagnetization event will then occur based on the time loaded into the demagnetization timer.
The demagnetization timer will simply be loaded with one-forth of the time value used for commutation which should be more than adequate for most applications. The interrupt service routine:
@interrupt void MTC_C_D_IT(void)
manages both the Commuation and Demagnetization Events.
Two tables are used to determine which phase outputs are active and how long each step will take:
const UInt8 PHASE_CONFIG[ PHASE_CONFIG_SIZE ]
const Step_s RAMP[ STEP_RAMP_SIZE ].
The PHASE configuration table contains six steps. Each step defines which two phases are driven and which phase is used to sense BEMF. The order of the elements in the PHASE_CONFIG table are reversed to make the motor spin in reverse.
Once the central timer is started, the pre-scaler adjustments are limited to one count (either up or down). This puts some limitation on the RAMP table. RAMP table pre-scale values cannot change more than one count between table entries.
The actual step time is calculated based on the peripheral clock speed, the pre-scale value, and the time value to be loaded into the commutation timer. The example used assumes a 4MHz peripheral clock.
The step pre-scaler (ratio setting) is set to 6. This provides a time-base of 32 microsecond/count with the timer ((26+1)/4MHz). The first time value of the ramp table is 150. This calculates to a first step time of 4.8ms (150 x 32 microseconds).
The ramp table uses a constant pre-scale value to make the step time calculations easier. The pre-scaler value may need to be changed (usually deccremented) if the motor needs to be stepped faster, requiring a finer time scale.
The ramp table in the example has an exponentially faster progressing step times. The « shape » of the ramp table may either be linear, exponential, or something in between. Some experimentation may be necessary to determine what table shape works best for the target motor.
During the switched mode, the PHASE and RAMP tables are independently stepped through. The Commutation timer is loaded with the step time from the RAMP table and determines if the pre-scaler needs to be adjusted from the pre-scaler values of the same table. The Demagnetization timer is loaded every time a C-event occurs with one-fourth of the commutation time.
Since the RAMP and PHASE tables are of differing sizes, each table is individually tracked. The PHASE table is looped as the phases driven in a repeating pattern. The RAMP table is stepped through until a reliable BEMF is detected.
If the end of the RAMP table is reached and suitable BEMF has not been detected, then a serious error has occurred. Typically, BEMF is detectable within 3-5 steps of the RAMP.
During the first four steps of the RAMP table, any BEMF detections are ignored. This is to prevent spurious BEMF zero crossing events from being counted. After the fourth step of the RAMP, the zero crossing interrupts are enabled.
The number of zero crossing events to be ignored is based on the motor driven, some experimentation may be necessary – just as some motors will require more speed to obtain a reliable zero crossing point than others.
Therefore, the RAMP table step time, acceleration rate, and the number of ignored zero crossings will need to be optimized for a given motor.
The interrupt routine:
@interrupt void MTC_R_Z_IT(void)
manages the Zero Crossing Event.
During the switched mode of operation the Z-event interrupt routine counts the number of zero crossings detected and the C-event interrupt also checks for a Z-event for every C-event.
If the Z-events are not consecutive, the C-event interrupt clears the zero crossing counter and the entire process begins again. Once 12 consecutive zero crossings have been detected, the process of changing to the auto-switch mode begins.
The process to enter the auto-switch mode occurs over two steps. The first step prepares for the change to the auto-switch mode, and it prepares to switch the central timer over the control of the zero crossing time.
When the minimum number of required consecutive zero crossings have occurred, the commutation timer is adjusted to place the next commutation event half way between the next zero crossing time. This is due to the change over in the way the central timer is reset.
As stated above, while in the auto-switched mode,, the central timer is reset on each zero crossing event, just after storing the central timer value of when the zero crossing occurred.
The second step actually enables the auto-switched mode and performs some final housekeeping duties. These housekeeping activities include resetting a stabilization counter, setting the commutation weighting factor register to a fixed value, and initializing the zero crossing time buffer.
Once in the auto-switched mode, the zero crossing event interrupt routine simply maintains the last six zero crossing time values in a circular buffer. Since there are six steps in one electrical revolution, the buffering of the last six zero crossing times will make it possible to determine the rotational speed of the motor.
The stabilization timer is used to allow the motor to run a few rotations to stabilize before the duty cycle is allowed to be changed, resulting in a motor speed change. The commutation weighting factor register is used to determine what percentage of the zero crossing time is used to delay a commutation event.
The commutation delay value can vary with motor speed and can be adjusted based on the information contained within the zero crossing time buffer. The delay values and any variations with motor speed will depend upon the target motor.
Most of the work for the auto-switched mode is done during the commutation event. The commutation event must also manage the demagnetization time. This is performed by an index into a software demagnetization table. This table is constructed using the central timer pre-scaler value as an index.
For a given pre-scaler value, the software demagnetization time is added to the commutation time. Typically, a motor will require less demagnetization time as the motor spins faster (lower pre-scale value) because the current is lower.
The commutation event must also check for an overflow of the demagnetization time. Once the demagnetization time has been calculated, the commutation interrupt routine sets the commutation delay register to determine the next commutation time based on the current or previous zero crossing.
The example software is designed to accommodate an asymmetrical motor with respect to zero crossing times. The commutation event interrupt routine checks for the next zero crossing direction (rising or falling) and compensates accordingly.
The commutation event interrupt routine loads the next commutation weighting factor based on the zero crossing direction. The actual calculation of the weight factor value is performed outside of the event to save time in the commutation event handler. The routine to calculate the weighting factor is
void Set_Duty(UInt16 duty)
The Set_Duty function waits until after the stabilization time and then starts to calculate the commutation weighting (delay) factors based on the current motor speed. The routine segments the motor speeds into five areas.
For a starting point with a target motor, the areas can be divided equally along the motor’s full operating speed range with a common weighting factor for all ranges. From this point, any speed dependencies can be observed and the speed ranges adjusted.
To adjust the weighting factor to their optimum values, the motor phases are monitored. The ideal waveform is to have the trapezoidal waveform symmetric about its center. The motor speed is changed to enter into one of the desired speed ranges and the waveforms monitored. The rising and falling weighting factors are changed as necessary to make the waveforms balanced or symmetric.
The final aspect in the auto-switched mode is the pre-scaler adjustment. The motor control cell automatically adjusts the pre-scale value based on the value of the zero crossing time. The motor control cell attempts to keep the zero crossing time somewhat in the middle of the zero crossing range.
If the zero crossing time gets to be too large, the motor control cell increments the pre-scaler value to divide the zero crossing time in half. Similarly, when the zero crossing time is too small, the motor control cell will decrement the pre-scaler value to multiply the zero crossing time by two.
This happens automatically without software intervention. An interrupt routine can be triggered when the pre-scaler is adjusted to allow any other zero crossing/pre-scaler based times to be adjusted as necessary.
At this point, the motor is basically being controlled automatically by the zero crossing, demagnetization, and commutation event handlers.
Tuning and Debugging Considerations
The motor control cell has the capability to echo the status of the commutation, zero crossing, and demagnetization events. Unfortunately, the pin locations for these signals are fixed by hardware and frequently overlap with other board functions.
The solution is to use two general purpose I/Os pins and use a few lines of software to relay the information to the pins. The commutation and demagnetization events use a single pin and the zero crossing event has its own pin.
For the commutation/ demagnetization pin, the idea is to set the pin high when a commutation event occurs and clear the pin low when a demagnetization event occurs.
When the commutation/ demagnetization pin is shown on an oscilloscope with a phase voltage signal, it is simple to determine if enough or too much demagnetization time being allowed for that motor speed.
The falling edge of the commutation/ demagnetization pin must occur after the actual motor demagnetization event but not so long that the zero crossing detection is significantly delayed.
The zero crossing pin needs only to change its level each time a zero crossing event occurs. This will provide an indication as to when the zero crossing is occurring with respect to the commutation and demagnetization events.
These pins are vital when tuning a motor for the first time. During the switched mode phase of the motor start-up, the commutation events can be seen via these signals.
These events are directly related to stepping through the RAMP table. The acceleration will be seen as continually shortening steps in the table. The demagnetization time can also be seen as the motor is being accelerated. The zero crossing events should start to occur within a few steps of the ramp table.
If the zero crossings do not occur, perhaps the motor is not being accelerated fast enough to generate enough BEMF to be detected. Once the zero crossing events are being detected, they should coincide consistently with the commutation events. If the zero crossings are somewhat inconsistent, perhaps the motor is being accelerated too fast.
When using debugging software, it is important to note that once the motor is spinning, breakpoints should not be used. If breakpoints are used while the motor is spinning, the code execution will be stopped and the motor will no longer step through the phases. This may leave the system with the output drivers active and draw large amounts of current, possibly destroying the driven MOSFETs.
With this, we have a complete sensorless brushless motor control system. Until now, most people thought that sensorless brushless commutation could only be done using a 16 bit or 32 bit machine.
Designers today are being surprised at how inexpensively they can implement sensorless brushless control using a low cost 8 bit machine. The magic is in the micro’s motor control peripheral. The result is a cost-efficient sensorless brushless control system that works reliably over a very large speed range.
David Swanson is a principal engineer in the Automotive Business Unit of STMicroelectronics. He has a BSEE from North Carolina State University and holds several automotive-related patents. Kurt Perski is a Microcontroller Field Applications Engineer with STMicroelectronics, whose professional interests focus on embedded software design.