implementation of a digital control - laas

3
Implementation of a digital control This subject follows the work of the first practical session on velocity control of a circular saw. In this first practical session we have : — identified the transfer function of the motor, — designed a PI controller, — discretized the continuous-time controller to derive a digital control, — validated the method with simulation (with matlab/Simulink) and experimentation (with a data acquisition board Q2-USB). For the experimental tests, we used a generic acquisition board and a PC with the software mat- lab/Simulink. If this setup is useful for tests during the theoretical development, it is not suitable for industrial applications. The next step is to implement the control law on a dedicated cheap electronic board. In this practical session, the objective is to program the microcontroller of the electronic board so as to replace the setup of the first session and control the motor’s velocity. 1 Control law The scheme of the closed loop system studied in the first session is given in Figure 1. The transfer function G(p) of the motor has been experimentally determined and the corresponding sampled transfer function has been calculated : G(p)= 1.1 0.045p +1 and G(z)= 0.54 z - 0.51 The controller C(z)= 1.2z - 0.55 z - 1 with a sampling period T e = 30ms has been validated through simulation and experimentation. Ω (p) + - G(p) B 0 (p) T e Ω (z) U(z) C(z) Ω c (z) Figure 1 1. Calculate the closed loop transfer function F (z). 2. Show that the closed loop system is stable. 3. Show that the static error is zero. Simulate the block diagram with matlab et Simulink. Check that simulations are consistent with your calculation. 4. Determine the recurrence equation of the controller. What is the interest of this formulation ? 1

Upload: others

Post on 11-Jan-2022

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implementation of a digital control - LAAS

��

� Implementation of a digital control

This subject follows the work of the first practical session on velocity control of a circular saw. In thisfirst practical session we have :

— identified the transfer function of the motor,— designed a PI controller,— discretized the continuous-time controller to derive a digital control,— validated the method with simulation (with matlab/Simulink) and experimentation (with a data

acquisition board Q2-USB).For the experimental tests, we used a generic acquisition board and a PC with the software mat-

lab/Simulink. If this setup is useful for tests during the theoretical development, it is not suitable forindustrial applications. The next step is to implement the control law on a dedicated cheap electronicboard. In this practical session, the objective is to program the microcontroller of the electronic board soas to replace the setup of the first session and control the motor’s velocity.

1 Control law

The scheme of the closed loop system studied in the first session is given in Figure 1. The transferfunction G(p) of the motor has been experimentally determined and the corresponding sampled transferfunction has been calculated :

G(p) =1.1

0.045p + 1and G(z) =

0.54

z − 0.51

The controller

C(z) =1.2z − 0.55

z − 1

with a sampling period Te = 30ms has been validated through simulation and experimentation.

Ω (p)+-

G(p)B0(p)Te

Ω (z)U(z)C(z)Ωc (z)

Figure 1

1. Calculate the closed loop transfer function F (z).

2. Show that the closed loop system is stable.

3. Show that the static error is zero.

Simulate the block diagram with matlab et Simulink. Check that simulations are consistentwith your calculation.

4. Determine the recurrence equation of the controller. What is the interest of this formulation ?

1

Page 2: Implementation of a digital control - LAAS

2 Toward implementation

After calculation, simulations and experiments phases, we now aim at implementing the control law ona suitable, cheaper and easy to integrate device. The proposed solution is the electronic board of Figure2, that includes a microcontroller PIC18F4550 from Microchip.

Pickit3 pour programmationdu microcontrôleur(interface avec PC de dev.)

MicrocontrôleurBornierinterface avec moteur

PotentiomètreLEDBoutonCommunication parliaison série

Figure 2

5. List all the input and output signals to have on the electronic board.

6. Give, using natural language or a schematic, the algorithm to be programmed.

In order to get started on programming the microcontroller, a first simple code is provided 1.

7. After having examined the code, execute it on the board.

3 Programming

This part concerns the control law programming on the microcontroller. The objective is to makethe electronic board able to control the motor’s speed. Three aspects are to be considered : the controlalgorithm itself, the acquisition of signals (inputs for the board) and the generation of a signal (outputfor the board). The two latter points consist in programming the interfaces between the board and thephysical system. The motor’s output signal will be simulated by a second potentiometer. Three measuringpoints are available (where a probe can be plugged) to observe with an oscilloscope the voltage at theterminals of the two potentiometers and the control signal that will be connected to the motor (PWMsignal).

Acquisition of an analog signal

The voltage at the terminals of potentiometers is a continuous analog voltage between 0 and 5V. Ananalog to digital converter (ADC) is required to have the values of the signal available in your program.This peripheral is integrated in the microcontroller chip, it converts an analog value (0−5V) into a numbercoded with 10 bits, that is an integer from 0 to 1023 (= 210 − 1). A library 2 is provided and contains twofunctions to handle this peripheral ;

8. Make a program that acquires the voltage from a potentiometer and send the result over the serialcommunication, in a loop (continuously).

1. The MPLAB project including this code is provided on moodle.2. Use the module analog.c from the library libPicIcam. It is already included in the startup program (MPLAB project).

2

Page 3: Implementation of a digital control - LAAS

9. Change your program to set a time period 3 of acquisition (one every 200ms), to handle the twopotentiometers and that translates 10 bits values into float values with a physical meaning.

PWM signal generation

The expected signal at the input of the test bed is an analog voltage between 0 and 15V (when rotatingin the same direction). The microcontroller used here does not have a peripheral able to generate such asignal, that is a digital to analog converter (DAC). Moreover, the supply voltage of the board is 5V , andits output are thus limited to that value. This task will be carried out by a separated electronic device(PWM2B). This latter is driven by a PWM signal. The operating principle is illustrated in Figure 3.

Figure 3

Two functions are already coded to generate a PWM signal : pwmSetup to configure microcontrollerregister ; setPWM to set a value for the duty cycle.

10. Using the datasheet 4 of the microcontroller, analyze the code of the two functions.

11. Write the structure of the program that generate the PWM signal with a duty signal proportionalto the potentiometer position.

12. Program your algorithm and test your board.

[with the teacher], review the global structure of the program discussed at question 6, analyzethe proposed code and test it on the test bed.

13. Plot the graph of the experimental results 5 and compare them to your simulation results.

3. Use an appropriate function from module time.c.4. the pin diagram of the µC is given p4 ; register configuration related to the PWM function is given p143 ; additional

explanations are given p148.5. Datas are stored in a file available on moodle.

3