lab 3 real-time control of a hot air plant using rtos µc/osii due date: week of nov. 2 nd, 2010

22
Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd , 2010

Upload: angelina-jones

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Lab 3

Real-Time Control of a Hot Air Plant using RTOS µC/OSII

Due Date: Week of Nov. 2nd, 2010

Page 2: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Today's Activities

Lab 3 Presentation Special topic presentation

Rate Monotonic Scheduling (RMS) Lab 2 demos.

Page 3: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Lab 1 Development Environment

LabVIEW 2009 software Nios II IDE Altera Nios II Embedded Evaluation

Kit

Page 4: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Simple Hot Air BlowerPT 326 Process Trainer

Page 5: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Lab 1 Architecture

UART Write Serial Read

UART Read Serial Write

LabVIEWAltera Nios II

Plant ModelPlant Comm.

PID Controller

Operator Input

Feedback Signal

Control Signal

Input Voltage

Measured Voltage

Page 6: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Plant/Controller Features

Page 7: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Lab Requirements

Plant interface Input from plant Output to plant

PID control system Operator Interface

LCD display Operator input

Page 8: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Plant Interface

Input from plant Plant output voltage (from LabVIEW)

Output to plant Heater control (manipulated variable)

Communication implemented using serial communication with termination character.

Page 9: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Operator Interface - Inputs

Input from LCD touch screen ON/OFF signal Auto/Manual mode control Setpoint voltage (Auto Mode) Voltage input (Manual Mode)

Page 10: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Operator Interface - Outputs Output to LCD

Voltage/Time graph (Lab 1) + voltage setpoint

Current sampling time Voltage reference Voltage output (output to plant) Proportional gain (Kc) Integral time (Ti) Derivative Time (Td) Current time (HH:MM:SS)

Page 11: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Operator Display

Page 12: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

PID Control System

m(t) = manipulated variable (output to plant) r(t) = plant setpoint c(t) = controlled variable (voltage from LabVIEW) e(t) = plant error = r(t) – c(t) Kp= Proportional gain Ti = Integral time Td = Derivative time

]/)(()(/1)([)(0

dttedTdtteTteKtm d

t

ip

Page 13: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

PID Control Discrete Time Implementation

)]1()([)()()(

)()1()(

neneKnsKneKnm

nensns

dip

sdpd

ispi

TTKK

TTKK

/

/

Where s(n) is the sum of errors Ts = sampling time = ∆t

Page 14: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Implementation Requirements LabVIEW model

Two tasks: Plant Model task, communication task. Data communication between tasks using queues. Serial communication using termination character

Altera implementation Must employ at least three tasks PID controller must have a dedicated task Semaphores used for data synchronization

Note that ALL timing requirements discussed in the lab manual MUST be implemented.

Task priorities MUST be discussed and justified in your report Time delays on time critical tasks MUST be discussed and

justified in your report

Page 15: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Real-Time System Implementation – pg. 58-59 of lab manual

Page 16: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Real-Time Constraints Control system must operate with a sampling rate

of [100-500] ms ON/OFF buttons

Sampled every 2-5 seconds Auto/Manual controls

Sampled every 2-5 seconds Vinput and Vref buttons

Sampled every 1-2 seconds Clock/Time

Must execute every 1 second Operator display must be updated every 5 seconds

Page 17: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Task Priorities uC/OS II can manage up to 63 tasks OS has it’s own system tasks

It is recommended that you DON’T use priorities 0-5 (Highest priority = 6)

Each task must be assigned a unique priority level.

The lower the priority number the higher the priority of the task

uC/OS II will always execute the highest priority task ready to run.

Page 18: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Assigning Task Priorities Assigning task priorities in complex real-

time systems is a difficult job Noncritical tasks should obviously be given low

priorities Most real-time systems have a

combination of soft and hard requirements Soft RT systems: tasks are performed as quickly

as possible but they don’t have to finish by specific times

Hard RT systems: tasks must be performed correctly within the required time

Page 19: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Rate Monotonic Scheduling (RMS)

Priorities are assigned based on how often the tasks execute Tasks with the highest rate of execution are

given the highest priorities

Task Execution Rate (HZ)

High

Pri

ori

ty

Low

Page 20: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

RMS Theorem– cont… RMS makes a number of assumptions

All tasks are periodic (occur at regular intervals) The CPU must always execute the highest priority

task that is ready to run Given a set of n tasks that are assigned RMS

priorities, the basic RMS theorem states that all task hard-real time deadlines are always met if the following inequality holds

i

n

i

i nT

E)12( /1

Page 21: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Where Ei= maximum execution time of task i Ti= execution period of task i Ei/Ti = the fraction of CPU time required to execute task i

Note: CPU use of all time-critical tasks should be less than 70%

Cont…

i

n

i

i nT

E)12( /1

Number of Tasks

1 1.000

2 0.828

3 0.779

Inf 0.693

)12( /1 nn

Page 22: Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2 nd, 2010

Deadlines and Marking Lab 3 is worth 12%. 6% for the report, and 6% for the

demo The Demo is due Nov. 2nd, 2010 in the

Lab. The Report is due Nov. 2nd, 2010 in

the Lab. A signed group evaluation sheet must

be submitted with the lab report