15
Motor control using FPGA MOTIVATION In the previous chapter you learnt ways to interface external world signals with an FPGA. The next chapter discusses digital design and control implementation of different motors — stepper, permanent magnet DC motor, brushless DC motor, permanent magnet synchronous motor (PMSM) and permanent magnet reluctance motor. For the robot controller application chosen in this book, the electric motor is the actuator of the control scheme. There are many types of electric motors available that can be used for robot applications. The control scheme used for each motor type may be unique, but the overall control approach for motion control is similar across motor drives. A motor controller is a device or group of devices that serves to govern in some predetermined manner the performance of an electric motor. A motor controller might include a manual or automatic means for starting and stopping the motor, selecting forward or reverse rotation, selecting and regulating the speed, regulating or limiting the torque, and protecting against overloads and faults. There are various types of motors. The type of motor used for robot joint axis control varies. Simple robots use the stepper and DC motor for joint control. Contemporary industrial robots use AC servomotors such as a permanent magnet synchronous motor (PMSM) for axis control. So, it becomes necessary to learn about the different motors and their control techniques.

Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Embed Size (px)

Citation preview

Page 1: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Motor control using FPGA

MOTIVATION

In the previous chapter you learnt ways to interface external world signals with an FPGA. The next chapter discusses digital design and control implementation of different motors — stepper, permanent magnet DC motor, brushless DC motor, permanent magnet synchronous motor (PMSM) and permanent magnet reluctance motor. For the robot controller application chosen in this book, the electric motor is the actuator of the control scheme. There are many types of electric motors available that can be used for robot applications. The control scheme used for each motor type may be unique, but the overall control approach for motion control is similar across motor drives.

A motor controller is a device or group of devices that serves to govern in some predetermined manner the performance of an electric motor. A motor controller might include a manual or automatic means for starting and stopping the motor, selecting forward or reverse rotation, selecting and regulating the speed, regulating or limiting the torque, and protecting against overloads and faults.

There are various types of motors. The type of motor used for robot joint axis control varies. Simple robots use the stepper and DC motor for joint control. Contemporary industrial robots use AC servomotors such as a permanent magnet synchronous motor (PMSM) for axis control. So, it becomes necessary to learn about the different motors and their control techniques.

Page 2: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Types of motor (Source : Wikipedia )

PREREQUISITES

A basic understanding of what is meant by motors is required.

SUGGESTED TIME

8 hrs

LEARNING OBJECTIVES

In this module we will be learning about:

motor drivers, position loops and speed loops Stepper Motor Controller different types of Motors.

READING MATERIAL

Motor control

Page 3: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Introduction to Motor Drives

Robots make tremendous use of electric motor drives as actuators. Electric motors as actuators for robot joint movement have proved to better than hydraulic and pneumatic actuators. Moreover, electric motor based control schemes are cleaner and easier to execute. Previously, robots had used brushed DC motors as actuators. Although the control of DC motors is basic, it is not favoured because of frequent maintenance and probable risk due to sparking of brushes. Today many robot manufacturers use AC servomotors instead of DC motors. Implementation of complex algorithms is possible due to fast digital circuits. These are required to control AC motors. To get a whole picture, this module besides FPGA-based control of DC motors, includes control techniques used for AC servomotors.

Every motor drive gives basic functionality for:

· Setting of speed reference

· Control of motor direction (forward or reverse)

· Run/Jog operating controls

· Setting of acceleration/deceleration rate

· Emergency stop using dynamic or regenerative braking.

Digital Block Diagram for Robot Axis Control

The robot axis motion control is made up of three control loops. All these three loops work in tandem to move the robot axis to the position directed by the profile generator. The output of the position controller is made to be the reference for the speed loop. Likewise, the output of the speed controller becomes the reference for the motor current/torque loop. The controller’s task for all loops is to decrease the error between the reference and feedback values.

Page 4: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Control loops of motor control system

Position Loop

