You are on page 1of 6

Institute of Technology – Federal University of Pará

Laboratory of Control and Systems – lacos.ufpa.br

Project: Under-damped System


By Prof. Antonio da Silva Silveira

Main objective: based on Ogata’s Example 3-8 shown on page 80, design and implement an under-
damped plant to be used for digital control systems practices.

Appropriate resistors and capacitors values should be selected in order to build the system
with a damping factor of less than 0.5 and with a settling time of over 10 seconds, preferably, since
the control practices will occur using a free and open hardware and software suite for data
acquisition solution known as DaqDuino which generally works well at a maximum sampling
frequency of 20Hz.

Circuit description and its relation to the plant’s design criteria:

The circuit shown next in Fig. 1 is our basic analog structure. This basic structure still
misses the symmetrical power source for the op-amps and the input low-pass filters bank that is
going to aid the conversion of a PWM signal into an analog one, to be shown later in this project.

Fig. 1: Under-damped second-order system.

The structure shown in Fig. 1 leads to the following transfer function (TF):

(1)

This TF can be compared to a standard second-order system as follows:

(2)

From (2) it can be show that the static gain and that

(3)
(4)

Selection of resistors and capacitors:

Equations (3) and (4) can be precisely set with different components combinations.
However, we should be aware that higher resistor values will work better for our task in terms of
safety, since it will lower the current values. In this sense, we should look for resistors in the
kiloohm range and beyond.

Assuming the availability of capacitors and that the design restrictions are
seconds and , we can use the following piece of Scilab code to evaluate the step response of
our system and assess possible resistors values based on their availability:

clear; xdel(winsid()); clc;

R1=100e3; R2=2e6; C=1e-6; // Define components values


wn=sqrt(R1*R2)/(R1*R2*C); // Convert components to 2nd-order system params
zeta=sqrt(R1*R2)/(2*R2); // Convert components to 2nd-order system params
s=%s; Gs = syslin('c', (wn^2)/(s^2+2*zeta*wn*s+wn^2) ); // Set linear system in
s-domain
t=0:0.01:20; // Time vector

N = length(t);
redLineUp = 1.02*ones(1,N);
redLineDn = 0.98*ones(1,N);
plot(t,redLineUp,'r'); plot(t,redLineDn,'r');

y=csim('step',t,Gs); plot(t,y); // Simulate the step response


ylabel('Output (V)'); xlabel('Time (s)'); title('Step response');

Considering the use of and , the step response shown in Fig. 2 was
produced. In this current setup the system has a natural frequency around 2.23 rad/s, a damping
factor of 0.11 and a settling time close to 16 seconds.

Fig. 2: Simulated step-response of the circuit planned to be built.


Op-amps follower (buffer) and symmetrical power source:

The op-amp follower shown in Fig. 3 could be placed at the input and at the output of our
designed system. This circuit would eventually handle any possible impedance mismatch, despite
increasing the number of required op-amps.

Fig. 3: Op-amp follower (buffer) circuit.

If the input/output buffers were to be used, then the complete system will require five op-
amps, which is assumed too much for this current design, thus we are going to neglect the use of the
input buffer and just the output/sensor buffer will be implemented. So, with only four op-amps in
this particular design we will use the integrated circuit (IC) LM234N or a similar 4-op-amps IC.
This IC must be powered by a symmetrical power supply with at least three power terminals: +6V,
0V, -6V.
The current requirement will be very small, due to the lack of load draining any power and
high-value resistances in use. Thus, the power source could be any AC-DC 12V adapter we might
find and that we can divide using a voltage divider as shown in Fig. 4. The resistances can also be
set to the kiloohm range.

Fig. 4: Voltage divider circuit to derive the symmetrical power supply for the LM324N.

Remark: for the symmetrical power source it is also possible to use two 5V AC/DC
adapters commonly used to charge cell phones. If you have a two old chargers that are functioning
properly but are no longer in use, then they could be used to generate three power terminals: +5V,
0V, -5V. It will not be ideal since the op-amps will saturate earlier, but it will work.

DaqDuino: the data acquisition device based on the Arduino Nano board:

The DaqDuino is a software suite comprised of a firmware for Arduino and a set of script-
functions for Scilab, Matlab and Python. It has been successfully applied to Arduino’s Nano, Uno
and Due boards. It is free and it can be downloaded from the following sites:

