{'fraction_non_alphanumeric': 0.027189233427298353, 'fraction_numerical': 0.013480949349822679, 'mean_word_length': 4.564002023779408, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
FPGA-Based Hybrid Stepper Motor Drive System Design by Variable Structure Control

A stepper motor is usually operated in position open-loop control for simplicity. However, in order to improve the transient and steady-state performances of the stepper motor-based drive system, a high performance stepper motor drive system is usually designed to feed the encoder signal back to form a closed-loop system such as a general servo motor drive, and high-performance position and speed loop controller can then be used to overcome the nonlinear characteristics of the motor, such as the cogging force and impacts from external load. On the other hand, the existed cogging force of the hybrid stepper motor must be solved to increase the positioning precision. The variable structure control (VSC) is insensitive to the bounded uncertainty and load disturbance, and has been known as a high-performance controller. A predeﬁned sliding surface is used to shape the system performances, and incorporate with switching control to achieve the robustness property. Thus, we applied the VSC to implement the stepper motor drive system about the position and speed control, and the switching control is used to overcome the cogging force. The ﬁeld programmable gate array (FPGA) is a good alternative to be used to realize a motor drive system by considering its programmable ability and diverse designing environment. It is easily developed as an intellectual property (IP) for future use or combined as a part of a large control system. This paper showed the procedures to develop the hardware circuits for the variable structure controller, and applied it to stepper motor position and velocity control. Functions such as PI controllers, dq-axis transformation and two-phase space vector space vector modulation (SVPWM) designed for the stepper motor drives are also shown in the paper. The system simulation and hardware circuit realization are based on MATLAB/Simulink, and realized on Altera FPGA. Simulations on MATLAB/Simulink with trapezoidal velocity proﬁle command, and experiments with and without the load added are shown to demonstrate the hardware performances and correctness.


Introduction
Considering the advantages of low cost, high precision, and high torque output, stepper motors are frequently used in the field of high-precision control. Traditional openloop control can lead to momentary step loss or position error when the load changes. As a result, the stepper motor drive system for position and speed control loops has been gradually enhanced as a closed-loop control [1][2][3][4][5]. In Ref. [1], PI controllers are applied for the current and speed closed-loop control, and P control for the position control loop. For Ref. [2], the closed-loop control structure and PI controllers with motor parameter identification are applied to the current and position control of a two-phase bipolar hybrid stepper motor. Furthermore, feedforward compensation is used for the damping control such that the motor can be operated at a high speed range. The authors of Ref. [3] adopted the fuzzy-sliding mode observer to estimate the motor velocity and fed it back as a speed closed-loop system. In that system, PI controllers are used for the stationary A-B phase current control. In Ref. [4], the authors proposed a wide speed range closed-loop-control 2 of 18 drive system, and implemented by a field programmable gate array (FPGA) chip. For low-speed operation, the speed control loop is bypassed, and for the high-speed operation, the field-weaken vector control is used to reach the desired performance. Regarding Ref. [5], it proposed a simple torque control method with shaft-position feedback to correct the load angle, and was also realized by FPGA. In Ref. [6], the PID controller and feedforward control are applied to the stepper motor current control to guarantee the desired current response.
For most of the AC motor drive systems, such as induction motor (IM) and permanent magnet synchronous motor (PMSM)-based systems, vector control is widely used. For such systems, a three-phase modulator is usually used to generate the desired d-axis and q-axis voltages. Clarke and inverse Clarke matrices are used for the transformation between the three-phase and two-phase systems. For a two-phase hybrid stepper motor, it only needs a two-axis modulator mainly made by two H-bridge inverters to convert the DC bus voltage into a pair of quadrature voltages for the two stator coils. Thus, the stepper motor drive system can be operated without executing the conversion of a three-phase stationary (a-b-c) coordinate system into two-phase stationary (α, β) coordinate system. Regarding the vector control for the stepper motor drive system, for the implementation of the vector control in the stepper motor, only Park and inverse Park matrices are required.
The cogging force of the hybrid stepper motor affects the accuracy of positioning. Moreover, for the vector control protocol, the coordinate transformation requires the position feedback to convert the stationary αβ-axis signals into synchronous rotary dq-axis signals. For a closed-loop stepper motor drive system, a high-precision incremental encoder can be used to improve the positioning accuracy. However, the coordinate transformation performs the sin/cos calculation. This requires the position feedback, and the resolution of the sin/cos table holds the precision of the transformation. Additionally, a high-resolution position feedback by incremental encoder is hard to produce the same resolution of voltage generation because of the precision limitations of the space vector pulse width modulation (SVPWM) hardware system, and that leads the current control to not be as precise as the position control loop. As a result, a high-performance variable structure controller is used to improve the positioning accuracy regarding the existence of the problems mentioned above. The variable structure control (VSC) has the advantages of insensitivity to parameter changes, external interference suppression and fast dynamic response [7]. The VSC or sliding mode control (SMC) has been widely applied to single-motor drive design [8][9][10], or designed for a system such as Ref. [11] which is applied to the balance control of a two-wheel vehicle system. For systems controlled by VSC, some steps are included into the design procedure. First, a mathematic model for the control system is presented. Second, a sliding surface or switching surface which dynamics is equivalent to the desired system performances is made. Third, a control law to guarantee the existence of the sliding mode is made. Sometimes, a VSC system exists in the reaching phase and sliding phase, and the system performance is guaranteed on its sliding phase but not on its reaching phase [7,8]. Furthermore, finding an easy way to shape the desired system dynamics is also important for VSC systems. Thus, for the proposed algorithm, the design procedure of a stepper motor drive system is demonstrated step by step. The controlled system is first represented into state space form, and the linear state feedback control method is applied to find the desired system dynamics and switching surface. Finally, a control law which combines the linear control and VSC is designed to make the sliding condition occur.
Hardware circuits realized by field programmable gate array (FPGA) have the benefit of fast prototyping with digital structure, verified with ease. In addition to associating with some of the high-level programming languages, such as C/C++ or MATLAB/Simulink, control systems designed and represented by hardware description language (HDL) are easily achieved. Furthermore, owing to the development of high-density and high-performance FPGA [12][13][14], hardware controllers implemented by FPGA are widely obtained. Some examples include the design of velocity estimation [15], virtual anemometer [16], PID controller [17] and fuzzy controller [18]. FPGA is also suitable for the control system realization of power electronic circuits [19]. In this paper, we first constructed the mathematical model of a hybrid stepper motor and its drive control system in Simulink [4,9]. Next, the models of the controllers were then digitized to be converted into Verilog HDL codes to meet the requirements of hardware design resources. Finally, the designed hardware circuit was used to implement the position, speed and current control to illustrate the correctness of the hardware circuit design and the performance of the variable structure controller. The performances are mainly demonstrated by a 4-ch digital oscilloscope with logical input. The main contributions of the proposed model are based on the state space motor model to the position and speed control, and the applied variable structure controller reaching the desired position and speed performance. The current loop is based on a two-phase vector control strategy where the d-and q-axis loops are controlled separately. The designed system was successfully implemented on FPGA and evaluated by hybrid stepper motor control platform.
The further contents of the paper are as follows: in Section 2, the modeling of the hybrid stepper motor is shown, and the variable structure controller for position/speed control is introduced. Section 3 gives the position variable structure controller design. The simulations on MATLAB/Simulink platform of the proposed are given in Section 4. The experimental setup and results are shown in Section 5. Finally, Section 6 contains the conclusions.

Mathematic Model of Two-Axis Hybrid Stepper Motor
The electrical circuit equivalent for the two-phase hybrid stepper motor is: where v a is the voltage of the coil a, v b is the voltage of the coil b, i a is the current of the coil a, i b is the current of the coil b, R is the coil resistance, L is the coil inductance, K e is the motor back-EMF constant, ω m is the mechanical speed of the motor, N r is the number of rotor teeth, and θ m is the rotor position. The equivalent circuit of the two-phase hybrid stepper motor is shown in Figure 1.
high-performance FPGA [12][13][14], hardware controllers implemented by FPGA are widely obtained. Some examples include the design of velocity estimation [15], virtual anemometer [16], PID controller [17] and fuzzy controller [18]. FPGA is also suitable for the control system realization of power electronic circuits [19]. In this paper, we first constructed the mathematical model of a hybrid stepper motor and its drive control system in Simulink [4,9]. Next, the models of the controllers were then digitized to be converted into Verilog HDL codes to meet the requirements of hardware design resources. Finally, the designed hardware circuit was used to implement the position, speed and current control to illustrate the correctness of the hardware circuit design and the performance of the variable structure controller. The performances are mainly demonstrated by a 4-ch digital oscilloscope with logical input. The main contributions of the proposed model are based on the state space motor model to the position and speed control, and the applied variable structure controller reaching the desired position and speed performance. The current loop is based on a two-phase vector control strategy where the d-and q-axis loops are controlled separately. The designed system was successfully implemented on FPGA and evaluated by hybrid stepper motor control platform. The further contents of the paper are as follows: in Section 2, the modeling of the hybrid stepper motor is shown, and the variable structure controller for position/speed control is introduced. Section 3 gives the position variable structure controller design. The simulations on MATLAB/Simulink platform of the proposed are given in Section 4. The experimental setup and results are shown in Section 5. Finally, Section 6 contains the conclusions.

Mathematic Model of Two-Axis Hybrid Stepper Motor
The electrical circuit equivalent for the two-phase hybrid stepper motor is:  The generated torque output without considering the component of cogging torque is: where J m is the inertia of the motor, B m is the viscous friction coefficient of the motor, T L is the load torque, and T L = T L + F c sin(4N r θ m ) is the lumped total load for the dynamical control system.
To construct the mathematical model of the hybrid stepper motor with MATLAB/ Simulink, Equations (1) and (2) can be rewritten as: From Equations (4)-(7), the built models by MATLAB/Simulink are shown in Figure 2, where the blocks "Ia" and "Ib" are equivalent to Equations (6) and (7); cos_sin block is used to generate the sine and cosine functions, and the blocks "Te" and "Wm" are used to realize Equations (4) and (5).

Variable Structure Control
In the following, the variable structure controller will be used as the main controller for the position and speed control.
A single-input linear system under nominal condition is expressed in a controlled canonical form as: where x is the system state, u is the scalar control input, and A and b are with the appropriate range matrices. The control law u by variable structure system can be divided into two parts: the linear part L u and the VSC part VSC u . First, let the nominal system be under linear state feedback control; we can easily have the control gain, T k to

Variable Structure Control
In the following, the variable structure controller will be used as the main controller for the position and speed control.
A single-input linear system under nominal condition is expressed in a controlled canonical form as: where x is the system state, u is the scalar control input, and A and b are with the appropriate range matrices. The control law u by variable structure system can be divided Some techniques such as the pole placement or linear quadratic method can be used to determine the value of k. Under the condition of a closed loop control, from [7], (8) can be expressed as: Next, the sliding surface of the variable structure controller is defined as: and c is a constant vector. For the closed-loop system (10) under nominal conditions, for any initial value x 0 , σ(x, t) = 0 for t ≥ 0; i.e., the system states are initially on the sliding surface and will stay on it for all the next proceeding time. However, for a perturbed system, the linear control element (9) may not make the sliding condition exist. We require additional control to make and keep the states on the sliding surface. The additional control law is defined as: where sgn(·) is the sign function, and q is a positive scalar constant. Then, the combined control law for the designed system is: To determine the quantity of q, it must be chosen to satisfy the sliding condition, Thus, the desired closed-loop dynamics for the perturbed system can be obtained even though the perturbations exist.

Position Control by State Feedback and Variable Structure Control
The vector control methodology is used for the motor drive system design, the Park transformations between the stationary reference frame to synchronous rotation reference frame for winding voltages and currents are, respectively, defined by: and where v d , v q , i d and i q are direct voltage, quadrature voltage, direct current, and quadrature current in synchronous rotation reference frame. Applying Park transformation to the state-space equation yields new state-space equation as follows: With the vector control assumed, the instant motor generated torque by stator coil current can be expressed as: Applying the state feedback position controller design, the system model is first described in the state variable form, as shown in (20): For a desired rotor position θ d , we first define two new variables, z 1 and z 2 as: where z 1 is the position error, and z 2 is its derivative. Substituting (19) and (21) into (20), the dynamic error equation for position control can be obtained as (22): where a = B m /J m and b = K m /J m , the matrix A and vector b of (8) are: The pole placement method is used to design the position control system characteristics. At first, we do not have to consider the uncertainty and interference. The feedback gain k of (9) is selected for the nominal condition system. The desired system characteristic equation is shown in (24), where a and b are defined in (23), in which case the poles of the system are located at: At first, by appropriately selecting k 1 and k 2 in (24) to meet the requirements, such as the damping ratio, ξ, and rise time, t r [20]. Second, the sliding surface can be yielded by Equation (11). The matrix A c in (11) is the equivalent system matrix under linear state feedback control gain k. The constant vector c T can be simply determined by choosing c T b = 1. Since the matrix b of the two-phase hybrid stepper motor system is b T = 0 b , c can thus be set as: The VSC compensation part, −qsgn(σ), is used to overcome the parameters' uncertainties and external interferences, including the load and cogging torque. For a motor position control system, the form of the total disturbance p is p T = 0 p , so the value of q should be set to satisfy the requirement: where |p| max is the upper bound of total perturbation. Note that, with the constraint of (27), the designed system is stable and robust to a bounded uncertainty and load.

Computer Simulation and Results
Simulations are based on MATLAB/Simulink platform to verify the system performance. The parameters of the two-phase hybrid stepper motor used in the simula-tion are listed in Table 1. Two kinds of command are assumed: (a) position step input, (b) motion control with trapezoidal speed profile limitation. The step input command is 0.628 radian. The motion command includes the acceleration segment, deceleration segment and constant speed, and total angular displacement 0.628 radian in the duration time 0.7 s. Substituting the parameters shown in Table 1 into (22), the control gain k T = k 1 k 2 = 15 0.4 is chosen such that the resulting second-order system (23) possesses the performances of damping ratio 0.707 and rising time 0.05 s. Thus, the linear control law u L and sliding surface σ are determined as: and

Rated current
According to (28) and (29), and with the setting, where q 0 and q 1 are two positive constants for the VSC control part. The schematic block diagram of the Simulink model of the variable structure controller and the structure of the drive system are shown in Figure 3.  The system shown in Figure 3 includes the linear state feedback and variable structure control for the position/speed loops, and the inner d-and q-axis current control loops are Actuators 2021, 10, 113 8 of 18 dominated by two PI controllers. As shown in Figure 3, the command of q-axis current control loop is from the output of the variable structure controller, and the command of the d-axis current control loop is set as 0. The sampling time for the current and speed/position control loops are set as 0.05 ms and 0.5 ms, respectively.
A typical trapezoidal speed profile with a displacement 0.628 radian, as shown in Figure 4, is used as the command input. The following simulated responses, including the position, speed, current and sliding surface σ, will be shown for with and without load conditions, which are defined dependent on whether or not the disk load axis connected. The speed profile of Figure 4 is made with the time constraints of acceleration period 0.2 s, constant speed period 0.3 s and deceleration period 0.2 s, and the variable structure control part (29) is set as:  In (31), 0 q is mainly used to reduce the steady-state error coming from the deadband, backlash, cogging torque, or other nonlinear part of the system, and make the sliding condition exist. The second part of (31), whereby magnitude is proportional to the motor speed, is designed to guarantee the system states follow the desired trajectory defined in matrix c A .
First, the responses of step position command input are shown in Figure 5. There is no speed restriction on the response, and the speed and position are controlled by the equivalent system matrix c A . Figures 6-8 are the position, speed and current response under the no-load condition. In Figure 6, we can see that the feedback has reached the target position of 0.628 radians at the time of about 0.7 s. The simulation shows that the drive system with variable structure control can ensure the performance of the position control. The speed response displayed on Figure 7 shows that the acceleration segment, constant speed and deceleration are near to the desired speed command profile. From Figure 7, the speed at the run segment is about 1.256 rad/s. Due to the chatter control of VSC and the low-speed operation, there is a little ripple in the speed response. The current response is shown in Figure 8, in which the magnitude is small because a no-load condition is asserted. In (31), q 0 is mainly used to reduce the steady-state error coming from the dead-band, backlash, cogging torque, or other nonlinear part of the system, and make the sliding condition exist. The second part of (31), whereby magnitude is proportional to the motor speed, is designed to guarantee the system states follow the desired trajectory defined in matrix A c .
First, the responses of step position command input are shown in Figure 5. There is no speed restriction on the response, and the speed and position are controlled by the equivalent system matrix A c . Figures 6-8 are the position, speed and current response under the no-load condition. In Figure 6, we can see that the feedback has reached the target position of 0.628 radians at the time of about 0.7 s. The simulation shows that the drive system with variable structure control can ensure the performance of the position control. The speed response displayed on Figure 7 shows that the acceleration segment, constant speed and deceleration are near to the desired speed command profile. From Figure 7, the speed at the run segment is about 1.256 rad/s. Due to the chatter control of VSC and the low-speed operation, there is a little ripple in the speed response. The current response is shown in Figure 8, in which the magnitude is small because a no-load condition is asserted.     Figure 9 is the response of the sliding surface σ, which shows that the system enters the sliding surface once the motor starts, and it can be used to verify the correctness of the     Figure 9 is the response of the sliding surface σ, which shows that the system enters the sliding surface once the motor starts, and it can be used to verify the correctness of the proposed variable structure control. Sometimes, the motion control is shown running     Figure 9 is the response of the sliding surface σ, which shows that the system enters the sliding surface once the motor starts, and it can be used to verify the correctness of the     Figure 9 is the response of the sliding surface σ, which shows that the system enters the sliding surface once the motor starts, and it can be used to verify the correctness of the  Figure 9 is the response of the sliding surface σ, which shows that the system enters the sliding surface once the motor starts, and it can be used to verify the correctness of the proposed variable structure control. Sometimes, the motion control is shown running forward and backward, as Figure 10 displays. In it, the position tracking error is defined as the difference between position command and position feedback. Next, the simulation under the load condition is shown; the command used is the same as the no-load condition. For this condition, the inertia and the friction of the rotor are assumed by 10 times and twice the origin, respectively. The simulated results are shown in Figures 11-13. proposed variable structure control. Sometimes, the motion control is shown running forward and backward, as Figure 10 displays. In it, the position tracking error is defined as the difference between position command and position feedback. Next, the simulation under the load condition is shown; the command used is the same as the no-load condition. For this condition, the inertia and the friction of the rotor are assumed by 10 times and twice the origin, respectively. The simulated results are shown in Figures 11-13.    proposed variable structure control. Sometimes, the motion control is shown running forward and backward, as Figure 10 displays. In it, the position tracking error is defined as the difference between position command and position feedback. Next, the simulation under the load condition is shown; the command used is the same as the no-load condition. For this condition, the inertia and the friction of the rotor are assumed by 10 times and twice the origin, respectively. The simulated results are shown in Figures 11-13.    proposed variable structure control. Sometimes, the motion control is shown running forward and backward, as Figure 10 displays. In it, the position tracking error is defined as the difference between position command and position feedback. Next, the simulation under the load condition is shown; the command used is the same as the no-load condition. For this condition, the inertia and the friction of the rotor are assumed by 10 times and twice the origin, respectively. The simulated results are shown in Figures 11-13.       Figure 11 is almost the same as the response without load of Figure 6; that is what the VSC control wants. However, because the connected flywheel load makes the system with 10 times the inertia as compared to the unload condition, which reduces the system bandwidth and presents small speed ripples. Since the control law of VSC part is used to make sure the system states keep the sliding condition, it is looking forward to a larger q-axis current for load condition. However, since the system has the same setting for both the unload and load conditions, the current response is nearly the same for both cases, as Figures 8 and 13 have shown. Next, Figure 14 displays the response of σ with load. As the speed ripple of Figure 12 is smaller than Figure 7, the ripple of σ in Figure   14 is smaller than Figure 9, and the system also stays on the sliding phase from the beginning.

Experimental Setup and Results
To practically evaluate the actual performance of the proposed control scheme, the experimental setup is shown in Figure 15a, which includes the FPGA board, power board,    Figure 11 is almost the same as the response without load of Figure 6; that is what the VSC control wants. However, because the connected flywheel load makes the system with 10 times the inertia as compared to the unload condition, which reduces the system bandwidth and presents small speed ripples. Since the control law of VSC part is used to make sure the system states keep the sliding condition, it is looking forward to a larger q-axis current for load condition. However, since the system has the same setting for both the unload and load conditions, the current response is nearly the same for both cases, as Figures 8 and 13 have shown. Next, Figure 14 displays the response of σ with load. As the speed ripple of Figure 12 is smaller than Figure 7, the ripple of σ in Figure   14 is smaller than Figure 9, and the system also stays on the sliding phase from the beginning.

Experimental Setup and Results
To practically evaluate the actual performance of the proposed control scheme, the experimental setup is shown in Figure 15a, which includes the FPGA board, power board,   Figure 11 is almost the same as the response without load of Figure 6; that is what the VSC control wants. However, because the connected flywheel load makes the system with 10 times the inertia as compared to the unload condition, which reduces the system bandwidth and presents small speed ripples. Since the control law of VSC part is used to make sure the system states keep the sliding condition, it is looking forward to a larger q-axis current for load condition. However, since the system has the same setting for both the unload and load conditions, the current response is nearly the same for both cases, as Figures 8 and 13 have shown. Next, Figure 14 displays the response of σ with load. As the speed ripple of Figure 12 is smaller than Figure 7, the ripple of σ in Figure 14 is smaller than Figure 9, and the system also stays on the sliding phase from the beginning.   Figure 11 is almost the same as the response without load of Figure 6; that is what the VSC control wants. However, because the connected flywheel load makes the system with 10 times the inertia as compared to the unload condition, which reduces the system bandwidth and presents small speed ripples. Since the control law of VSC part is used to make sure the system states keep the sliding condition, it is looking forward to a larger q-axis current for load condition. However, since the system has the same setting for both the unload and load conditions, the current response is nearly the same for both cases, as Figures 8 and 13 have shown. Next, Figure 14 displays the response of σ with load. As the speed ripple of Figure 12 is smaller than Figure 7, the ripple of σ in Figure   14 is smaller than Figure 9, and the system also stays on the sliding phase from the beginning.

Experimental Setup and Results
To practically evaluate the actual performance of the proposed control scheme, the experimental setup is shown in Figure 15a, which includes the FPGA board, power board,

Experimental Setup and Results
To practically evaluate the actual performance of the proposed control scheme, the experimental setup is shown in Figure 15a, which includes the FPGA board, power board, DC power supply, hybrid stepper motor, motor load and digital oscilloscope with logic analyzer. On the FPGA board, it includes the Altera Cyclone III FPGA with type EP3C16E144C8N, 12-bit serial analog to digital converter (ADC) AD7866 made by Analog Devices and 12-bit digital to analog converter (DAC) TLV5618 made by Texas Instruments. In the power board, there are two H-bridge circuits used to transfer the DC power to the stepper motor, and two Hall current sensors are set to detect the motor stator currents. The EP3C16E144C8N chip has 84 I/O pins, 15,408 logic elements, 516,096 bits RAM, 56 18 × 18 multipliers and 4 PLLs [21], and is clocked by 20 MHz. The FPGA chip is used to develop the hardware control system, which includes the coordinate transformation, variable structure controller, PI controllers, 4X quadrature encoder counter, two-phase SVPWM, and the series/parallel conversions for the ADC and DAC converters. A non-optimized usage report about the proposed drive system is shown in Table 2. ADC and DAC are serial type 12-bit converters clocked by 20 MHz. ADC is used to obtain the analog current of phases A and B detected by Hall sensors, and works with a 20 kHz trigger signal. DAC is used to output the corresponding analog voltage signals of the controlled variables such as the rotor position, speed, and sliding surface σ to be checked and compared, and those signals are shown on the digital oscilloscope. DAC is worked with a 2 kHz trigger signal since it is used to demonstrate the mechanic signals. The sampling times for the current control loop and position/speed control loops are, respectively, 0.05 ms and 0.5 ms. The built functions of the FPGA chip and the signal flow diagram out of the FPGA of the experimental system are shown in Figure 16, and signal flow of the blocks inside the FPGA can be found in Figure 3. Logic analyzer, which is built in the digital oscilloscope, is used to capture and display the digital signal outputs from the FPGA. In here, the logical analyzer is used to display the position tracking error of the position control loop. The stepper motor is a hybrid one with 50 rotor teeth, rated current 2 A, and is powered by DC bus voltage 24 V. Additionally, it is equipped with a 5000 p/rev incremental encoder for the position/speed feedback. The load system for the experiment is shown in Figure 15b; it is a flywheel-type load, and counterweights can be used to change the inertia on the rotor. For the comparison purpose, the desired speed waveform and angular destination of the experimental system are the same as the simulated system.  [21], and is clocked by 20 MHz. The FPGA chip is used to develop the hardware control system, which includes the coordinate transformation, variable structure controller, PI controllers, 4X quadrature encoder counter, two-phase SVPWM, and the series/parallel conversions for the ADC and DAC converters. A nonoptimized usage report about the proposed drive system is shown in Table 2. ADC and DAC are serial type 12-bit converters clocked by 20 MHz. ADC is used to obtain the analog current of phases A and B detected by Hall sensors, and works with a 20 kHz trigger signal. DAC is used to output the corresponding analog voltage signals of the controlled variables such as the rotor position, speed, and sliding surface σ to be checked and compared, and those signals are shown on the digital oscilloscope. DAC is worked with a 2 kHz trigger signal since it is used to demonstrate the mechanic signals. The sampling times for the current control loop and position/speed control loops are, respectively, 0.05 ms and 0.5 ms. The built functions of the FPGA chip and the signal flow diagram out of the FPGA of the experimental system are shown in Figure 16, and signal flow of the blocks inside the FPGA can be found in Figure 3. Logic analyzer, which is built in the digital oscilloscope, is used to capture and display the digital signal outputs from the FPGA. In here, the logical analyzer is used to display the position tracking error of the position control loop. The stepper motor is a hybrid one with 50 rotor teeth, rated current 2 A, and is powered by DC bus voltage 24 V. Additionally, it is equipped with a 5000 p/rev incremental encoder for the position/speed feedback. The load system for the experiment is shown in Figure 15b; it is a flywheel-type load, and counterweights can be used to change the inertia on the rotor. For the comparison purpose, the desired speed waveform and angular destination of the experimental system are the same as the simulated system.    The experimental results with step position command input are shown in Figure 17. The system takes about 100 ms to reach its steady-state value as simulated, and the speed response is not so sharp as the simulation.  The experimental results with step position command input are shown in Figure 17. The system takes about 100 ms to reach its steady-state value as simulated, and the speed response is not so sharp as the simulation. The experimental results with step position command input are shown in Figure 17. The system takes about 100 ms to reach its steady-state value as simulated, and the speed response is not so sharp as the simulation.    To check the position response precisely, we sent the position error in digital format with 8 bits to the output port of the FPGA, and captured them by the logic analyzer. In Figure 18, it displays that the bit D0 is switching between 0 and 1, and the other bits, D1-D7, stay at 0. Thus, the position error in the steady-state condition is about one encoder pulse. Figure 19 is the zoomed plot to the steady-state condition. Figure 20 is the result with running forward and backward. To check the position response precisely, we sent the position error in digital format with 8 bits to the output port of the FPGA, and captured them by the logic analyzer. In Figure 18, it displays that the bit D0 is switching between 0 and 1, and the other bits, D1-D7, stay at 0. Thus, the position error in the steady-state condition is about one encoder pulse. Figure 19 is the zoomed plot to the steady-state condition. Figure  20 is the result with running forward and backward.   To check the position response precisely, we sent the position error in digital format with 8 bits to the output port of the FPGA, and captured them by the logic analyzer. In Figure 18, it displays that the bit D0 is switching between 0 and 1, and the other bits, D1-D7, stay at 0. Thus, the position error in the steady-state condition is about one encoder pulse. Figure 19 is the zoomed plot to the steady-state condition. Figure  20 is the result with running forward and backward.     Figures 21 and 22 are, respectively, the stator current and sliding surface σ . Since the system is with a trapezoidal velocity profile command input, the current response is requested to respond to the similar profile as the speed response. In Figure 22, the sliding surface is always kept at a quite low value since the system enters the sliding phase from starting.    Figures 21 and 22 are, respectively, the stator current and sliding surface σ. Since the system is with a trapezoidal velocity profile command input, the current response is requested to respond to the similar profile as the speed response. In Figure 22, the sliding surface is always kept at a quite low value since the system enters the sliding phase from starting.  Figures 21 and 22 are, respectively, the stator current and sliding surface σ . Since the system is with a trapezoidal velocity profile command input, the current response is requested to respond to the similar profile as the speed response. In Figure 22, the sliding surface is always kept at a quite low value since the system enters the sliding phase from starting.    Figures 21 and 22 are, respectively, the stator current and sliding surface σ . Since the system is with a trapezoidal velocity profile command input, the current response is requested to respond to the similar profile as the speed response. In Figure 22, the sliding surface is always kept at a quite low value since the system enters the sliding phase from starting.   Next, we are going to display the test with load. The motor is connected to a disk load, as shown in Figure 15b, and four counterweights are added to increase the rotor inertia to about 10 times the case without them, and two-time frictions are assumed. Figures 23-25 are the results of load conditions. Next, we are going to display the test with load. The motor is connected to a disk load, as shown in Figure 15b, and four counterweights are added to increase the rotor inertia to about 10 times the case without them, and two-time frictions are assumed.   Figure 23 shows the position and speed responses under the load condition. The speed response is obedient to follow the speed profile as the no-load condition. Since the tested load is constructed by increasing the rotor inertia and friction, more generated torque is needed to overcome the variations as the evidence that the stator current was increased to about 0.35A peak to peak value as shown in Figure 24, and its magnitude is greater than the one without load connected. Comparing the two sliding surface responses of Figures 22 and 25, they show that the ripple of the load condition is greater than the case without load. On the contrary, in the steady-state duration, the system speed is almost zero, and the increased inertia and friction lead to the reduction of system bandwidth. Thus, the magnitude of the ripple about σ for the load condition is smaller than the unload condition at the steady-state duration. It can also be seen from the steady-state digital tracking error where the load condition is not so active compared to the no-load condition.    Figure 23 shows the position and speed responses under the load condition. The speed response is obedient to follow the speed profile as the no-load condition. Since the tested load is constructed by increasing the rotor inertia and friction, more generated torque is needed to overcome the variations as the evidence that the stator current was increased to about 0.35A peak to peak value as shown in Figure 24, and its magnitude is greater than the one without load connected. Comparing the two sliding surface responses of Figures 22 and 25, they show that the ripple of the load condition is greater than the case without load. On the contrary, in the steady-state duration, the system speed is almost zero, and the increased inertia and friction lead to the reduction of system bandwidth. Thus, the magnitude of the ripple about σ for the load condition is smaller than the unload condition at the steady-state duration. It can also be seen from the steady-state digital tracking error where the load condition is not so active compared to the no-load condition.

Conclusions
As we can see in this paper, the stepper motor drive system with a variable structure controller implemented on an FPGA chip has been successfully realized. The system was first designed and simulated on the MATLAB/Simulink platform to evaluate the performance of the inner loop vector current control and outer loop position/speed variable structure control. It has been shown to be able to overcome the nonlinear characteristics of the fourth harmonic cogging torque and external load; the positioning error is about one bit. The hardware system implemented on FPGA for the variable structure controller and PI controller are verified by practical experiment for the stepper motor drive system  Figure 23 shows the position and speed responses under the load condition. The speed response is obedient to follow the speed profile as the no-load condition. Since the tested load is constructed by increasing the rotor inertia and friction, more generated torque is needed to overcome the variations as the evidence that the stator current was increased to about 0.35A peak to peak value as shown in Figure 24, and its magnitude is greater than the one without load connected. Comparing the two sliding surface responses of Figures 22 and 25, they show that the ripple of the load condition is greater than the case without load. On the contrary, in the steady-state duration, the system speed is almost zero, and the increased inertia and friction lead to the reduction of system bandwidth. Thus, the magnitude of the ripple about σ for the load condition is smaller than the unload condition at the steady-state duration. It can also be seen from the steady-state digital tracking error where the load condition is not so active compared to the no-load condition.

Conclusions
As we can see in this paper, the stepper motor drive system with a variable structure controller implemented on an FPGA chip has been successfully realized. The system was first designed and simulated on the MATLAB/Simulink platform to evaluate the performance of the inner loop vector current control and outer loop position/speed variable structure control. It has been shown to be able to overcome the nonlinear characteristics of the fourth harmonic cogging torque and external load; the positioning error is about one bit. The hardware system implemented on FPGA for the variable structure controller and PI controller are verified by practical experiment for the stepper motor drive system with the trapezoidal velocity profile constraint, and the drive system is completed operated on the predefined profile. With the results, it shows that a DSP-or microprocessor-based control system can be replaced by a hardware controller realized by FPGA. Furthermore, as the results show in Figures 9 and 14, the system is initially in the sliding surface and the following successive time. It means that the system's characteristics are completely matched to the designed equivalent system matrix, A c .
In the simulated speed responses of Figures 7 and 12, the speed ripples are obviously different, and no load condition is bigger than with the load condition. An estimator to dynamically determine the magnitude of q 0 and q 1 in (30) and (31) is going to be designed to reduce the chattering.