DSCs Enable FieldOriented Control for Washer Motors
When used in an appliance, a permanent magnet synchronous motor (PMSM) provides very good efficiency because of its constant rotor magnetic field, which is produced by a permanent magnet on the rotor. In addition, its stator magnetic field is generated by sinusoidal distribution of the windings. Compared to induction motors, PMSMs have a very high power/size ratio. They also produce less electrical noise compared to dc motors since brushes are not used.
In PMSMbased appliances, fieldoriented control (FOC) offers a great cost benefit because it eliminates the position sensors. The sensorless FOC technique also overcomes restrictions placed on some applications that cannot deploy position or speed sensors, such as those in which the motor is immersed in oil. Although proprietary FOC designs using ASICs are available, a new generation of digital signal controllers (DSCs) offer a lowcost alternative for implementing the FOC algorithm.
DSCs are suitable for appliances like washing machines because they feature peripherals tailored for motor control such as pulse width modulators (PWMs), analogtodigital converters (ADCs) and quadrature encoder interfaces. When executing controller routines and implementing digital filters, DSCs help designers optimize code execution by being able to carry out the multiplyaccumulate instructions and fractional operations in a single cycle. Also, for operations requiring saturation capabilities, DSCs help designers avoid overflows by offering hardware saturation protection.
DSCs need fast and flexible ADCs for current sensing, a crucial function in motor control. For example, the Microchip dsPIC DSC family features ADCs capable of converting inputs at a 1Msample/sec rate and handling up to four inputs simultaneously. Multiple trigger options on the ADCs enable the use of inexpensive currentsense resistors to measure motor phasewinding currents. Triggering ADCs with PWM modules enables inexpensive currentsensing circuitry, by sensing inputs at specific times where switching transistors allow current to flow through the currentsense resistors.
Development Tools
The FOC motorcontrol firmware discussed in this article was developed based on Microchip's dsPICDEM MC1 Motor Control Development Board.^{[1]} Microchip's data monitor and control interface (DMCI) tool, which is a module within the MPLAB Integrated Development Environment (IDE), was used to test and debug the FOC algorithm. The DMCI tool provides a quick and dynamic IDE, which allows designers to graphically represent the application feedback. For instance, DMCI's IDE provides projectaware navigation of program symbols (variables) that can be dynamically assigned to any combination of slider, direct input or Boolean controls. These controls can be used interactively to change the values of program variables within the DMCI IDE. Further, the graphs can be dynamically configured for viewing programgenerated data.
In the system overview block diagram (Fig. 1), it can be seen that no position sensors are attached to the motor shaft. However, there are some sensors used for current measurements on the motor. These sensors feature lowinductance resistors that are part of the inverter function block. A threephase inverter stage drives the motor windings (Fig. 2).
The FOC Algorithm
The following is a stepbystep summary of the FOC (or vectorcontrol) algorithm:

Measure the stator currents phase currents i_{A} and i_{B}. Calculate i_{C} from the fact that i_{A} + i_{B} + i_{C} = 0 and calculate the currents from the two current sensors.

Convert the set of these threephase currents onto a twoaxis system. This conversion provides the variables i_{α} and i_{β} from the measured i_{A}, i_{B} and i_{C} values; i_{α} and i_{β} are timevarying quadrature current values, as viewed from the stator's perspective. This step is called Clarke Transformation.

Rotate the twoaxis coordinate system to align with the rotor flux, using the transformation angle calculated at the last iteration of the control loop. This conversion provides the i_{D} and i_{Q} variables from i_{α} and i_{β}. Now, transform the quadrature currents, i_{D} and i_{Q}, onto the rotating coordinate system. During steadystate conditions, i_{D} and i_{Q} will remain constant. This step is called the Park Transformation.

Error signals are formed using i_{D}, i_{Q} and reference values for each. The i_{D} reference controls rotormagnetizing flux. The i_{Q} reference controls the torque output of the motor. The error signals are input to proportional and integral (PI) controllers. Then, the PI controller's output provides V_{D} and V_{Q}, which is a voltage vector that will be sent to the motor.

Estimate the new coordinate transformation angle, where V_{α}, V_{β}, i_{α} and i_{β} are the inputs. The new angle guides the FOC algorithm as to where to place the next voltage vector.

Rotate the V_{D} and V_{Q} output values from the PI controllers back into the stationary reference frame, using the new angle. This calculation provides new quadrature voltage values, V_{α} and V_{β}.

