Control Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

EE324: Lab1

Design a PID controller to rotate motor by 180◦under


given constraints
TUESDAY BATCH - GROUP 9
Patel Kunj-210070059
Sankethan Rathod-210070075
Kalpit Jain-210070039
August 29, 2023

1 Aim of the experiment


To rotate motor by 180◦ from any given point using PID controller under constraints :

- Overshoot ≤ 10 percentage

- Rise time ≤ 0.5 seconds

- Settling time ≤ 1 seconds

2 Control Algorithm
Using pidTuner() in MATLAB we adjusted the response time(faster or slower) and transient
state(robust or agressive) to get parameters within above mentioned constraints. We used those
values of Kp , Ki , and Kd for initial work. Based on the motor we then needed to fine tune the
response to reduce steady state error, and oscillations.
The tuned PID controller came out to be,
Z t
d
speed(t) = Kp ∗ error(t) + Ki ∗ error(t) + Kd ∗ error(t); Kp =120, Ki =5, Kd =1 (1)
0 dt

where error(t) is the difference between current position and destination.


Also the input to PWM can not exceed 255, so we need to use min(speed(t),255) to avoid
aurdino giving any arbitary value to PWM output.

This was the main sole of our control algorithm, other nuances are included in next section.

1
3 Challenges faced and their solution
• The potentiometer reading were unreliable and 512 did not always gave sat-
isfactory result of 180◦ rotation.
Solution : We tried to plot the graph of Potentiometer reading v/s Angle. This gave
us insight about non-linear region and also that thinking 512 ≡ 180◦ is wrong. We tried
to find non-linear region which came out to be 120◦ to 150◦ on given motor, with 120◦ -
133◦ was pulsating and rest was constant at 1023.
Also for us 180◦ was equivalent to 547, which we got from by choosing sets of points
180◦ apart (excluding non-linear regions) and taking average of difference of their poten-
tiometer reading.

• The speed measured through the PID controller always came out to be greater
than 255, so it was as good as there doesn’t exist PID control, and speed was
dead set at 255.
Solution : According to our default settings in aurdino IDE time was in milliseconds
unit. So every where it was 1 instead of 0.001 in calculation of derivative and integration.
This added factor of 1000. Also the potentionmeter reading was from 0-1023 and it
represented 0-5V so we multiplied the error by 5/1023 to do all calculations in terms of
voltage so it would be easier to apply that value to PWM output. This added factor of
∼ 200. Now our speed was in satisfactory range after reduction of factor of 2*105 .

• The speed was slow after above procedure and may be it did not satisfy the
constraints.
Solution : The PWM is of 50% duty cycle. So if we want to supply 10V we need to
keep high value at 20V so then average would turn out to be 10V. This was the PWM
Time Period
ratio that we multiplied with speed after equation 1. Ratio = High Level Time
.

• There were oscillations at steady state


Solution : By varying the value of Kd we reduced the oscillations and by varying the
values of Ki we reduced the steady state error of system. By increasing these quantities
we can reduce corresponding errors.
Needed to find sweet spot because increasing :
Kp =⇒ overshoot ↑ ; rise time ↓ ; settling time-not much effect
Ki =⇒ overshoot ↑ ; rise time ↓ ; settling time ↑
Kd =⇒ overshoot ↓ ; rise time - small change ; settling time ↓

• Sometimes we forget or the user forget that starting point is a non-linear


region, and it gives any arbitrary rotation
Solution : We appened a small peice of code at start of control algorithm, which detect
whether the start is in nnon-linear region or not, and accordingly refused or allows to
start the rotation. The way to do that was to measure potentiometer reading twice with
gap of 1sec, and if those two reading differ by more than 2(pulsating region), then the
point is in non-linear region. A explicit condition is for the constant region of 1023 in
that non-linear region.

2
4 Results
The printed the potentiometer reading and the time in output window. Later we used those
values to get plot. Which turns out to be:

Figure 1: Complete Response

3
Figure 2: Rise Time

Figure 3: Settling Time

4
Figure 4: Overshoot

In figure 1 the three lines represent the rise time (63% - this is taken as system responds nearly
as first order system), settling time(98%) and final steady state error and overshoot(both of
which are highly negligible in engineering perspective), and are as good as none.

In calculations of time, 1000ms is taken as starting point as first 1000ms are used
in determmining whether starting point is in non-linear region or not.

Rise Time : According to Figure 2, the system reaches 63% of its steady state value (i.e.
113.78◦ ) at 1284.13 ms (through linear approximation between two points). Therefore, Rise
Time = 284.13ms

Settling Time : According to Figure 3, the point is very near to intersection whose time
co-ordinate is 1678 ms. Therefore, Settling Time = 678ms.

Overshoot : Practically there is zero overshoot, but still for completeness, if we zoom in
to the final phase of response we see that the max angle that system has reached is 180.329◦ .
Therefore, one can say that there is overshoot of 0.182%. In similar fashion s.s. error turns
out to be -0.329◦ , though we can’t be 100% sure of it as data has been taken only for ∼ 2300ms.

5
5 Observation and Inference
• The system behaved nearly as first order, due to choice of parameters and the tuning that
was done w.r.t. motor.

• How potentiometer readings may not be linear at ends, and what all situations can arise
when a potentiometer is joint end to end to have circular pot.

• Theoretically the values of Kp , Ki , Kd came out to be different than those used finally
after tuning as in theoretical calculations we don’t include the aspects of system itself
like, friction, measurement accuracy, responsiveness, etc.

• The usage of PID controller bring system to steady state, quickly, smoothly and accu-
rately, as all three components are neccesary to have zero s.s. error, lower settling time,
rise time, and overshoot.

• When intentionally the motor was given non linear region point as starting point, it gave
arbitary rotation each time due to pulsating effect, also for the constant regime, for a set
of starting points the destination was same, as for that whole set the value was 1023.

• Also if the destination is the pulsating region then the motor will keep on rotating, because
when it reachess dstination, the value over there keeps changing so error(t) ̸= 0 ∀ t and
thus by equation 1 speed(t) ̸= 0 so it keeps on rotating.

You might also like