Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview – Multitasking Basics

Similar presentations


Presentation on theme: "Overview – Multitasking Basics"— Presentation transcript:

1 Overview – Multitasking Basics
Multitasking and RTOS Overview – Multitasking Basics August 26, 2013 Charles J. Lord, PE President, Consultant, Trainer Blue Ridge Advanced Design and Automation

2 This Week’s Agenda 8/26 Multitasking Basics 8/27 State Machines I 8/28 State Machines II / Round Robin 8/29 Finishing it Up 8/30 An Example RTOS

3 This Week’s Agenda 8/26 Multitasking Basics 8/27 State Machines I 8/28 State Machines II / Round Robin 8/29 Finishing it Up 8/30 An Example RTOS

4 Multitasking, RTOS, and Real Life
We hear a lot about the proliferation of RTOS on myriad processors, even some 8-bit machines, but when do we need a real-time operating system (RTOS)? Just how critical is timing and interoperation? Cost of chip size, power consumption “small ARM” vs 8/16 bit “Free” RTOS and many paid ones, plus alternatives (kernals, etc)

5 Distributed Processing
8-bit 8-bit Control / Data (typically i2c) 8-bit

6 Multitasking Approach
32-bit (typically)

7 Multitasking Dividing duties requires capability to:
Switch tasks cleanly without corruption Determine priorities when conflicts occur Provide clean, independent storage for each task Provide communications between tasks when needed Accomplishing the above usually requires robust timing control

8 Simple Example – RTOS? Picture a simple digital alarm clock with hours and minutes display Primary task: update the counters every minute to display the current time Other tasks: set time, set alarm, determine if alarm should sound, enable snooze, other possible operator interaction. RTOS not necessary – a few simple interrupts State machine?

9 A little more realistic example
We will look at an industrial washer (similar to a dishwasher) – simplified The I/O is simple: start button, a door switch, a two digit minutes countdown display, two LEDs, a water valve solenoid, a motor on/off, and a motor direction (wash / drain), and a ‘water level full’ input. Please note for simplicity that we are ignoring many real-world features like error sense and recovery!

10 Our Washer CPU Motor Run Motor Direction Water On Door Lock
Water Level Full Wash Rinse

11 Our States Idle – unit is not operating Filling to wash
Wash cycle (10 minutes) Drain from wash Fill to rinse Rinse cycle (10 minutes) Drain from rinse

12 Our States IDLE: Motor, water, all LEDs and display off
Door Locked and start button pressed, go to FILL-TO-WASH FILL-TO-WASH: Water on, motor off, counter “FF” If door locked = FALSE, go to IDLE If water level full, go to WASH

13 Our States WASH: Water off, motor on, motor direction = wash
Start countdown timer from 10 minutes on entry Display time Turn on Wash LED If door unlocked, go to IDLE On time = 00, go to DRAIN-FROM-WASH

14 Our States DRAIN-FROM-WASH:
Motor on, Motor direction = drain, water off Counter display = “dr”, LEDs off Set timer for one minute If door unlocked, go to IDLE If timer = 00, go to FILL-TO-RINSE

15 Our States FILL-TO-RINSE: Water on, motor off, counter “FF”
If door locked = FALSE, go to IDLE If water level full, go to RINSE

16 Our States RINSE: Water off, motor on, motor direction = wash
Start countdown timer from 10 minutes on entry Display time Turn on Wash LED If door unlocked, go to IDLE On time = 00, go to DRAIN-FROM-RINSE

17 Our States DRAIN-FROM-RINSE:
Motor on, Motor direction = drain, water off Counter display = “dr”, LEDs off Set timer for one minute If door unlocked, go to IDLE If timer = 00, go to IDLE

18 What’s Next? As we have described the project in “states”, we will first build the project as a simple state machine over the next two days. We will look at how to initialize each state, and may add other states as needed. Later this week, we will look at another approach – the round robin – and re-define our states as “tasks” On Friday we will look at an RTOS implementation

19 This Week’s Agenda 8/26 Multitasking Basics 8/27 State Machines I 8/28 State Machines II / Round Robin 8/29 Finishing it Up 8/30 An Example RTOS

20 Please stick around as I answer your questions!
Please give me a moment to scroll back through the chat window to find your questions I will stay on chat as long as it takes to answer! I am available to answer simple questions or to consult (or offer in-house training for your company)


Download ppt "Overview – Multitasking Basics"

Similar presentations


Ads by Google