For the first time in a single reference, this book provides the beginner with a coherent and logical introduction to the hardware and software of the PIC32, bringing together key material from the PIC32 Reference Manual, Data Sheets, XC32 C Compiler User's Guide, Assembler and Linker Guide, MIPS32 CPU manuals, and Harmony documentation. This book also trains you to use the Microchip documentation, allowing better life-long learning of the PIC32. The philosophy is to get you started quickly, but to emphasize fundamentals and to eliminate "magic steps" that prevent a deep understanding of how the software you write connects to the hardware.
Applications focus on mechatronics: microcontroller-controlled electromechanical systems incorporating sensors and actuators. To support a learn-by-doing approach, you can follow the examples throughout the book using the sample code and your PIC32 development board. The exercises at the end of each chapter help you put your new skills to practice.
Coverage includes:
- A practical introduction to the C programming language
- Getting up and running quickly with the PIC32
- An exploration of the hardware architecture of the PIC32 and differences among PIC32 families
- Fundamentals of embedded computing with the PIC32, including the build process, time- and memory-efficient programming, and interrupts
- A peripheral reference, with extensive sample code covering digital input and output, counter/timers, PWM, analog input, input capture, watchdog timer, and communication by the parallel master port, SPI, I2C, CAN, USB, and UART
- An introduction to the Microchip Harmony programming framework
- Essential topics in mechatronics, including interfacing sensors to the PIC32, digital signal processing, theory of operation and control of brushed DC motors, motor sizing and gearing, and other actuators such as stepper motors, RC servos, and brushless DC motors
For more information on the book, and to download free sample code, please visit http://www.nu32.org
Key Features
- Extensive, freely downloadable sample code for the NU32 development board incorporating the PIC32MX795F512H microcontroller
- Free online instructional videos to support many of the chapters
- Dedication
- Figure Credits
- Preface
- Contents
- Choices made in this book
- The NU32 development board
- How to use this book in a course
- Website, videos, and flipped classrooms
- Other PIC32 references
- Acknowledgments
- I: Quickstart
- Chapter 1: Quickstart
- Abstract
- 1.1 What You Need
- 1.2 Compiling the Bootloader Utility
- 1.3 Compiling Your First Program
- 1.4 Loading Your First Program
- 1.5 Using make
- 1.6 Chapter Summary
- Chapter 1: Quickstart
- II: Fundamentals
- Chapter 2: Hardware
- Abstract
- 2.1 The PIC32
- 2.2 The NU32 Development Board
- 2.3 Chapter Summary
- 2.4 Exercises
- Chapter 3: Software
- Abstract
- 3.1 The Virtual Memory Map
- 3.2 An Example: simplePIC.c
- 3.3 What Happens When You Build?
- 3.4 What Happens When You Reset the PIC32?
- 3.5 Understanding simplePIC.c
- 3.6 Bootloaded Programs vs. Standalone Programs
- 3.7 Build Summary
- 3.8 Useful Command Line Utilities
- 3.9 Chapter Summary
- 3.10 Exercises
- Chapter 4: Using Libraries
- Abstract
- 4.1 Talking PIC
- 4.2 The NU32 Library
- 4.3 Bootloaded Programs
- 4.4 An LCD Library
- 4.5 Microchip Libraries
- 4.6 Your Libraries
- 4.7 Chapter Summary
- 4.8 Exercises
- Chapter 5: Time and Space
- Abstract
- 5.1 Compiler Optimization
- 5.2 Time and the Disassembly File
- 5.3 Space and the Map File
- 5.4 Chapter Summary
- 5.5 Exercises
- Chapter 6: Interrupts
- Abstract
- 6.1 Overview
- 6.2 Details
- 6.3 Steps to Configure and Use an Interrupt
- 6.4 Sample Code
- 6.5 Chapter Summary
- 6.6 Exercises
- Chapter 2: Hardware
- III: Peripheral Reference
- Chapter 7: Digital Input and Output
- Abstract
- 7.1 Overview
- 7.2 Details
- 7.3 Sample Code
- 7.4 Chapter Summary
- 7.5 Exercises
- Chapter 8: Counter/Timers
- Abstract
- 8.1 Overview
- 8.2 Details
- 8.3 Sample Code
- 8.4 Chapter Summary
- 8.5 Exercises
- Chapter 9: Output Compare
- Abstract
- 9.1 Overview
- 9.2 Details
- 9.3 Sample Code
- 9.4 Chapter Summary
- 9.5 Exercises
- Chapter 10: Analog Input
- Abstract
- 10.1 Overview
- 10.2 Details
- 10.3 Sample Code
- 10.4 Chapter Summary
- 10.5 Exercises
- Chapter 11: UART
- Abstract
- 11.1 Overview
- 11.2 Details
- 11.3 Sample Code
- 11.4 Wireless Communication with an XBee Radio
- 11.5 Chapter Summary
- 11.6 Exercises
- Chapter 12: SPI Communication
- Abstract
- 12.1 Overview
- 12.2 Details
- 12.3 Sample Code
- 12.4 Chapter Summary
- 12.5 Exercises
- Chapter 13: I2C Communication
- Abstract
- 13.1 Overview
- 13.2 Details
- 13.3 Sample Code
- 13.4 Chapter Summary
- 13.5 Exercises
- Chapter 14: Parallel Master Port
- Abstract
- 14.1 Overview
- 14.2 Details
- 14.3 Sample Code
- 14.4 Chapter Summary
- 14.5 Exercises
- Chapter 15: Input Capture
- Abstract
- 15.1 Overview
- 15.2 Details
- 15.3 Sample Code
- 15.4 Chapter Summary
- 15.5 Exercises
- Chapter 16: Comparator
- Abstract
- 16.1 Overview
- 16.2 Details
- 16.3 Sample Code
- 16.4 Chapter Summary
- 16.5 Exercises
- Chapter 17: Sleep, Idle, and the Watchdog Timer
- Abstract
- 17.1 Overview
- 17.2 Details
- 17.3 Sample Code
- 17.4 Chapter Summary
- 17.5 Exercises
- Chapter 18: Flash Memory
- Abstract
- 18.1 Overview
- 18.2 Details
- 18.3 Sample Code
- 18.4 Chapter Summary
- 18.5 Exercises
- Chapter 19: Controller Area Network (CAN)
- Abstract
- 19.1 Overview
- 19.2 Details
- 19.3 Sample Code
- 19.4 Chapter Summary
- 19.5 Exercises
- Chapter 20: Harmony and Its Application to USB
- Abstract
- 20.1 Overview
- 20.2 The Framework
- 20.3 PLIB
- 20.4 Harmony Concepts
- 20.5 Drivers
- 20.6 System Services
- 20.7 Program Structure
- 20.8 USB
- 20.9 Chapter Summary
- 20.10 Exercises
- Chapter 7: Digital Input and Output
- IV: Mechatronics
- Chapter 21: Sensors
- Abstract
- 21.1 Contact: Buttons and Switches
- 21.2 Light
- 21.3 Angle of a Revolute Joint
- 21.4 Position of a Prismatic Joint
- 21.5 Acceleration and Angular Velocity: Gyros, Accelerometers, and IMUs
- 21.6 Magnetic Field Sensing: Hall Effect Sensors
- 21.7 Distance
- 21.8 Force
- 21.9 Temperature
- 21.10 Current
- 21.11 GPS
- 21.12 Exercises
- Chapter 22: Digital Signal Processing
- Abstract
- 22.1 Sampled Signals and Aliasing
- 22.2 The Discrete Fourier Transform
- 22.3 Finite Impulse Response (FIR) Digital Filters
- 22.4 Infinite Impulse Response (IIR) Digital Filters
- 22.5 FFT-Based Filters
- 22.6 DSP on the PIC32
- 22.7 Exercises
- Chapter 23: PID Feedback Control
- Abstract
- 23.1 The PID Controller
- 23.2 Variants of the PID Controller
- 23.3 Empirical Gain Tuning
- 23.4 Model-Based Control
- 23.5 Chapter Summary
- 23.6 Exercises
- Chapter 24: Feedback Control of LED Brightness
- Abstract
- 24.1 Wiring and Testing the Circuit
- 24.2 Powering the LED with OC1
- 24.3 Playing an Open-Loop PWM Waveform
- 24.4 Establishing Communication with MATLAB
- 24.5 Plotting Data in MATLAB
- 24.6 Writing to the LCD Screen
- 24.7 Reading the ADC
- 24.8 PI Control
- 24.9 Additional Features
- 24.10 Chapter Summary
- 24.11 Exercises
- Chapter 25: Brushed Permanent Magnet DC Motors
- Abstract
- 25.1 Motor Physics
- 25.2 Governing Equations
- 25.3 The Speed-Torque Curve
- 25.4 Friction and Motor Efficiency
- 25.5 Motor Windings and the Motor Constant
- 25.6 Other Motor Characteristics
- 25.7 Motor Data Sheet
- 25.8 Chapter Summary
- 25.9 Exercises
- Chapter 26: Gearing and Motor Sizing
- Abstract
- 26.1 Gearing
- 26.2 Choosing a Motor and Gearhead
- 26.3 Chapter Summary
- 26.4 Exercises
- Chapter 27: DC Motor Control
- Abstract
- 27.1 The H-Bridge and Pulse Width Modulation
- 27.2 Motion Control of a DC Motor
- 27.3 Chapter Summary
- 27.4 Exercises
- Chapter 28: A Motor Control Project
- Abstract
- 28.1 Hardware
- 28.2 Software Overview
- 28.3 Software Development Tips
- 28.4 Step by Step
- 28.5 Extensions
- 28.6 Chapter Summary
- 28.7 Exercises
- Chapter 29: Other Actuators
- Abstract
- 29.1 Solenoids
- 29.2 Speakers and Voice Coil Actuators
- 29.3 RC Servos
- 29.4 Stepper Motors
- 29.5 Brushless DC Motors
- 29.6 Linear Brushless Motors
- 29.7 Chapter Summary
- 29.8 Exercises
- Chapter 21: Sensors
- Appendix A: A Crash Course in C
- A.1 Quick Start in C
- A.2 Overview
- A.3 Important Concepts in C
- A.4 C Syntax
- A.5 Exercises
- Appendix B: Circuits Review
- B.1 Basics
- B.2 Linear Elements: Resistors, Capacitors, and Inductors
- B.3 Nonlinear Elements: Diodes and Transistors
- B.4 Operational Amplifiers
- B.5 Modular Circuit Design: Input and Output Impedance
- Appendix C: Other PIC32 Models
- C.1 The PIC32MX5xx/6xx/7xx Family
- C.2 PIC32MX3xx/4xx Family
- C.3 PIC32MX1xx/2xx Family
- C.4 PIC32MX1xx/2xx/5xx 64-100 Pin Family
- C.5 PIC32MX330/350/370/430/450/470 Family
- C.6 PIC32MZ Family
- C.7 Conclusion
- Index
- Smith, PIC Projects and Applications using C, Newnes, 2013, 196pp, 9780080971513, $39.95
- Di Jasio, Programming 16-Bit PIC Microcontrollers in C, 2nd ed. Newnes, 2011, 416pp, 9781856178709, $59.95
- Di Jasio, Programming 32-Bit Microcontrollers in C, Newnes, 2008, 552pp, 9780750687096, $72.95