https://lacos.ufpa.br/files/daqduino_v2.2.zip
https://www.mathworks.com/matlabcentral/fileexchange/50784-daqduino
For a quick reference and understanding of the DaqDuino concept, its firmware code is
shown in Table 1. This code assumes a Nano or Uno board and a single-input single-output (SISO)
implementation (but you can change it to cope with multi-input multi-output applications as well).
Observe in Table 1, lines 10 and 11, that we have two variables, u and y, and they mean
exactly the input/control variable and the output/controlled variable, respectively. In line 12 it is
defined the Arduino’s pin 6 as the PWM pin in use. So, it will be from this pin that we will send
control commands to our plant (not directly, since it still needs some filters that we will see later
on). Thus, pin 6 is responsible for sending the value in u to the PWM pin 6.

Table 1: DaqDuino’s firmware script (version 2.2).


1. // DAQ_Duino for Matlab/Scilab/Python (Arduino side code)
2. // Author: Antonio Silveira (asilveira@ufpa.br)
3. // Laboratory of Control and Systems, LACOS
4. // http://lacos.ufpa.br
5.
6. // Description: this is a very simple code to handle data acquisition essays
7. // using Matlab and Arduino. The Matlab side code is required
8. // in order to send I/O requests to this Arduino side.
9.
10. float u[1]={0.0};
11. float y[1]={0.0};
12. #define DA6 (6) // PWM Pin 6
13.
14. void setup() {
15. pinMode(DA6, OUTPUT);
16. digitalWrite(DA6, LOW);
17. Serial.begin(115200);
18. Serial.setTimeout(5); // Maximum milisecs to wait for
19. // Serial.parseFloat to timeout
20. }
21.
22. void loop() {
23. if (Serial.available() > 0) {
24. u[0] = Serial.parseFloat();
25. if (u[0]<0) {u[0]=0;}
26. if (u[0]>5) {u[0]=5;}
27. u[0] = u[0]*(255/5.0);
28. analogWrite(DA6,u[0]);
29.
30. y[0] = analogRead(A0)*(5/1023.0); // Pin A0 as Input
31. if (y[0]<0) {y[0]=0;}
32. if (y[0]>5) {y[0]=5;}
33. Serial.println(y[0]);
34. }
35. }

The output y is updated at line 30 in Table 1, where Arduino’s A0 pin, which is connected to
the process’ output/sensor, works as the analog-to-digital converter. The main loop in DaqDuino
works from line 23 to 34 and such a loop is only activated upon periodic serial requests from the
control computer/algorithm.
Bank of low-pass filters for digital-to-analog conversion:

The Nano and Uno boards do not have digital-to-analog converters, only simple PWM
outputs. Depending on the process/plant to be controlled, the PWM frequency might be too slow
relative to the response speed of the process, thus requiring a bank of low-pass filters to convert the
PWM signal into analog.

In order to design this bank of low-pass filters we are going to consider that Arduino’s PWM
signal works at a frequency close to 500Hz. Also, as a limitation of the Nano and Uno boards in
terms of what is called single-shot acquisition (read sensor data, update the PWM and sleep until
the next sampling time), the shortest sampling period possible is around 0.01 seconds, that is, a
sampling frequency of 100Hz. I hardly agree with some of my students that said they successfully
got up to such a speed with Nanos and Unos and for safety reasons I usually consider going no
lower than 0.05 seconds (or no further than 20Hz).

Assuming that our DaqDuino will work in the minimum limit of 0.05 second of sampling
time (or max of 20Hz), our bank of low-pass filters must guarantee a conversion of the PWM
signal prior to 0.05 seconds.

Using computer aided design with Scilab’s Xcos, we can simulate Arduino’s PWM signal
working at 500Hz. The diagram shown in Fig. 5 was simulated with a bank filter comprised of three
low-pass filters using and . A duty cycle of 50% was used in this
simulation, aiming at a digital-to-analog conversion to 2.5 V. The simulation result is shown in Fig.
6.

Fig. 5: Simulation diagram of a bank of low-pass filters for digital-to-analog conversion.

Fig. 6: 500Hz PWM at 50% duty cycle (black line). Filtered/converted signal (blue line). Observe
that the signal is converted almost 10 times faster than the intended sampling time of 0.05s.
The complete circuit diagram

Fig. 7: This is the plant/process circuit schematic comprised of, from left to right, the Arduino
PWM pin, the bank of low-pass filters, the input buffer op-amp, and the under-damped second-
order system. The symmetrical power source circuit is not shown in this diagram, but its three
terminals are being depicted as U1_V+, GND, U1_V-, respective to +6V, 0V, -6V.

Remark: remember to connect the Arduino’s GND to the process’ GND (0V, in this case).

List of parts/components

5x resistors of 10 k
4x resistors of 100 k
2x resistors of 2 M
3x capacitors of 0.1 uF
2x capacitors of 1 uF
1x LM324N
1x Arduino Nano

You might also like