Sunteți pe pagina 1din 7

EE1038 AUTOMATIC REGULATION

REPORT PRACTICE 2

PNEUMATIC CYLINDER POSITION


CONTROL

Pedro Sancho Álvarez

Castellón, Abril de 2018


ÍNDEX

1. Objective. ......................................................................................................... 3

2. Problem Statment. ............................................................................................ 3

3. Realization of de practice. ................................................................................ 4

4. Conclusions. ..................................................................................................... 7
1. Objective.

The objective of this practice session is to make the position control of a pneumatic
cylinder using a PID controller implemented with a microcontroller.

2. Problem Statement.

The connection scheme is the following:

The available material is:


- Process: Cylinder tyre with linear potentiometer.
- Card Arduino one.
- PC with Arduino software.
- Switched power amplifier

The position of the cylinder will be measured by a potentiometer. The mobile terminal
is attached to the cylinder, so if a voltage of 5 V is applied between the ends of the
potentiometer. Between the cursor and the terminal attached to 0 V there will be a
theoretical voltage between 0 and 5 V, proportional to the position of the cylinder, which
is within the range of the input voltage of the DAC converter of the microcontroller.

The solenoid valve must be powered between 0 and 15 volts. One of the PWM outputs
of the microcontroller is connected to the digital input pin in the amplifier circuit. When the
PWM signal is at 1, the coil is at 15V, whereas when PWM1 is at 0, the coil is at 0 V. The
control action will be defined by the working cycle of the PWM signal.

EE1038 PRACTICE 2 page 3 of 7


3. Realization of the practice.

Below is the last code we made in the practice. A code has been made to control the
pneumatic cylinder by means of a PID controller. That PID has been adjusted to obtain a
good step and external disturbance response.

1. #include <MsTimer2.h>
2.
3. float y, r, u, c = 0, a, y_cm, r_cm, r_cm0, er_cm, u_v, r_udig, u_udig;
4. float h = 10, BM_dig = 0.06, pmax = 0.2;
5. float e = 0, e1, ef, ef1;
6. float kp = 0.75, kp_v_cm;
7. float D = 0, Td = 0, qd = 0;
8. //float offset = 100;
9. float I, qi, Ti = 0.1;
10. float T = 0.001;
11. float b = 1;
12. float tau_d, N = 5;

First of all, we include the libraries that we need and we define the variables that we
are going to use. We have used a java tool to adjust the PID constants.

13. void setup() {


14. // put your setup code here, to run once:
15. Serial.begin(9600);
16. MsTimer2::set(T * 1000, control);
17. MsTimer2::start();
18. kp_v_cm = kp * 20.058;
19. u = 100;
20. qi = kp_v_cm * T / Ti;
21. qd = kp_v_cm * Td / T;
22. tau_d = Td / N;
23. a = T / (T + tau_d);
24. }

We have used the main loop to see the variables that interests us on the serial display.

25. void loop() {


26. // put your main code here, to run repeatedly:
27. // Serial.print(millis()/1000.0);
28. // Serial.print(" ");
29. // Serial.print(u);
30. // Serial.print(" ");
31. // Serial.print(y);
32. // Serial.print(" ");
33. // Serial.println(r);
34.
35. Serial.print(millis() / 1000.0);
36. Serial.print(" ");
37. Serial.print(y_cm);
38. Serial.print(" ");
39. Serial.println(er_cm);
40. }

EE1038 PRACTICE 2 page 4 of 7


The interrupt routine.

41. void control() {


42. y = analogRead(A0);
43. y_cm = y * (3.0 / 1023.0);
44. r_udig = analogRead(A1);
45. r_cm0 = r_udig / 1023.0 * 3.0;
46. if (r_cm0 > r_cm + pmax * T)r_cm = r_cm + pmax * T;
47. else if (r_cm0 < r_cm - pmax * T)r_cm = r_cm - pmax * T;
48. else r_cm = r_cm0;
49. er_cm = r_cm - y_cm;
50. if (er_cm > BM_dig) e = er_cm - BM_dig;
51. if (er_cm < -BM_dig) e = er_cm + BM_dig;
52. if (abs(er_cm) < BM_dig)e = 0;
53. ef = a * (c * r_cm - y_cm) + (1 - a) * ef1;
54. D = qd * (ef - ef1);
55. I = I + qi * e;
56. u_v = kp_v_cm * (b * r_cm - y_cm) + I + D;
57. if (((u_v > 15) & (qi * e > 0)) || ((u_v < 0) & (qi * e < 0))) I = I - qi * e;
//AntiWindup
58. if (u_v > 15) u_v = 15; //saturation
59. if (u_v < 0) u_v = 0;
60. u_udig = u_v / 15.0 * 255;
61. analogWrite(9, u_udig);
62. ef1 = ef;
63. }

First read the position of the cylinder and the reference, converting both readings into
real units, centimeters.

The next part of the code is to correct the position errors with the dead band, the
saturation of the control action and the Antiwindup. We use Antiwindup to avoid the
integral windup, refers to the situation in a PID feedback controller where a large change
in setpoint occurs and the integral terms accumulates a significant error during the rise,
windup, thus overshooting and continuing to increase as this accumulated error is
unwound (offset by errors in the other direction). The problem is the excess overshooting.

Finally, the control action is implemented by attacking the analog output with the
necessary power and the error is updated with the last known error

Graph of step response:

EE1038 PRACTICE 2 page 5 of 7


Graph of external disturbance response:

EE1038 PRACTICE 2 page 6 of 7


4. Conclusions.

In this practice we have seen different modes of control of a pneumatic cylinder. First,
a control was made using a Hysresis band, then we added a dead band and finally tested
different PI, PD and PID controllers. The improvement in control has been clearly observed
in the mechanical operation of the cylinder.

The last PID code we have made allows us to adjust it in a robust way for different
situations. modifying the constants Kp, Ti, Td and the ain we achieve different responses.

EE1038 PRACTICE 2 page 7 of 7

S-ar putea să vă placă și