Introduction |
|
xv | |
Acknowledgements |
|
xix | |
|
PART I Essentials of Embedded Systems, using the mbed |
|
|
|
Chapter 1 Embedded Systems, Microcontrollers and ARM |
|
|
3 | (14) |
|
1.1 Introducing Embedded Systems |
|
|
3 | (3) |
|
1.1.1 What is an Embedded System? |
|
|
3 | (2) |
|
1.1.2 An Example Embedded System |
|
|
5 | (1) |
|
1.2 Microprocessors and Microcontrollers |
|
|
6 | (3) |
|
1.2.1 Some Computer Essentials |
|
|
7 | (1) |
|
1.2.2 The Microcontroller |
|
|
8 | (1) |
|
1.3 Development Processes in Embedded Systems |
|
|
9 | (2) |
|
1.3.1 Programming Languages: What is so Special about C/C++? |
|
|
9 | (1) |
|
1.3.2 The Development Cycle |
|
|
10 | (1) |
|
|
11 | (6) |
|
|
12 | (1) |
|
1.4.2 Some Technical Detail: What does this RISC Word Mean? |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
Chapter 2 Introducing the mbed |
|
|
17 | (12) |
|
|
17 | (5) |
|
2.1.1 The mbed Architecture |
|
|
19 | (2) |
|
2.1.2 The LPC1768 Microcontroller |
|
|
21 | (1) |
|
2.2 Getting Started with the mbed: A Tutorial |
|
|
22 | (3) |
|
Step 1 Connecting the mbed to the PC |
|
|
22 | (1) |
|
Step 2 Creating an mbed Account |
|
|
23 | (1) |
|
|
23 | (1) |
|
Step 4 Compiling the Program |
|
|
24 | (1) |
|
Step 5 Downloading the Program Binary Code |
|
|
25 | (1) |
|
Step 6 Modifying the Program Code |
|
|
25 | (1) |
|
2.3 The Development Environment |
|
|
25 | (4) |
|
2.3.1 The mbed Compiler and API |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
27 | (2) |
|
Chapter 3 Digital Input and Output |
|
|
29 | (28) |
|
|
29 | (5) |
|
3.1.1 Thinking about the First Program |
|
|
30 | (2) |
|
3.1.2 Understanding the mbed API |
|
|
32 | (1) |
|
3.1.3 Exploring the while Loop |
|
|
33 | (1) |
|
3.2 Voltages as Logic Values |
|
|
34 | (2) |
|
3.3 Digital Output on the mbed |
|
|
36 | (3) |
|
|
36 | (1) |
|
3.3.2 Using mbed External Pins |
|
|
37 | (2) |
|
|
39 | (3) |
|
3.4.1 Connecting Switches to a Digital System |
|
|
39 | (1) |
|
|
40 | (1) |
|
3.4.3 Using if to Respond to a Switch Input |
|
|
40 | (2) |
|
3.5 Interfacing Simple Opto Devices |
|
|
42 | (7) |
|
3.5.1 Opto Reflective and Transmissive Sensors |
|
|
42 | (1) |
|
3.5.2 Connecting an Opto-Sensor to the mbed |
|
|
43 | (2) |
|
3.5.3 Seven-Segment Displays |
|
|
45 | (1) |
|
3.5.4 Connecting a Seven-segment Display to the mbed |
|
|
46 | (3) |
|
3.6 Switching Larger DC Loads |
|
|
49 | (4) |
|
3.6.1 Applying Transistor Switching |
|
|
49 | (1) |
|
3.6.2 Switching a Motor with the mbed |
|
|
50 | (1) |
|
3.6.3 Switching Multiple Seven-Segment Displays |
|
|
51 | (2) |
|
3.7 Mini-Project: Letter Counter |
|
|
53 | (4) |
|
|
53 | (1) |
|
|
53 | (2) |
|
|
55 | (2) |
|
|
57 | (20) |
|
4.1 Introducing Data Conversion |
|
|
57 | (2) |
|
4.1.1 The Digital-to-Analog Converter |
|
|
58 | (1) |
|
4.2 Analog Outputs on the mbed |
|
|
59 | (6) |
|
4.2.1 Creating Constant Output Voltages |
|
|
60 | (1) |
|
|
60 | (3) |
|
4.2.3 Testing the DAC Resolution |
|
|
63 | (1) |
|
4.2.4 Generating a Sine Wave |
|
|
64 | (1) |
|
4.3 Another Form of Analog Output: Pulse Width Modulation |
|
|
65 | (1) |
|
4.4 Pulse Width Modulation on the mbed |
|
|
66 | (11) |
|
4.4.1 Using the mbed PWM Sources |
|
|
66 | (1) |
|
4.4.2 Some Trial PWM Outputs |
|
|
67 | (1) |
|
4.4.3 Speed Control of a Small Motor |
|
|
68 | (2) |
|
4.4.4 Generating PWM in Software |
|
|
70 | (1) |
|
|
71 | (1) |
|
4.4.6 Outputting to a Piezo Transducer |
|
|
72 | (2) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (2) |
|
|
77 | (18) |
|
5.1 Analog-to-Digital Conversion |
|
|
77 | (5) |
|
5.1.1 The Analog-to-Digital Converter |
|
|
78 | (1) |
|
5.1.2 Range, Resolution and Quantization |
|
|
79 | (2) |
|
|
81 | (1) |
|
5.1.4 Analog Input with the mbed |
|
|
82 | (1) |
|
5.2 Combining Analog Input and Output |
|
|
82 | (4) |
|
5.2.1 Controlling LED Brightness by Variable Voltage |
|
|
82 | (2) |
|
5.2.2 Controlling LED Brightness by PWM |
|
|
84 | (1) |
|
5.2.3 Controlling PWM Frequency |
|
|
84 | (2) |
|
5.3 Processing Data from Analog Inputs |
|
|
86 | (2) |
|
5.3.1 Displaying Values on the Computer Screen |
|
|
86 | (1) |
|
5.3.2 Scaling ADC Outputs to Recognized Units |
|
|
87 | (1) |
|
5.3.3 Applying Averaging to Reduce Noise |
|
|
87 | (1) |
|
5.4 Some Simple Analog Sensors |
|
|
88 | (2) |
|
5.4.1 The Light-Dependent Resistor |
|
|
88 | (1) |
|
5.4.2 Integrated Circuit Temperature Sensor |
|
|
89 | (1) |
|
5.5 Exploring Data Conversion Timing |
|
|
90 | (2) |
|
5.5.1 Estimating Conversion Time and Applying Nyquist |
|
|
90 | (2) |
|
5.6 Mini-Project: Two-Dimensional Light Tracking |
|
|
92 | (3) |
|
|
92 | (1) |
|
|
93 | (1) |
|
|
93 | (2) |
|
Chapter 6 Further Programming Techniques |
|
|
95 | (20) |
|
6.1 The Benefits of Considered Program Design and Structure |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
97 | (3) |
|
6.3.1 Using Flowcharts to Define Code Structure |
|
|
97 | (2) |
|
|
99 | (1) |
|
6.4 Working with Functions on the mbed |
|
|
100 | (5) |
|
6.4.1 Implementing a Seven-Segment Display Counter |
|
|
100 | (2) |
|
|
102 | (1) |
|
6.4.3 A More Complex Program Using Functions |
|
|
103 | (2) |
|
6.5 Using Multiple Files in C/C++ |
|
|
105 | (4) |
|
6.5.1 Overview of the C/C++ Program Compilation Process |
|
|
106 | (1) |
|
6.5.2 The C/C++ Preprocessor and Preprocessor Directives |
|
|
107 | (1) |
|
6.5.3 The #ifndef Directive |
|
|
108 | (1) |
|
6.5.4 Using mbed Objects Globally |
|
|
109 | (1) |
|
6.6 Modular Program Example |
|
|
109 | (6) |
|
|
113 | (1) |
|
|
113 | (2) |
|
Chapter 7 Starting with Serial Communication |
|
|
115 | (32) |
|
7.1 Introducing Synchronous Serial Communication |
|
|
115 | (2) |
|
7.2 Serial Peripheral Interface |
|
|
117 | (8) |
|
|
117 | (2) |
|
|
119 | (1) |
|
7.2.3 Setting up an mbed SPI Master |
|
|
119 | (2) |
|
7.2.4 Creating a SPI Data Link |
|
|
121 | (4) |
|
7.3 Intelligent Instrumentation and a SPI Accelerometer |
|
|
125 | (4) |
|
7.3.1 Introducing the ADXL345 Accelerometer |
|
|
125 | (1) |
|
7.3.2 Developing a Simple ADXL345 Program |
|
|
125 | (4) |
|
|
129 | (1) |
|
7.5 The Inter-Integrated Circuit Bus |
|
|
129 | (6) |
|
7.5.1 Introducing the I2C Bus |
|
|
129 | (2) |
|
|
131 | (1) |
|
7.5.3 Setting up an I2C Data Link |
|
|
131 | (4) |
|
7.6 Communicating with an I2C Temperature Sensor |
|
|
135 | (3) |
|
7.7 Using the SRF08 Ultrasonic Range Finder |
|
|
138 | (2) |
|
|
140 | (1) |
|
7.9 Asynchronous Serial Data Communication |
|
|
140 | (4) |
|
7.9.1 Introducing Asynchronous Serial Data |
|
|
140 | (1) |
|
7.9.2 Applying Asynchronous Communication on the mbed |
|
|
141 | (3) |
|
7.9.3 Applying Synchronous Communication with the Host Computer |
|
|
144 | (1) |
|
7.10 Mini-Project: Multi-Node I2C Bus |
|
|
144 | (3) |
|
|
144 | (1) |
|
|
145 | (1) |
|
|
145 | (2) |
|
Chapter 8 Liquid Crystal Displays |
|
|
147 | (22) |
|
|
147 | (3) |
|
8.1.1 Introducing Liquid Crystal Technology |
|
|
148 | (1) |
|
8.1.2 Liquid Crystal Character Displays |
|
|
149 | (1) |
|
8.2 Using the PC1602F LCD |
|
|
150 | (10) |
|
8.2.1 Introducing the PC1602F Display |
|
|
151 | (1) |
|
8.2.2 Connecting the PC1602F to the mbed |
|
|
152 | (1) |
|
8.2.3 Using Modular Coding to Interface the LCD |
|
|
153 | (1) |
|
8.2.4 Initializing the Display |
|
|
154 | (1) |
|
8.2.5 Sending Display Data to the LCD |
|
|
155 | (1) |
|
8.2.6 The Complete LCD.cpp Definition |
|
|
156 | (1) |
|
8.2.7 Utilizing the LCD Functions |
|
|
157 | (1) |
|
8.2.8 Adding Data to a Specified Location |
|
|
158 | (2) |
|
8.3 Using the mbed TextLCD Library |
|
|
160 | (2) |
|
8.4 Displaying Analog Input Data on the LCD |
|
|
162 | (1) |
|
|
163 | (3) |
|
|
163 | (1) |
|
8.5.2 Controlling a SPI LCD Mobile Phone Display |
|
|
163 | (3) |
|
8.6 Mini-Project: Digital Spirit Level |
|
|
166 | (3) |
|
|
167 | (1) |
|
|
167 | (1) |
|
|
167 | (2) |
|
Chapter 9 Interrupts, Timers and Tasks |
|
|
169 | (38) |
|
9.1 Time and Tasks in Embedded Systems |
|
|
170 | (1) |
|
9.1.1 Timers and Interrupts |
|
|
170 | (1) |
|
|
170 | (1) |
|
9.1.3 Event-Triggered and Time-Triggered Tasks |
|
|
171 | (1) |
|
9.2 Responding to Event-Triggered Events |
|
|
171 | (2) |
|
|
171 | (1) |
|
9.2.2 Introducing Interrupts |
|
|
172 | (1) |
|
9.3 Simple Interrupts on the mbed |
|
|
173 | (2) |
|
9.4 Getting Deeper into Interrupts |
|
|
175 | (6) |
|
9.4.1 Interrupts on the LPC1768 |
|
|
178 | (1) |
|
9.4.2 Testing Interrupt Latency |
|
|
178 | (1) |
|
9.4.3 Disabling Interrupts |
|
|
179 | (1) |
|
9.4.4 Interrupts from Analog Inputs |
|
|
180 | (1) |
|
9.4.5 Conclusion on Interrupts |
|
|
181 | (1) |
|
9.5 An Introduction to Timers |
|
|
181 | (2) |
|
9.5.1 The Digital Counter |
|
|
181 | (1) |
|
9.5.2 Using the Counter as a Timer |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
183 | (4) |
|
9.6.1 Using Multiple mbed Timers |
|
|
184 | (1) |
|
9.6.2 Testing the Timer Duration |
|
|
185 | (2) |
|
9.7 Using the mbed Timeout |
|
|
187 | (4) |
|
9.7.1 A Simple Timeout Application |
|
|
187 | (2) |
|
9.7.2 Further Use of Timeout |
|
|
189 | (1) |
|
9.7.3 Timeout used to Test Reaction Time |
|
|
190 | (1) |
|
9.8 Using the mbed Ticker |
|
|
191 | (4) |
|
9.8.1 Using Ticker for a Metronome |
|
|
192 | (2) |
|
9.8.2 Reflecting on Multi-Tasking in the Metronome Program |
|
|
194 | (1) |
|
|
195 | (1) |
|
|
196 | (2) |
|
|
198 | (9) |
|
9.11.1 A Self-Contained Metronome |
|
|
198 | (1) |
|
9.11.2 Accelerometer Threshold Interrupt |
|
|
198 | (1) |
|
|
199 | (1) |
|
|
199 | (8) |
|
Chapter 10 Memory and Data Management |
|
|
207 | (12) |
|
|
201 | (4) |
|
10.1.1 Memory Function Types |
|
|
201 | (1) |
|
10.1.2 Essential Electronic Memory Types |
|
|
202 | (3) |
|
10.2 Using Data Files with the mbed |
|
|
205 | (2) |
|
10.2.1 Reviewing some Useful C/C++ Library Functions |
|
|
205 | (1) |
|
10.2.2 Defining the mbed Local File System |
|
|
205 | (1) |
|
10.2.3 Opening and Closing Files |
|
|
206 | (1) |
|
10.2.4 Writing and Reading File Data |
|
|
206 | (1) |
|
10.3 Example mbed Data File Access |
|
|
207 | (3) |
|
|
207 | (1) |
|
10.3.2 String File Access |
|
|
208 | (1) |
|
10.3.3 Using Formatted Data |
|
|
209 | (1) |
|
10.4 Using External Memory with the mbed |
|
|
210 | (2) |
|
10.5 Introducing Pointers |
|
|
212 | (2) |
|
10.6 Mini-Project: Accelerometer Data Logging on Exceeding Threshold |
|
|
214 | (5) |
|
|
215 | (1) |
|
|
216 | (1) |
|
|
216 | (3) |
|
PART II Moving to Advanced and Specialist Applications |
|
|
|
Chapter 11 An Introduction to Digital Signal Processing |
|
|
219 | (24) |
|
11.1 What is a Digital Signal Processor? |
|
|
219 | (1) |
|
11.2 Digital Filtering Example |
|
|
220 | (2) |
|
|
222 | (7) |
|
11.3.1 Input and Output of Digital Data |
|
|
222 | (2) |
|
11.3.2 Signal Reconstruction |
|
|
224 | (1) |
|
11.3.3 Adding a Digital Low-Pass Filter |
|
|
224 | (4) |
|
11.3.4 Adding a Push-Button Activation |
|
|
228 | (1) |
|
11.3.5 Digital High-Pass Filter |
|
|
229 | (1) |
|
|
229 | (3) |
|
11.5 Working with Wave Audio Files |
|
|
232 | (7) |
|
11.5.1 The Wave Information Header |
|
|
233 | (2) |
|
11.5.2 Reading the Wave File Header with the mbed |
|
|
235 | (1) |
|
11.5.3 Reading and Outputting Mono Wave Data |
|
|
236 | (3) |
|
|
239 | (1) |
|
11.7 Mini-Project: Stereo Wave Player |
|
|
240 | (3) |
|
11.7.1 Basic Stereo Wave Player |
|
|
240 | (1) |
|
11.7.2 Stereo Wave Player with PC Interface |
|
|
240 | (1) |
|
11.7.3 Portable Stereo Wave Player with Mobile Phone Display Interface |
|
|
241 | (1) |
|
|
241 | (1) |
|
|
241 | (1) |
|
|
242 | (1) |
|
Chapter 12 Advanced Serial Communications |
|
|
243 | (30) |
|
12.1 Introducing Advanced Serial Communication Protocols |
|
|
243 | (1) |
|
12.2 Bluetooth Serial Communication |
|
|
244 | (7) |
|
12.2.1 Introducing Bluetooth |
|
|
244 | (1) |
|
12.2.2 Interfacing the RN-41 and RN-42 Bluetooth Modules |
|
|
244 | (1) |
|
12.2.3 Sending mbed Data over Bluetooth |
|
|
245 | (2) |
|
12.2.4 Receiving Bluetooth Data from a Host Terminal Application |
|
|
247 | (1) |
|
12.2.5 Communicating between Two mbeds on Bluetooth |
|
|
248 | (3) |
|
|
251 | (4) |
|
12.3.1 Using the mbed to Emulate a USB Mouse |
|
|
252 | (1) |
|
12.3.2 Sending USB MIDI Data from an mbed |
|
|
253 | (2) |
|
12.4 Introducing Ethernet |
|
|
255 | (6) |
|
|
255 | (2) |
|
12.4.2 Implementing Simple mbed Ethernet Communications |
|
|
257 | (2) |
|
12.4.3 Ethernet Communication between mbeds |
|
|
259 | (2) |
|
12.5 Local Network and Internet Communications with the mbed |
|
|
261 | (12) |
|
12.5.1 Using the mbed as an HTTP Client |
|
|
262 | (2) |
|
12.5.2 Using the mbed as an HTTP File Server |
|
|
264 | (2) |
|
12.5.3 Using Remote Procedure Calls to Modify mbed Outputs |
|
|
266 | (1) |
|
12.5.4 Controlling the mbed using a Remote JavaScript Interface |
|
|
267 | (3) |
|
|
270 | (1) |
|
|
271 | (1) |
|
|
271 | (2) |
|
Chapter 13 An Introduction to Control Systems |
|
|
273 | (24) |
|
|
273 | (7) |
|
13.1.1 Closed and Open Loop Control Systems |
|
|
274 | (1) |
|
13.1.2 Closed Loop Cruise Control Example |
|
|
275 | (1) |
|
13.1.3 Proportional Control |
|
|
276 | (2) |
|
13.1.4 Proportional Integral Derivative Control |
|
|
278 | (2) |
|
13.2 Closed Loop Digital Compass Example |
|
|
280 | (8) |
|
13.2.1 Using the HMC6352 Digital Compass |
|
|
281 | (2) |
|
13.2.2 Implementing a 360 Degree Rotation Servo |
|
|
283 | (2) |
|
13.2.3 Implementing a Closed Loop Control Algorithm |
|
|
285 | (3) |
|
13.3 Communicating Control Data over the Controller Area Network |
|
|
288 | (9) |
|
13.3.1 The Controller Area Network |
|
|
288 | (1) |
|
|
289 | (5) |
|
|
294 | (1) |
|
|
294 | (1) |
|
|
295 | (2) |
|
Chapter 14 Letting Go of the mbed Libraries |
|
|
297 | (24) |
|
|
297 | (1) |
|
14.2 Control Register Concepts |
|
|
298 | (1) |
|
14.3 Digital Input/Output |
|
|
299 | (6) |
|
14.3.1 mbed Digital Input/Output Control Registers |
|
|
299 | (2) |
|
14.3.2 A Digital Output Application |
|
|
301 | (1) |
|
14.3.3 Adding a Second Digital Output |
|
|
302 | (1) |
|
|
303 | (2) |
|
14.4 Getting Deeper into the Control Registers |
|
|
305 | (5) |
|
14.4.1 Pin Select and Pin Mode Registers |
|
|
305 | (3) |
|
14.4.2 Power Control and Clock Select Registers |
|
|
308 | (2) |
|
|
310 | (2) |
|
14.5.1 mbed DAC Control Registers |
|
|
310 | (1) |
|
|
311 | (1) |
|
|
312 | (6) |
|
14.6.1 mbed ADC Control Registers |
|
|
312 | (2) |
|
14.6.2 An ADC Application |
|
|
314 | (2) |
|
14.6.3 Changing ADC Conversion Speed |
|
|
316 | (2) |
|
14.7 A Conclusion on using the Control Registers |
|
|
318 | (3) |
|
|
319 | (1) |
|
|
319 | (1) |
|
|
319 | (2) |
|
Chapter 15 Extension Projects |
|
|
321 | (10) |
|
15.1 Where do We Go from Here? |
|
|
321 | (1) |
|
15.2 Pololu Robot for mbed |
|
|
321 | (2) |
|
15.3 Advanced Audio Projects |
|
|
323 | (1) |
|
15.4 The Internet of Things |
|
|
323 | (2) |
|
15.5 Introducing the mbed LPC11U24 |
|
|
325 | (1) |
|
15.6 From mbed to Manufacture |
|
|
326 | (3) |
|
|
329 | (2) |
|
|
329 | (2) |
Appendix A Some Number Systems |
|
331 | (8) |
Appendix B Some C Essentials |
|
339 | (20) |
Appendix C mbed Technical Data |
|
359 | (6) |
Appendix D Parts List |
|
365 | (4) |
Appendix E The Tera Term Terminal Emulator |
|
369 | (4) |
Index |
|
373 | |