Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lab 5: Controls and Feedback - Building a Proportional Controller for Lighting Systems, Study notes of Computer Science

An introduction to control systems, specifically focusing on proportional controllers and their application in closed-loop systems. The lab aims to develop a controller using feedback from a sensor to adjust ambient light levels dynamically. Topics covered include open-loop vs closed-loop systems, error terms, and the use of proportional controllers. Students will construct a closed-loop system using an avr microcontroller and a cds photocell.

Typology: Study notes

2012/2013

Uploaded on 03/22/2013

dhritiman
dhritiman 🇮🇳

4.7

(6)

107 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lab 5 - Controls and Feedback
There are many examples of feedback in everyday life, such an example is a speeding
ticket. Consider the ticket as an “error term” where a large ticket means that you
exceeded the limit by a greater amount compared to a small ticket. Hopefully, a ticket
motivates you to drive slower and a larger ticket convinces you to drive slower, faster.
The use of feedback to control a system functions on similar principles. The device built
in this lab is a Proportional Controller. The exact reason for its name will be evident by
lab’s end. The idea is to develop a controller that uses feedback from a sensor to drive a
closed-loop system that dynamically adjusts operations to compensate for external
disturbances or interferences.
Background
There are two basic types of control systems: open loop and closed loop. Both types of
control systems use reference, r(t), and control, u(t), signals. Open loop systems do not
use feedback, while closed loop systems rely on feedback.
For demonstration purposes think of an assembly plant and a controller that controls
operations in the plant. In an open-loop system the controller does not recognize that the
plant might be generating output other than what it requested when it set u(t), therefore it
is not possible for the controller to modify u(t) to account for variations in y(t). One
reason that y(t) might vary from u(t) is because the mathematical model of the plant does
not account for a state or event in the plant, in which case u(t) does not directly correlate
to y(t). Another possible reason is that external, uncontrollable, events are affecting the
plant’s output.
Figure 5-1 – Block Diagram of an Open-Loop System
controller plant
h(t)
r(t) u(t) y(t)
Figure 5-1 shows a reference signal, r(t), a control signal u(t), and an output signal y(t).
h(t) is the plant’s transfer function and
)()()( thtuty =
where is the convolution
operator. Usually a reference signal is a human controlled input that indicates the desired
output to the controller. A volume control or gas pedal qualifies as a reference signal.
In closed-loop system a Proportional Controller dynamically adjusts u(t) based on the
error term, e(t), where:
)()()( tkytrte
=
where
1=k
for unity feedback. A proportional
controller computes the adjustment to the control signal, u(t), by simply adding the error
term to u(t). In an analog closed loop system the error term e(t) is continuously
calculated. Digital systems compute e(t) and u(t) at discrete time intervals, such as:
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Lab 5: Controls and Feedback - Building a Proportional Controller for Lighting Systems and more Study notes Computer Science in PDF only on Docsity!

Lab 5 - Controls and Feedback

There are many examples of feedback in everyday life, such an example is a speeding ticket. Consider the ticket as an “error term” where a large ticket means that you exceeded the limit by a greater amount compared to a small ticket. Hopefully, a ticket motivates you to drive slower and a larger ticket convinces you to drive slower, faster.

The use of feedback to control a system functions on similar principles. The device built in this lab is a Proportional Controller. The exact reason for its name will be evident by lab’s end. The idea is to develop a controller that uses feedback from a sensor to drive a closed-loop system that dynamically adjusts operations to compensate for external disturbances or interferences.

Background

There are two basic types of control systems: open loop and closed loop. Both types of control systems use reference, r(t), and control, u(t), signals. Open loop systems do not use feedback, while closed loop systems rely on feedback.

For demonstration purposes think of an assembly plant and a controller that controls operations in the plant. In an open-loop system the controller does not recognize that the plant might be generating output other than what it requested when it set u(t), therefore it is not possible for the controller to modify u(t) to account for variations in y(t). One reason that y(t) might vary from u(t) is because the mathematical model of the plant does not account for a state or event in the plant, in which case u(t) does not directly correlate to y(t). Another possible reason is that external, uncontrollable, events are affecting the plant’s output.

Figure 5-1 – Block Diagram of an Open-Loop System

controller plant h(t)

r(t) u(t)^ y(t)

Figure 5-1 shows a reference signal, r(t), a control signal u(t), and an output signal y(t). h(t) is the plant’s transfer function and y ( t )= u ( t )∗ h ( t )where (^) ∗ is the convolution

operator. Usually a reference signal is a human controlled input that indicates the desired output to the controller. A volume control or gas pedal qualifies as a reference signal.

In closed-loop system a Proportional Controller dynamically adjusts u(t) based on the error term, e(t), where: e ( t )= r ( t )− ky ( t )where k = 1 for unity feedback. A proportional

controller computes the adjustment to the control signal, u(t), by simply adding the error term to u(t). In an analog closed loop system the error term e(t) is continuously calculated. Digital systems compute e(t) and u(t) at discrete time intervals, such as:

u(t 2 )=u(t 0 ) + e(t 1 ), where t 2 >t 1 >t 0 and e(t 1 )=r(t 0 )-y(t 0 ). Iterative logic in a digital controller easily implements these calculations.

Figure 5-2 – A Closed-Loop System with Unity Feedback

controller

r(t) u(t) (^) plant y(t) h(t)

e(t)

Feedback enables a system to become stable and to return to a stable condition when external events disrupt or perturb a system. In return for being stable a system exhibits a slowed response to changes in a reference signal or to external events. The mechanisms for a control system using feedback are: proportional, derivative, integral or of these mechanisms combined into a PID controller. The PID controller is very common in industry.

The choice of a controller depends on the application’s requirements. This lab builds an application that uses the duty cycle of the PWM signal to dynamically adjust ambient light levels. The controller increases the duty cycle of the PWM in order to apply more power to the LED and thereby increase its intensity. The PWM is the control, u(t), that is fed into the plant (that is, LED).

This particular product experiences perturbations on a regular basis. Someone might open a curtain or turn on another light. The controller should respond to increases in ambient light by decreasing the PWM signal’s duty cycle which in turn dims the LED (plant) such that the total ambient light matches the reference signal.

Changes to the LED’s intensity can occur as fast as the mcu computes and updates the PWM duty cycle register (OCR2). For this application one update every 100 milliseconds is more than sufficient. One milli-second is very slow compared to how fast ambient light fills a room. At speeds of human perception 100 milliseconds is fast but detectable. These timing considerations drive the requirement for only needing to use a proportional controller. Hint. A maximum change of 2% to 4% to the duty cycle every 50 - 100 ms implements a nice smooth transition of the LED’s intensity.

As you can imagine this is just the surface of a deep topic. If this material is interesting consider taking other courses that discuss feedback and specifically control systems, such as ECE4510 or ECE4520 (ECE3510 is a pre-requisite for both courses). However, this lab is a practical hands-on approach. We need just enough information to know that the design is grounded on theory.

Circuit 5-1 – A Closed-Loop Control System

ATMEGA16L

VTG 150 10K

SW

VTG 150 10K

SW PB

PB

PC

RXD TXD

To Computer Serial Port

14 15

1

2

(^22) LED

VCC VTG 10K

150

VTG 150 10K

SW

PC1 23

PB2 3

VTG 150 10K

SW

PB3 4

VTG 150 10K

SW

PB4 5

LED

VCC VTG 10K

150

LED

VCC VTG 10K

LED

VCC VTG 10K

LED

VCC VTG 10K

150 150 150

PC2 24 PC3 25 PC4 26

OC (PD7)

21 130 Ω Sensor

200KΩ

LED

ADC (PA0)

40 VTG

V_Feedback R

R

Pre-Lab Assignments

  1. Read Chapter 2 of Microelectronic Circuits, 4th^ Edition, by Sedra/Smith..
  2. Complete the Pre-Lab Questions on page 5-5.

In-Lab Tasks

  1. Construct Circuit 5-1 and test its functionality before hooking it up to the STK500.
  2. Connect Circuit 5-1 to the STK 500 and write code to implement the closed-loop design. The buttons on the STK are to be used as reference values for the intensity of the light. THE VALUES CANNOT JUST BE HARDCODED INTO THE PROGRAM. THE LIGHT INTENSITY IS TO CHANGE ACCORDING TO THE FEEDBACK FROM THE CIRCUIT. The program is also to output the percentage of intensity that the light is actually lit up. Hint: You are going to have to experiment with the hardware and values that are returned to correctly adjust the light output.

Parts List

  1. CdS Photocell
  2. Resistors (~130 Ohm and 200K Ohm)

Deliverables

Describe your closed-loop system in the lab report. Include data obtained from different intensities of light. Demonstrate your circuit to the lab instructor.

Pre-Lab Questions for Lab 5 Name: ______________________________

10 points total, 4 points for question 1 and 6 points for question 2.

  1. Describe the 3 basic components of a PID and give an example of how each is used.
  2. Here’s a C-programming question. Let’s say your code has defined a 16-bit signed integer, and reads a 10-bit value from the ADC. What is the maximum value that your code can multiply the ADC value by before storing the result in the 16-bit signed, integer variable, without loosing any bits? Now, suppose that for whatever reason you need to multiply the ADC value by 74 but that you also need to divide it by a normalization factor of 165. Write the code, including the variable and constant (if any) definitions, to perform this calculation with minimal loss of accuracy in the final, signed, integer formatted answer.