# Embedded Systems Interfacing

Fall 2008

jeg

Feedback Speed Control
Purpose:
To learn how to control the speed of a DC Servomotor under various load and gain conditions.

Background:
This laboratory exercise will require an exposure to control system theory. In that Computer Engineering students in this course have not had a formal course in control system theory we will base our discussion on the course of Signals & Systems.
P W M D R I V E R

Speed Reference (Internal)

+

Error Σ

Control Algorithm
PIC24FJ128CA010

DC Servo Motor

Speed

-

Tachometer Output

Frequency to Voltage Converter
Figure 1 Speed Control System The system will consist of the Explore-16 with PICTail Protoboard, an LM2906 Frequency-to-Voltage converter, a TD62003AP Darlington Sinking Driver to power the motor, and the 429A6004 DC servomotor. These are assembled into the control system of Figure 1. We need to model the DC servomotor and the frequency-to-voltage converter. For experience with the previous laboratory exercise we know the servomotor may be modeled using one dominant pole. The transfer function for this is: Equation 1 Single Dominate Pole

P( s) =

B 1+ A• s

The values of B and A should have been determined in the previous laboratory exercise via the Open-Loop StepResponse. The next step is to decide what control algorithm should be used that is easy to implement, makes the system reasonable responsive, and keeps the system stable. These topics constitute a great deal of time in Controls I and Controls II. You will not be asked to make the decision but only to observe the results of the decisions made for you. We will use a Proportional-Integral or PI controller were the signal applied to the motor is proportional to the desired speed and the integral of the error between desired and actual speed.

1

E(n-1) is the previous and E(n-2) the previous-previous error signal.Embedded Systems Interfacing Fall 2008 jeg R(z) + Σ - E(z) _k(z-b)___ z(z-1) U(z) DAC U(s) B_ (s+A) Y(s) ADC Y(z) Figure 2 Proportional-Integral Speed Control System In the z-domain the PI controller is: Equation 2 z-Domain PI Controller C( z) = U (z ) k (z − b ) = E (z ) z (z − 1) ) This z-domain controller can be translated to the following difference equation. 2 . U(n) represents the present value written to the PWM register. Stability: The stability of a control system can be determined by first finding the forward gain of the feedback system which we will call H(z). Root-locus is the process of finding the location of the poles and zeros as a function the gain. we can determine the properties of the closed-loop control systems. U(n-1) is the previously written value. Equation 3 Control Algorithm U ( z ) k (z − b ) = E ( z) z (z − 1) U ( z ) kz − kb = E ( z) z2 − z z 2 • U ( z) − z • U ( z) = k • z • E( z) − k • b • E( z) z • U ( z) + k • z • E( z) − k • b • E ( z) U ( z) = z2 U ( z ) = z −1 • U ( z ) + k • z −1 • E ( z ) − z − 2 • k • b • E ( z ) U (n) = U (n − 1) + k • E (n − 1) − k • b • E (n − 2). E(n) is the present error signal. This difference equation will be implemented in the PIC24F. This can be found by using the relationship: Equation 4 Control Ratio H ( z) = M ( z) • C ( z) where C(z) is the controller transfer function and M(z) is the motor transfer function translated to the z-domain. If we find the location of the poles and zeros of a function as a function of the controller gain.

3 .95.den) sysd = tf(num. As an example % Motor Step Response clc A = 13.Embedded Systems Interfacing Fall 2008 jeg Figure 3 Closed-Loop Root-Locus An example of a root-locus is shown in Figure 3. MATLAB Transfer Function MATLAB Control Tool box has a transfer function called tf( ). The root-locus tool may be used to find the controller gain at various damping ratios.333.den. % Motor B = A*1. The damping ratio is a measure of how fast the controlled signal settles on the reference signal. The second form is for discrete systems where Ts is the sample interval.[1 A]).Ts) We will use the first form for continuous systems step response. % step(1. The syntax is: sys = tf(num.95*Motor) % Motor Pole Gain Motor Transfer Function step response The A and B values given here are made-up and will not be equal to your measured and calculated values. The lower the number the longer it takes to settle. % Motor Motor = tf([B].

The syntax is: sysd = c2d(sys. To see where the poles and zeros of the servomotor lie we will use the c2d( ) function and the pzmap( ) in the MATLAB Controls Toolbox. or SS). Find the step response of the servomotor and electronics. step(6*Motor) Use your values for A and B.333. In a feedback control system. See above for an example Y (s ) . If one defines the numerator of the motor transfer function. The time range and number of points are chosen automatically. From the MATLAB online help the step function details are: STEP(SYS) plots the step response of the LTI model SYS (created with either TF.Embedded Systems Interfacing Fall 2008 jeg MATLAB Step Function: MATLAB has a function called step( ) that will plot the step response of the system. U (s ) as N and the denominator of the control ratio as D. For multiinput models.[1 A]). independent step commands are applied to each input channel. %use your measured value 4 .333. step response. Next we will find the root locus of the closed loop system for various gains. Task 1: Use the A and B values from the previous laboratory exercise. and sysd is the discrete transfer function. %use your measured value B = A*1. %use your measured value Motor = tf([B]. Use the following m-script: %Task 1 Feedback Lab Root Locus clc A = 13. ZPK. MATLAB Root-Locus Tool Initialize the Root Locus Design GUI by rlocus(sys) where system is the transfer function of the product of the controller and motor in the z-domain.95. Ts is the sample interval (50 ms). Use the following m-script: %Task 1 Feedback Lab Step Response clc A = 13.Ts) where sys is the continuous domain transfer function. the location of poles and zeros of the control ratio move around as system gain is changed. Then step(N.D) will plot the MATLAB Continuous to Discrete Function To convert the continuous transfer function to its equivalent discrete transfer function use the c2d( ) function. If the measured and calculated responses do not agree contact the laboratory assistant or instructor for help. Then compare with the step response of the previous laboratory exercise.