The position loop is the outermost loop. For the robot control system, it shows the position of each axis of the robot for the robot control system. The inverse kinematics algorithm calculates the desired value of rotation, θn required for each axis, and this is the reference to the position loop. The profile generator is a widely used reference for the position loop. Since the time constant of physical movement of the robot axis is of the order of milliseconds, a software based approach can be utilised for profile generation. Shown below is the software code which explains the profile generation for one axis of the robot controller. A free running timer peripheral is employed to produce periodic interrupts. The process can depend on this to run the position control algorithm.

Control loops of a motor control system are given below: On interrupt /* from timer */ { Q1 = encoder_counter1 /* current pos of axis 1 */ Q1s = setpoint_register1 /* set point Q1s axis one */ /* error generating junction */ e1 = Q1s - Q1 /* PID controller */

Page 5: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

i = i_old + ( e1 + e1_old )/2; /* integrator */ i_old = i; d = e1 - e1_old; /* derivative term */ e1_old = e1; c = (kp * e) + (kp * i) + (kd * d); }

Speed Loop

The task of the speed control loop is to rectify the speed error by sampling the speed reference and measure speed variable periodically. The speed error is provided to a controller to create a reference for the current loop. Both software and hardware approaches can be used for this update time requirement since the update time of a speed loop controller varies from 1–10 ms.

Digital block diagram of control loop

Power Module of Motor

The output of the torque-current controller gives a set point to the power module of the firing control circuit. The sampling period of the firing circuit differs with the type of power module topology. A zero crossing of the input waveform supplied by a synchronizing transformer is utilised to update the sampling period for each firing circuit for a single-phase rectifier circuit. The time taken for a 50-Hz input voltage to the rectifier is 3.33 ms. The power devices of the bridge are

Page 6: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

switched at a frequency around 20 kHz to produce a sinusoidal PWM voltage using a three-phase bridge.

Case Studies for Motor Control

The kind of motor used for robot joint axis control varies. For example, simple robots use the stepper and DC motor for joint control while contemporary industrial robots use AC servomotors such as a permanent magnet synchronous motor (PMSM) for axis control. The following section analyses different motors and their control techniques.

Stepper Motor Controller

A stepper motor is an electric machine which rotates in discrete angular increments. Shown below is a cross-sectional view of the motor. The angular increment is used to compute the number of steps required to complete one revolution. Since stepper motors move to a commanded number of steps, many stepper motor applications do not need position sensing. This lessens the complexity of stepper motor movements. Stepper motors are made use of in diverse applications as in printers, plotters, X–Y tables, image scanners, copiers, medical apparatus and other devices.

Illustration of stepper motor Cross-sectional view of the stepper motor

From the stand point of digital control, the stator poles of the stepper motor need to be regularly excited to initiate movement of the permanent magnet rotor. The excitation table of a motor differs from choices that give single step movement with one or two winding excitation. Simultaneous excitation of two windings gives greater torque as related to one winding. Half step excitation that increases the resolution of the movement is shown in tables.

Stepper motor full step, single-phase excitation

Page 7: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Stepper motor full step, two-phase excitation

Example: Write a Verilog HDL code that controls the speed and direction of a stepper motor working in single-phase excitation, as given in the table.

The code gives excitation to two of the four coils of the stepper motor stator. The FSM makes sure that the proper sequence is followed for coil excitation. The direction of rotation is varied by changing the sequence of coil supply denoted by coil_supply_f and coil_supply_r.

Verilog code for control of a stepper motor

module stepper (input clk, rst, dir, output [3:0] coil _ supply);

‘define reset 3’d0 ‘define step1 3’d1 ‘define step2 3,d2

Page 8: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

‘define step3 3’d3 ‘define step4 3’d4

reg [2:0] ps,ns; //present state (ps) and next state (ns) registers

wire clk _ spd;

reg [3:0] coil _ supply _f , coil _ supply _r ;

assign clk _ spd = clk; // Based on desired motor speed , the clk _ spd is set

always @ ( posedge rst or posedge clk _ spd ) // state transition

begin if ( rst ) ps <= ‘reset; else ps <= ns; end

always @ ( ps ) //select of next state and change of output

begin

Case ( ps )

‘reset : begin

