Documente Academic
Documente Profesional
Documente Cultură
REPORT PRACTICE 2
1. Objective. ......................................................................................................... 3
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 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.
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.
We have used the main loop to see the variables that interests us on the serial display.
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
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.