overview of embedded systems in medical...
TRANSCRIPT
1Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Overview
of
Embedded Systems
in
Medical Applications
2Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Systems
Embedded SystemShorthand for Embedded Processor System Embed microprocessor + fixed program in non-computer system
Computer MicroprocessorInside
Not a Computer
Simplistic definition
3Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Fundamental Architectural AbstractionsDigital computer
Machine that can be programmed to process symbols
SymbolsInstruction
Symbols describing processing of other symbolsMachine can interpret instructions in its machine language
DataSymbol with no intrinsic meaning to machineMeaning of data imposed by user
Microprocessor (μP)Hardware device
Interprets instructions Performs instructions (processes) on data
Program Defines sequence of instructions
4Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
General Purpose Computers and Embedded SystemsA basic distinction
99%1%Share of microprocessors manufactured
Toys, toasters, phones, DVD players, car engines, cameras, medical devices
PC, workstation, file server, mainframe
Examples
√√User can access + add + modify data
√User can access + add + modify programs
√√Microprocessor performs instructions on data
√√Microprocessor‐based
Embedded SystemGeneral Purpose (GP)
5Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Why Embedded Processors?
DevicesWater heater / pump, level / temperature gauges, motor, indicators
Before 1990Motorized mechanical controller
Operates devices in pre-set sequenceGears, cogs, mechanical switches
Modify controller for each modelUpdate ⇒ redesign physical controller
After 1990
Microprocessor controllerOperates devices in programmed sequenceDigital timing and electronic switches
Modify controller program for each modelUpdate ⇒ change program code
Example — washing machine controller
6Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Economic Considerations
Product costCost = NRE + MC × N
NRE = non-recurring engineering = R&D cost (salaries)MC = manufacturing cost per unitN = number of units manufactured
Pure hardware productsMC → large
Entire product is hardwareLow product re-use ⇒ poor economies of scale
NRE → large Highly specific R&DSlow testing / update turn-aroundShortage of electrical and mechanical engineers
Higher salaries (since 2000)
Pure hardware products
7Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Economic Considerations
Product costCost = NRE + MC × N
NRE = non-recurring engineering = R&D cost (salaries)MC = manufacturing cost per unitN = number of units manufactured
Pure software productsMC → 0
Entire product is software
NRER&D is primary costComplex development techniques to lower cost
Object oriented design, middleware platforms, standard librariesComplex design can harm performance and reliability
Multiple stages of processingStandard software ⇒ less well understood
Pure software products
8Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Economic Considerations
Product costCost = NRE + MC × N
NRE = non-recurring engineering = R&D cost (salaries)MC = manufacturing cost per unitN = number of units manufactured
Embedded software products
MC significant for large NEmbedded software ⇒ improved hardware re-use + economies of scale
NRE Accept higher R&D cost to lower MCAvoid highly complex software modelsProgram in core systems in C and assemblyRestrict memory usage
Embedded software products
9Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical EquipmentFamiliar examples
GlucoseTest Set
PortableEKG
MRI
10Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical Equipment
Components User interface (UI)
ButtonsText-oriented screen
Strip connectorBatteryController (system-on-chip)
Programming tasksOperate UI
Detect buttonsDisplay text
Detect stripControl blood test cycleTest battery, temperature,
program sanity, ...
Glucose test set
11Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical Equipment
Components User interface (UI)
ButtonsGraphics-oriented screen
Electrode connectorBatteryController
Programming tasksOperate UI
Detect buttonsDisplay text + graphics
Control electrode amplifiers + A/DControl digital signal processing (DSP) of input signalsGenerate graphic display signalsTest battery, temperature, program sanity, ...
Portable EKG
12Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical Equipment
Components Multiple user interfacesPatient tableMagnetic field and RF sourcesElectromagnetic field detectorPower supply Controller
Programming tasksOperate UIsControl tableControl magnetic field and RF transmissionControl electromagnetic field detectorImaging algorithms and graphics processingTest system sanity
Magnetic Resonance Imaging (MRI)
13Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical Equipment
Hardware engineeringDesign of peripheral components
Sensors, actuators, displaysCharacterization of peripherals Design of device driversDesign of generic programmable embedded platformsGoal — specify hardware as API abstraction
Software engineeringDefining system requirementsSpecifying generic platformHigh level system software planningLower level software design Procedure / class codingDriver integrationGoal — interact with hardware via API
Division of labor
14Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Embedded Medical Equipment
Philips Research, Embedded Systems in Healthcare, 2008
Example: software technologies used in MRI
Scanning hardware: nanoseconds
Real‐time software: 1 millisecond
User interaction: 0.1 –1 second
Timing accuracy
8 million lines of code in 30,000 filesSource Code Size
Socket, COM, shared memory, shared filesInterprocess communication
RDBMS, flat files, indexed and sequential files, XMLPersistent Storage
C, C++/STL, C#, Visual Basic, ASP, JavaScript, Perl, Batch, and other proprietary languages
Programming Languages
15Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Typical System StructureHardware
Microcontroller (μC)Microprocessor (μP) + memory + timers + device controllers
DevicesSensors receive signals from physical environmentActuators act on physical environmentDisplays provide indications to user
Specialized controllers — very large scale integrated circuits (VLSI)
Software Fixed program code (FIRMWARE) not directly accessible to userInitialization / reset routineMain loop
Polls devices for events requiring attentionResponds to interrupts from devices that require immediate attentionContinues at start of loop
Handler functions for events
16Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Hardware EnvironmentMicrocontroller (μC)
Microprocessor core (μP)Memory
RAM for data + ROM for program (firmware)
Timers Time internal / external eventsWatchdog — timeout resets system if code loop fails
Controller I/OInterrupt controller — external event grabs processor attention Analog ↔ digital converters (A/D and D/A)Digital signal processor (DSP)Serial ↔ parallel converters (UART)
Sensors Position, contact, temperature, pressure, light, …
Actuators Displays, motors, solenoids, relays, valves, transmitters, …
17Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
I/O in DVD PlayerSensors
Switches on user interfaceOn/Off, REV, FF, Pause, Open/Close, Play, Stop, …
Motion detectorsDisk inserted, disk ejected, beginning of disk, end of disk, …
Safety detectors
Dew detector, thermostat, over-voltage, no-signal, …
Actuators
Disk drive motor, insert/eject motorMotor turns
Direction gear control solenoids Solenoid pushes or pulls
18Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Control Theory
Physical System
physical state
physical model
measured statecontrol signalsControllerdesired
physical state calculator
theory ofphysical system
Open Loop Control
Physical System
physical state
physical model
measured statecontrol signals
Controllerdesired
physical statecalculator
theory ofphysical system
Closed Loop Control
sampler
feedback signals
( ) ( ) ( )( )( ) ( )( )n+1 n n
n+1 n
state t = F state t , control t
control t = G target state t
( ) ( ) ( )( )( ) ( ) ( )( )n+1 n n
n+1 n n
state t = F state t , control t
control t = G target state t , measured state t
Interacting with physical environment
19Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Simple ExampleController for wireless mouse
Mouse contains RF transceiverTransmits to USB adapter on PC
Mouse one of several PC devicesIdentifies itself to PC with device ID
Mouse powered by batterySleeps after 5 seconds idleMaintains state Wakes up on motion or button click
20Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Wireless Mouse HardwareSwitches
Mouse buttonsMotion sensors (mechanical or optical)
Detect X-Y positionMicroprocessor
Translates switch and sensor outputs to motion dataManages battery usage and mouse status
Peripheral Engine (PE)Controls RF linkStores device information, button status, and X,Y-position
Radio Transceiver (Transmitter / Receiver)
21Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Mouse Routine (1)
; each loop: SUB CX, loop runtime
; initializationinit: request ID from PC ; send stored request string
describe hardware to PC ; send stored request stringstore X-Y position ; in memory buffer enable reset interrupt ; watchdog timerenable wake-up interrupt ; signal from X-Y or buttonzero 5 second timer ; CX ← 5 second count
; CX == 0 ⇒ 5 second timeout; main loop
L1: read button statuscmp button status, stored status ; Peripheral Engine (PE) encodesJE L2 ; status of 3 buttons andCALL button ; sends button status to PC
L2: read motion detectorscalculate X,Y-positionCMP position, stored position ; Peripheral Engine (PE) encodesJE L3 ; X,Y-position andCALL motion ; sends position to PC
L3: SUB timer, loop runtime ; decrease timerCMP timer,0JE sleep ; if 5 seconds passed, sleepJMP L1 ; continue; end main loop
22Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Mouse Routine (2)
; button press handlerbutton: store button status in PE
instruct PE to send button status to PCzero 5 second timerRET; motion handler
motion: store position in PEinstruct PE to send X,Y -position to PCzero 5 second timerRET; sleep state
sleep: lock PE registers ; store stateturn-off battery to PE and transceiver
wait: JMP wait ; low power do-nothing loop; stays here until interrupt
; wake-up ISRWAKE: unlock PE registers ; wake up
JMP L1 ; continue; reset ISR
reset: JMP init ; start
23Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
The Logic Gate Alternative
X,Y-position logicCounts mouse motion clicksAdjusts stored value in PE memory
Button status logic Encodes button presses to PE
Reset and wake-up logic Initializes and wakes up sleeping mousePuts idle mouse to sleep
String sequence logic Transmits code strings to PC as bits
PeripheralEngine
ButtonStatusLogic
X,Y-PositionCounter
Logic
Timer
StringSequence
UART
Reset andWake-up
Logic
Gate ImplementationsIndividual ICs
Large "footprint"Costly manufacture
Custom ICCostly development
24Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Goals in Embedded DesignReliability
Device operation depends on embedded processorBug is inconvenient, expensive, possibly life-threateningDevice must work 24/7/365 without user reset
PerformanceReal time system
Respond in fixed time limitsSatisfy real world timing constraints
SchedulingOptimized I/O
CostMinimize manufacturing cost for consumer marketFast Time to MarketNo opportunity for future modification
25Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Strict Requirements
NASA Photo ID: S84-27017 (February 11, 1984)
Programmer's nightmare
26Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Multitasking / Concurrency in Embedded SystemsController handles simultaneous independent events
Inputs from external sensorsInternal processesOutputs to external actuators
Programmable ThermostatThree concurrent tasks
Ref: Daniel W. Lewis, Fundamentals of Embedded Software: Where C and Assembly Meet
/* Monitor Keypad */
do forever {
check keypad ;
if (raise temp)
setting++ ;
else if (lower temp)
setting‐‐ ;
}
/* Monitor Time of Day */
do forever {
measure time ;
if (6:00 am)
setting = 72oF ;
else if (11:00 pm)
setting = 60oF ;
}
/* Monitor Temperature */
do forever {
measure temp ;
if (temp < setting)
start furnace ;
else if (temp > setting + delta)
stop furnace ;
}
27Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Design ProcessMethod
Top-down design — process abstraction to physical componentsBottom-up design — construct system to control existing hardware
RequirementsDefine control problem and hardware abstraction
Architectural specificationDetermine high level modules and information flow
Detailed system design Determine functions and information flow within each module
ImplementationCoding in C and assembly language
Debugging Initial debugging in code emulatorTesting code on target system
Using I/O emulationUsing physical platform
28Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Debugging
No bugs allowed
High performance demands
No human operator to perform "workaround"
No extended beta-testing ("service packs")
Hardware/software debugging
Hardware configuration → time consuming
Programmer must understand Hardware behavior (well enough for debugging)
Hardware/software interactions
All possible external situations
Interaction of C code and assembly code
Compiler choices
Debugging usually involves emulation of target system
29Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Development ToolsLanguage tools
Program managerIntegrated code editor, file manager, device database
Assembler, C compiler, linkerAssembly / C language to microcontroller machine language
DebuggerSimulates machine code execution on PCSimulates external I/O
Hardware toolsDevelopment platform
Generic circuit boards with microcontroller and external I/O devices
Device programmerBurn code from PC file to microcontroller internal ROM
Hardware debuggerIn-Circuit Emulator (ICE) — PC connection acts instead of controller In-Circuit Debugger (ICD) — program real controller for debugging
30Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
Development Platform
31Dr. Martin LandOverviewEmbedded Systems — Hadassah College — Spring 2012
In‐Circuit Emulator (ICE)Connection to PC
Connection to target platform