ns <= ‘ step 1; coil _ supply _ f <= 4’b0000; coil _ supply _ r <= 4’b0000; end

‘step1 : begin

ns < = ‘step2; coil _ supply _ f < = 4’b0011; // 4’bDCBA winding coil _ supply _ r <= 4’b1001; end

‘step2 : begin

Page 9: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

ns < = ‘step3; coil _ supply _ f < = 4’b0110; coil _ supply _ r <= 4’b1100; end

‘step3 : begin

ns < = ‘step4; coil _ supply _ f < = 4’b1100; coil _ supply _ r <= 4’b0110; end

‘step4 : begin

ns <= ‘reset; coil _ supply _ f <= 4’b1001; coil _ supply _ f <= 4’b0011; end

Default begin

ns <= ‘reset; coil _ supply _ f <= 4’b0000; coil _ supply _ f <= 4’b0000; end

endcase

end

assign coil _ supply = ( dir == 1’b1) ? Coil _ supply _ f: coil _ supply _ r

endmodule

Permanent Magnet DC Motor

One of the most widely used motors is the permanent magnet DC motor. Its feature of providing a speed proportional to the applied voltage makes it very easy to control. An H-bridge configuration is used to give four-quadrant speed control to DC motors. The control scheme is made up of a free running counter

Page 10: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

that produces a ramp signal. This ramp is utilised for setting the duty cycle of the PWM signal. The counter value is compared with a control voltage (Vc). If the value of Vc is higher, then the duty cycle will be higher of the PWM voltage. The voltage across the motor terminals is the average value of the duty cycle of the PWM.

Permanent magnet DC motor control using a field programmable device

Page 11: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

Change in PWM duty cycle based on the value of the control voltage Vc

Verilog code for PWM control of a PMDC motor

module pwm (input wire [7:0] vc, input clk, input rst, output reg pwm);

reg [7:0] counter;

always @ (posedge clk)

being

if(rst)

counter = 8’h00;

else if (counter <vc)

being

pwm = 1’b1;

counter = counter +1;

end

else

Page 12: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

being

pwm = 1’b0;

counter = counter +1;

end

end

endmodule The Verilog code above shows a counter circuit along with comparator logic. For values of Vc less than the counter value, the PWM output is set at logic 1, else it is set at logic 0. A section of the synthesis report below shows identification of an 8-bit counter, 8-bit comparator and a 1-bit register for the PWM output signal.

Synthesis report of a PWM controller for a PMDC motor

Dead Time Control

The power device bridge is vulnerable to shoot-through faults, when devices on the same leg turn on together. To avoid shoot-through problems, a finite delay is

Page 13: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

integrated in the turn on and turn off of the upper and lower devices of a power bridge. Several DSPs intended for motor applications have exclusive hardware for dead time control. A programmable dead time timer is interlocked with the drive ok permissive. Dead time delay logic and HDL implementation to give delayed output of a device triggering signal are described.

Logic for implementing a dead band for a PMDC motor H-bridge

Given below is the HDL code which is made up of the logic, to control the upper device of a given leg. To get the control signal of the upper device the input signal A is multiplied by a time (dead-time) delayed signal dA. Dead time for the circuit can be altered by changing the constant (6’h3C), which is used for comparison with the count value.

Page 14: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

The reader is urged to write an HDL code which will control the upper and lower devices of the three legs of a power bridge (since dead-time is often used as a component in motor control, try to design using a re-usable instance based approach).

Verilog code for setting dead time between devices on the same leg of an H-bridge

module deadtime (input rst, a, clk, output upper_sw);

reg [5:0] counter;

reg da;

always @ (posedge clk or posedge rst)

being

if(rst)

begin

da<=0;

count<=0;

end

else if(a)

begin

count <= count +1;

if(count == 6’h3C)

da <= 1’b1;

else if (~a)

begin

Page 15: Motor control using FPGA - Information and Library …eacharya.inflibnet.ac.in/data-server/eacharya-documents/53e0c6cbe... · Motor control using FPGA MOTIVATION ... In this module

count <=0;

da <= 1’b0;

end

end

assign upper_sw = a && da;

endmodule