Shawn Schaffert's ratcheting scheduler
Real Time Operating Systems
Even though this project is about a
smart home dashboard that doesn't necessarily have any time-critical tasks, it very easily could. What if a cloud covered the solar panels, and I wanted to dim the lights in response. I don't want my software to wait for all the temperature sensors to finish updated before changing the lighting. To avoid this potential problem, I want a "Real Time Operating System" for my project.
Systems using embedded controllers are often characterized by the
need to exhibit real-time computing behavior. It’s important
to understand what this means and how it affects the choice of software to use
in a project. No one would argue that computers have been getting faster and
faster over the years. Hard drive, memory, video card, and motherboard speeds
and clock rates have been steadily increasing with each new generation of
hardware. This has meant that the user can run complex applications without
having to wait unreasonable amounts of time, and that simple applications
perform their functions in vanishingly small time increments. For most desktop
applications, small delays in program execution are unnoticeable and
insignificant. But what if part of your application monitors the emergency-stop button for your home-built CNC
milling machine? You need the emergency-stop button to shut the
machine down within a guaranteed amount of time. Not having this determinism could create a very
dangerous situation if, say, a background task like playing music or
saving a file have momentarily taken over the computer bandwidth. You press
and release the emergency-stop and watch in horror as your mill bit keeps going
right through your part.
It doesn’t take a powerful or fast CPU to give a timely response
to a single bit change in a peripheral I/O register. Anyone who has programmed
a port interrupt in a simple 8-bit microcontroller can figure out how long it
will take for the 8-bit processor to capture the I/O interrupt and call the
code to respond to the event. With PC operating systems like OSX, Windows, and Linux, there is some ability to implement
“real-time” threads, but this capability is often implemented by overriding the
operating system’s normal behavior by using an operating system add-on
to achieve this capability. These operating systems were designed to be
effective general purpose tools for running a wide variety of applications and
interacting with numerous third-party hardware devices, but they were not designed to have real-time, deterministic behavior.
A true real-time operating system (RTOS) is designed
with features such that a program can be split into tasks which run on a fixed
schedule, and asynchronous events, such as the CNC mill emergency-stop button
press, will have a guaranteed maximum latency before they execute. You can write a program to
toggle one I/O pin at 5 kHz and another at 1 kHz with minimal jitter, or program the emergency stop button response to shut
off your CNC mill motors within a guaranteed 1 millisecond.
Numerous native RTOSs exist, many of which are listed below:
I leave it to the reader to explore the features of each operating system listed here. Just like deciding between hardware vendors, it can be a daunting task to evaluate so many operating systems. It is important to consider what CPU the OS runs on, how much the OS costs, how much memory it requires, how programmer friendly the development tools are, what is included in the libraries, and more.
Windows Embedded CE 6.0 R2
Of course this is a series of posts about projects using Windows Embedded CE 6.0 R2, so I’ll focus my attention on this tool, and it is exactly that - a tool to facilitate a task. It’s user base has traditionally been professional engineers and developers creating a wide variety of commercial products. Like any tool, it is has certain features which make it appropriate to solve a particular problem. Windows Embedded CE is a real-time operating system and was created as such. It is not a scaled-down version of the Windows desktop operating system or a version of Windows Mobile. Some of it’s features are listed below:
Downloading and Installation
One area for improvement for the Windows Embedded CE tools is the download and install process. Recommended workstation configuration to develop with Windows Embedded CE are:
• PC with 933 MHz or faster processor; 2 GHz recommended
• Microsoft Windows 2000 Professional SP4 or Microsoft Windows XP Professional SP2 (English or Japanese recommended)
• 512 MB of RAM; 1 GB recommended
• 18 GB of available space required on installation drive
• 1 GB of available space required on system drive
• DVD-ROM Drive
• Display monitor that supports 1024 x 768 high color — 16-bit color
Most of the SPARK hardware partners provide a DVD with Visual
Studio and Windows Embedded CE 6.0 as part of the SPARK hardware promotion.
That is definitely the way to go, but if you don’t have the DVD, you can
download all the files from Microsoft. A nice list has been posted on Mike Hall’s Windows Embedded Blog with the
steps for downloading and installing the tools:
• Install Visual Studio 2005
• Install Visual Studio 2005 SP1
• Install Visual Studio 2005 SP1 for Vista (not required
for XP)
• Install Windows Embedded CE 6.0 (Eval link)
• Install Windows Embedded CE 6.0 SP1
• Install Windows Embedded CE 6.0 R2
• Install Windows Embedded CE 6.0 cumulative product update
package (through 12/31/2008)
• Install Windows Embedded CE 6.0 monthly update package
(Jan 2009)
• Install Windows Embedded CE 6.0 monthly update package
(Feb 2009)
• Install Windows Embedded CE 6.0 monthly update package
(Mar 2009)
• Install Windows Embedded CE 6.0 monthly update package
(Apr 2009)
• Install Windows Embedded CE 6.0 monthly update package
(May 2009)
Learning Materials
Microsoft has done a good job providing educational material to help programmers get started with Windows Embedded CE. The
classroom packets are designed to give an overview of the tool and how to use it, and there are a number of
hands-on labs that put the hardware and software together and give an entry point to creating your first application. Next time, I will take you through that process.