220 likes | 235 Views
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. Lab 1 Development Environment. LabVIEW 2009 software Nios II IDE
E N D
Lab 3 Real-Time Control of a Hot Air Plant using RTOS µC/OSII Due Date: Week of Nov. 2nd, 2010
Today's Activities • Lab 3 Presentation • Special topic presentation • Rate Monotonic Scheduling (RMS) • Lab 2 demos.
Lab 1 Development Environment • LabVIEW 2009 software • Nios II IDE • Altera Nios II Embedded Evaluation Kit
Lab 1 Architecture Control Signal Input Voltage UART Write Serial Read Altera Nios II LabVIEW Plant Comm. PID Controller Operator Input Plant Model UART Read Serial Write Feedback Signal Measured Voltage
Lab Requirements • Plant interface • Input from plant • Output to plant • PID control system • Operator Interface • LCD display • Operator input
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.
Operator Interface - Inputs • Input from LCD touch screen • ON/OFF signal • Auto/Manual mode control • Setpoint voltage (Auto Mode) • Voltage input (Manual Mode)
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)
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
PID Control Discrete Time Implementation • Where s(n) is the sum of errors • Ts = sampling time = ∆t
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
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
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.
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
High Priority Low Task Execution Rate (HZ) 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
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
Cont… • 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%
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