Transform the V_{α} and V_{β} values back to threephase values V_{A}, V_{B} and V_{C}. The threephase voltage values are used to calculate new PWM dutycycle values that generate the desired voltage vector. The entire process of transforming, PI iteration, transforming back and generating PWM is shown in Fig. 3.
Sensorless FOC for PMSMs
The sensorless control technique implements the FOC algorithm by estimating the position of the motor without using speed or position sensors. Fig. 4 shows a simplified block diagram of the positionestimator function. The FOC algorithm is executed at the same rate as that of the PWM dutycycle algorithm. In the FOC algorithm, the PWM triggers two respective ADC conversions for the two windingcurrent shunt resistors. Then a potentiometer is used to set the reference speed of the motor. The ADC interrupts generate the data samples needed to execute the algorithm.
From the motor model in Fig. 5, the input voltage can be obtained:
And solving for i_{S} gives the motor current:
where i_{S} equals motor current vector, v_{S} equals input voltage, e_{S} equals backEMF vector, R equals winding resistance and L equals winding inductance.
In the digital domain, this equation becomes:
Again, solving for i_{S} yields:
Current Observer Model
A current observer model enables the indirect measure of the back EMF by ensuring that the input to the system (motor) is equal to the input to the motor model. Here is how it works: The motor and motor model are fed with the same input, but the motor model has a closedloop controller to ensure that the estimated value matches the measured value. For example, at any given time, if the actual motor input voltage and current are the same as the model, then we can “observe” the back EMF by solving for e_{S}.
For the observer model compensation, a slidingmode controller can track the input reference and force the error to zero between the measured current i_{S} and the estimated current i_{SESTIMATED}. Depending on the error sign, the slidingmode controller will apply either a positive feedback gain (K) or a negative feedback gain (K) to get the estimated current to match the measured current. Because the input voltages are the same for both the motor and its model, the back EMF can be calculated when the estimated and measured currents match.
BackEMF Estimation
Once the input currents and voltages of the model and the actual motor match, the correction factor z from the motor model can be filtered to get the back EMF. For this step, we use a firstorder digital lowpass filter, with the equation:
To filter z to get e_{SESTIMATED}, we substitute the value of f_{PWM} in the equation below:
where e[n] equals the next estimated backEMF value, e[n1] equals the last estimated backEMF value, f_{PWM} equals the PWM frequency at which the digital filter is being calculated, f_{C} equals the cutoff frequency of the filter and z[n] equals the unfiltered back EMF, which is output from the slidingmode controller
Solving this equation for e[n] yields the updated backEMF value. The value of the cutoff frequency can be determined through trial and error, depending on the selection of the slidingmode controller gain. The relationship between back EMF and the rotor's updated position is given by:
Speed Calculation
Due to the filtering function applied during the theta calculation, some phase compensation is needed before the calculated angle can be used to energize the motor windings. The amount of theta compensation is dependent on the rate of change of θ_{ROTOR}, or the speed of the motor (ω_{ROTOR}). The compensation for θ_{ROTOR} is performed in two steps: First, the speed of the motor is calculated based on the uncompensated theta calculation; second, this speed is used to calculate the amount of compensation. The speed can be calculated by summing θ_{ROTOR} values over M samples, and then multiplying the summed values by a constant. This is given by:
where ω_{ROTER}[n] equals angular velocity of the motor, θ_{ROTOR}[n] equals current rotor position value, θ_{ROTOR}[n1] equals previous rotor position value and K equals amplification factor for desired speed range.
Motor Startup
Because the sensorless FOC algorithm is based on the backEMF calculation, the motor needs to run at a minimum speed to get the backEMF value. Therefore, energizing motor windings with the appropriate estimated angle is required. To handle this, a motor startup subroutine was developed and works as follows: When motor is at standstill, and with the start/stop button pressed, the dsPIC DSC generates a series of sinusoidal voltages to set the motor spinning. While the motor spins at a fixed acceleration rate, the FOC algorithm controls the currents i_{D} and i_{Q}. The value of θ is incremented based on the acceleration rate.
Software State Machine
It is helpful to visualize the FOC algorithm as a software state machine (Fig. 7). First, the motor windings are deenergized and the system awaits the user to press the start/stop button. Once the user presses the start/stop button, the system enters the initialization state where all variables are set to their initial value. Then, the startup subroutine is executed. The current components for torque (i_{Q}) and flux production (i_{D}) are being controlled by the FOC, and commutation angle (θ) is being generated in a ramp fashion, to get the motor spinning and reaching the minimum speed required to run the estimator.
After going through the startup subroutine, the system switches over to sensorless FOC control, where the speed controller is added to the execution thread, and the slidingmode controller (SMC) starts estimating θ, as previously explained.
Upon entering the sensorless FOC control state, the reference speed is continuously read from an externally connected potentiometer, and the start/stop button is also monitored to determine whether or not to stop the motor.
In addition to the stop/start button being pressed while the motor is running, any fault in the system will cause the motor to stop and return to the “motor stopped” state. The motor remains stopped until the start/stop button is pressed again.
DSCBased FOC Control
A major advantage of deploying DSCs in motor control is the practicality of a common design platform, which can lower production costs. This means appliance makers now have an economical way to offer a range of appliance models that use PMSMs, or other motor types, with sensorless FOC algorithm control. These softwarebased motorcontrol designs enable rapid customization to address multiple applications.
Firmware IP protection is a major issue for manufacturers with design teams across many geographies. Design teams based in different locations could work in tandem to implement FOC firmware, develop the appliance front panel and complete the final system integration. Furthermore, in developing their designs, these teams will generate their own IP. Microchip's dsPIC DSC family offers the CodeGuard feature,^{[2]} which helps to protect IP in collaborative design environments by securing IP segments separately.
Since programming DSCs is similar to programming microcontrollers, appliance designers can quickly design their motorcontrol algorithm and test their prototypes. Best of all, finetuning the motor control has been simplified through the use of IDEbased tools such as the DMCI, which allows designers to easily port their algorithms across a variety of motor platforms including PMSM, brushlessdc, brusheddc and acinduction motors.^{[3]}
References

The dsPICDEM MC1 Motor Control Development Board is available at www.microchipdirect.com.

See www.microchip.com/codeguard for information on the CodeGuard security feature, including how it can be used to improve IP protection.

See www.microchip.com for application notes on motor control of ac induction (AN984, AN908 and GS004) and brushless dc (AN901, AN957, AN992, AN1017) motors, based on the dsPIC30F motorcontrol family.