Table of Contents

Preface

Chapter 1 – Real-Time Computing

1.0    Defining the Embedded System

1.1    Embedded Systems History

1.2    Hardware Complexity

1.2.1    Processor

1.2.2    Microcontrollers

1.2.3    Hardware and Software

1.3    Execution in Real-Time

1.3.1    Hard and Soft Real-Time Systems

Chapter 2 – Circuit Fundamentals

2.1    Electrical Circuit

2.2    Circuit Concepts and Components

2.3    Digital Electronics

2.4    Diode

2.4.1    Light-Emitting Diode (LED)

2.5    Transistors

2.5.1    Bipolar Transistor

2.5.2    MOS Transistor

Chapter 3 – Logic Gates and Circuit Components

3.1    Logic Gates

3.2    Power Supplies

3.3    Clocked Logic and Flip-Flops

3.3.1    RS Flip-Flop

3.3.2    Clocked Circuits

3.3.3    D Flip-Flop

3.3.4    Edge-Triggered D Flip-Flop

3.3.5    Preset and Clear Signals

3.3.6    D Flip-Flop Waveform Action

3.3.7    Flip-Flop Applications

3.4    Digital Clocks

3.4.1    Clock Waveforms

3.4.2    TTL Clock

3.4.3    555 Timer

3.4.4    Microcontroller Clocks

3.5    Counters and Frequency Dividers

3.5.1    Fre quency Dividers

3.5.2    JK Flip-Flop Counter

3.5.3    Ripple Counters

3.5.4    Decoding Gates

3.5.5    Synchronous Counters

3.5.6    Counter ICs

3.5.7    Shift Registers

3.6    Multiplexers and Demultiplexers

3.6.1    Multiplexers

3.6.2    Demultiplexers

3.6.3    Multiplexer and Demultiplexer ICs

Chapter 4 – Input and Output Devices

4.1    Obtaining Input

4.2    Switches

4.2.1    Switch Contact Bounce

4.2.2    Keypads

4.3    Output Devices

4.3.1    Seven-Segment LED

4.3.2    Liquid Crystal Displays

4.3.3    LCD Technologies

Chapter 5 – From Circuit Schematics to PCB

5.1    Circuit Diagram

5.1.1    Symbols

5.1.2    Tools for Electronic Circuit Design

5.2    Circuit Board Design

5.2.1    Board Design Standards

5.2.2    Gerber File Format

5.3    Developing the Circuit Prototype

5.3.1    Breadboard

Limitations of Breadboards

Breadboarding Tools and Techniques

5.3.2    Wire-Wrapping

5.3.3    Perfboards

5.4    Printed Circuit Boards

5.4.1    PCB Layers

5.4.2    PCB Connectors

5.5    Making Your Own PCB

5.5.1    Drawing the CPB Circuit

5.5.2    Printing the PCB

5.5.3    Transferring the PCB Image

5.5.4    Etching the Board

5.5.5    Finishing the Board

5.5.6    Backside Image

5.6    Surface-Mount Components

5.6.1    SMT Adapters

5.6.2    Soldering SMT Components

5.7    Troubleshooting the Circuit Board

5.7.1    Circuit Testing Tools

Chapter 6 – Introducing the Microcontroller

6.1    A Computer on a Chip

6.2    PICMicro Microcontroller

6.2.1    Programming the PIC

Development Boards

6.2.2    Prototyping a PIC Circuit

6.3    PIC Architecture

6.3.1    Baseline PIC Family

PIC10 Devices

PIC12 Devices

PIC14 Devices

6.3.2    Mid-Range PIC Family

PIC16 Devices

6.3.3    High-Performance PIC Family

PIC18 Devices

Chapter 7 – Architecture and Instruction Set

7.1    Mid-Range PIC Architecture

7.1.1    Harvard Architecture

7.1.2    CISC versus RISC

7.1.3    Single-Word Instructions

7.1.4    Instruction Format

7.1.5    Mid-Range Device Versions

7.1.6    Arithmetic-Logic Unit

7.2    Data Memory Organization

7.2.1    w Register

7.2.2    Data Registers

Memory Banks

SFRs

GPRs

7.2.3    Indirect Addressing

7.3    Mid-Range I/O and Peripherals

7.3.1    Ports

7.3.2    Timers

7.3.3    Capture and Compare Module

7.3.4    Master Synchronous Serial Port

7.3.5    USART Module

7.3.6    A/D Module

7.4    Mid-Range PIC Core Features

7.4.1    Oscillator

7.4.2    System Reset

7.4.3    Interrupts

7.5    Mid-Range Instruction Set

7.5.1    STATUS and OPTION Registers

7.6    EEPROM Data Storage

7.6.1    EEPROM in Mid-Range PICs

Chapter 8 – Embedded Systems Programming

8.1    Assembly versus High-Level Languages

8.1.2    Embedded Systems

8.2    Integrated Development Environment

8.2.1    Installing MPLAB

8.2.2    MPLAB Project

8.2.3    Project Build Options

8.2.4    Building the Project

8.2.5    Quickbuild Option

8.3    Simulators and Debuggers

8.3.1    MPLAB SIM

8.3.2    MPLAB Hardware Debuggers

8.3.3    Improvised Debugger

8.4    Programmers

8.5    Engineering PIC Software

8.5.1    Using Program Comments

Program Header

Commented Banners

Commented Bitmaps

8.5.2    Defining Data Elements

cblock Directive

8.5.3    Banking Techniques

banksel Directive

Bank Selection Macros

Deprecated Banking Instructions

8.5.4    Processor and Configuration Controls

Configuration Bits

8.5.5    Naming Conventions

8.5.6    Errorlevel Directive

8.6    Pseudo In structions

Chapter 9 – I/O Circuits and Programs

9.1    Simple Input and Output

9.1.1    16F84A Programming Template

9.2    Template Circuits

9.2.1    MCLR and Oscillator Template

9.2.2    Power Supplies

Voltage Regulator

9.3    Simple Circuits and Programs

9.3.1    Single LED Circuit

LED Flasher Program

9.3.2    LED/Pushbutton Circuit

9.3.3    Multiple LED Circuit

9.4    Seven-Segment LED

9.5    I/O Demo Board

9.5.1    TestDemo1 Program

9.6    Comparisons in PIC Programming

9.6.1    PIC Carry Flag

Chapter 10 – PIC Interrupt System

10.1  Interrupts

10.1.1  16F84 Interrupts

10.1.2  Interrupt Control Register

10.1.3  OPTION Register

10.2  Interrupt Sources

10.2.1  Port B External Interrupt

10.2.2  Timer0 Interrupt

10.2.3  Port B Line Change Interrupt

Multiple External Interrupts

10.2.4  EEPROM Data Write Interrupt

10.3  Developing the Interrupt Handler

10.3.1  Context Saving Operations

Saving W and STATUS Registers

10.4  Interrupt Programming

10.4.1  Programming the External Interrupt

RB0 Interrupt Initialization

RB0 ISR

10.4.2  Wake-Up from SLEEP Using the RB0 Interrupt

SleepDemo Program

10.4.3  Port B Bits 4-7 Status Change Interrupt

RB4-7 Interrupt Initialization

RB4-7 Change ISR

10.5  Sample Programs

10.6  Demonstration Programs

10.6.1  RB0Int Program

10.6.2  SleepDemo Program

10.6.3  RB4to7Int Program

Chapter 11 – Timers and Counters

11.1  Controlling the Time Lapse

11.1.1  16F84 Timer0 Module

11.1.2  Timer0 Operation

Timer0 Interrupt

Timer0 Prescaler

11.2  Delays Using Timer0

11.2.1  Long Delay Loops

How Accurate Is the Delay?

11.3  Timer0 as a Counter

11.4  Timer0 Programming

11.4.1  Programming a Counter

Timer/Counter Test Circuit

TimerCounter Program

Code Details

11.4.2  Timer0 as a Delay Timer

Delay Timer Circuit

11.4.3  DelayTimer Program

Code Details

11.4.4  Variable Time Lapse

11.4.5  Variable Lapse Timer Program

Code Details

11.4.6  Interrupt-Driven Timer

11.4.7  TimerInt Program

Code Details

11.5  Watchdog Timer

11.5.1  Watch dog Timer Programming

11.6  Demonstration Programs

11.6.1  Tmr0Counter program

11.6.2  Timer0 Program

11.6.3  LapseTimer Program

11.6.4  LapseTmrInt Program

Chapter 12 – LCD Hardware and Programming

12.1  Liquid Crystal Display

12.1.1  LCD Features and Architecture

12.1.2  LCD Functions and Components

Internal Registers

Busy Flag

Address Counter

Display Data RAM (DDRAM)

Character Generator ROM (CGROM)

Character Generator RAM (CGRAM)

Timing Generation Circuit

Liquid Crystal Display Driver Circuit

Cursor/Blink Control Circuit

12.1.3  Connectivity and Pin-Out

12.2  Interfacing with the HD44780

12.2.1  Busy Flag or Timed Delay Options

12.2.2  Contrast Control

12.2.3  Display Backlight

12.2.4  Display Memory Mapping

12.3  HD44780 Instruction Set

12.3.1  Instruction Set Overview

Clearing the Display

Return Home

Entry Mode Set

Display and Cursor ON/OFF

Cursor/Display Shift

Function Set

Set CGRAM Address

Set DDRAM Address

Read Busy Flag and Address Register

Write Data

Read Data

12.3.2  A 16F84 8-Bit Data Mode Circuit

12.4  LCD Programming

12.4.1  Defining Constants and Variables

Using MPLAB Data Directives

12.4.2  LCD Initialization

Function Set Command

Display Off

Display and Cursor On

Set Entry Mode

Cursor and Display Shift

Clear Display

12.4.3  Auxiliary Operations

Time Delay Routine

Pulsing the E Line

Reading the Busy Flag

Bit Merging Operations

12.4.4  Text Data Storage and Display

Generating and Storing a Text String

Displaying the Text String

12.4.5  Data Compression Techniques

4-Bit Data Transfer Mode

Master/Slave Systems

12.5  Sample Programs

Chapter 13 – Analog-to-Digital and Real-Time Clocks

13.1  Clocks and the Digital Revolution

13.2  A/D Converters

13.2.1  Converter Resolution

13.2.2  ADC Implementation

13.3  A/D Integrated Circuits

13.3.1  ADC0331 Sample Circuit and Program

13.4  PIC Onboard A/D Hardware

13.4.1  A/D Module on the 16F87x

ADCON0 Register

ADCON1 Register

SLEEP Mode Operation

13.4.2  A/D Module Sample Circuit and Program

13.5  Real-Time Clocks

13.5.1  NJU6355 Real-Time Clock

13.5.2  RTC Demonstration Circuit and Program

BCD Conversion Procedures

13.6  Demonstration Programs

13.6.1  ADF84 Program

13.6.2  A2DinLCD Program

13.6.3  RTC2LCD Program

Chapter 14 – Data EEPROM

14.1  EEPROM Programming

14.1.1  Data EEPROM

14.2  EEPROM Programming

14.2.1  Reading EEPROM Data

14.2.2  EEPROM Data Memory Write

14.3  EEPROM Programming Application

14.3.1  EECounter Program

Code Details

14.4  Demonstration Programs

14.4.1  EECounter Program

14.4.2  Ser2EEP Program

14.4.3  I2CEEP Program

Chapter 15 – Stepper Motors

15.1  Description and Operation

15.1.1  Stepper Motor Types

Variable Reluctance

Permanent Magnet

Hybrid

15.1.2  Unipolar Stepper Motors

15.1.3  Determining Unipolar and Bipolar Wiring

Four-Wire Motor

Six-Wire Unipolar Motor

Five-Wire Unipolar

15.1.4  Bipolar Stepper Motors

15.2  Stepper Motor Controls

15.2.1  Stepping Modes

Wave Drive Mode

Full Step Mode

Half Step Mode

Microstepping

Chapter 16 – Stepper Motor Circuit Components

16.1  Circuit Elements

16.1.1  Input, Output, and Feedback

16.2  Translator

16.2.1  PIC Microcontroller as a Translator

16.3  Translator/Drivers

16.3.1  UCN 5804

16.3.2  L297

16.3.3  EDE1204

16.3.4  SLA7060 and SLA7024

16.4  Power Driver

16.4.1  Unipolar Drivers

PIC Microcontroller as a Driver

ULN2803A

TIP 120

16.4.2  Bipolar Drivers

16.4.3  Transistorized H Bridge

Snubber Diodes

16.4.4  H Bridge ICs

L293D

L298

16.5  Modules in Circuit Schematics

16.5.1  Example 16F84 Translator Modules

Chapter 17 – Unipolar Motor Circuits and Programs

17.1  Stepper Motor Control Circuits

17.1.1  Stepper Motor Circuit Schematic Conventions

17.2  Motor Speed Control

17.2.1  Speed Control from Digital Input

17.2.2  An a log Input Speed Control

17.3  Unipolar Motor Control Circuits

17.3.1  Matching Circuit to Motor Power

17.3.2  16F84 Unipolar Circuit

Sample Program SMU_PIC16F84.asm

17.3.3  5804 Unipolar Circuit

Sample Program SMU_5804.asm

Generating the Motor Pulses

Interrupt-Driven Motor Pulsing

17.3.4  16F686 PIC Circuit

17.3.5  16F686 Programming

Sample Program SMU_PIC16F684.asm

Sample Program SMU_PIC16F684_INT.asm

17.3.6  Stepper Motor Position Control

Sample Program SMU_POSITION.asm

17.4  Demonstration Programs

17.4.1  SMB_297_293D.asm

17.4.2  SMU_PIC16F84.asm Program

17.4.3  SMU_5804.asm

17.4.4  SMU_5804_INT.asm

17.4.5  SMU_PIC16F684.asm

17.4.6  SMU_PIC16F684_INT.asm

17.4.7  SMU_POSITION.asm

Chapter 18 – Constant-Voltage Bipolar Motor Controls

18.1  Unipolar versus Bipolar

18.1.1  Bipolar Drive Circuits

18.2  Simple, L293 Bipolar Circuit

18.2.1  L297- and L293-Based Circuit

18.2.2  Minimal L297- and L298-based Circuit

18.3  Demonstration Programs

18.3.1  SMB_L293D.asm

18.3.2  SMB_297_293D.asm

18.3.3  SMB_297_298.asm

Chapter 19 – Advanced Motor Controls

19.1  Choppers and Microstepping

19.2  Chopper Circuit Fundamentals

19.3  L297/298 Chopper Circuit

19.3.1  Setting the Reference Voltage

19.4  A Chopper-Based Demo Board

19.4.1  Motor Circuit Power Requirements

19.4.2  Chopper Demo Program

19.5  Microstepping

19.5.1  Microstepping Fundamentals

Microstepping Theory

Pulse Width Modulation (PWM)

19.6  Programming PWM

19.6.1  CCP Module

19.6.2  PWM Circuit and Software

19.6.3  Microstepping by PWM

19.6.4  Microstepping Sample Program

19.7  Microstepping ICs

19.7.1  Allegro 3955 IC

19.7.2  3955-Based Circuit

19.7.3  3955 Motor Driver Program

19.8  Demonstration Programs

19.8.1  PWM_DEMO_873.asm

19.8.2  PIC_Chopper.asm

19.8.3  PWM_Micstep.asm

19.8.4  PIC873_3955.asm

Chapter 20 – Communications

20.1  PIC Communications Overview

20.2  Serial Data Transmission

20.2.1  Asynchronous Serial Transmission

20.2.2  Synchronous Serial Transmission

20.2.3  PIC Serial Communications

20.2.4  RS-232-C Standard

Essential Concepts

Serial Bit Stream

Parity Testing

Connectors and Wiring

Null Modem

Null Modem Cable

20.2.5  EIA-485 Standard

EIA-485 in PIC-based Systems

20.3  Parallel Data Transmission

20.3.1  PIC Parallel Slave Port (PSP)

20.4  PIC “Free-Style” Serial Programming

20.4.1  PIC-to-PIC Serial Communications

PIC-to-PIC Serial Communications Circuits

PIC-to-PIC Serial Communications Programs

20.4.2  Program Using Shift Register ICs

74HC165 Parallel-to-Serial Shift Register

74HC164 Serial-to-Parallel Shift Register

20.5  PIC Protocol-Based Serial Programming

20.5.1  RS-232-C Communications on the 16F84

RS-232-C Transceiver IC

PIC-to-PC Communications

RS-232-C TTY Board

16F84A UART Emulation

LCD Scrolling Routine

20.5.2  RS-232-C Communications on the 16F87x

16F87x USART Module

USART Baud Rate Generator

16F87x USART Asynchronous Transmitter

16F87x USART Asynchronous Receiver

PIC-to-PC RS-232-C Communications Circuit

16F877 PIC Initialization Code

USART Receive and Transmit Routines

USART Receive In terrupt

20.6 Demonstration Programs

20.6.1  SerialSnd Program

20.6.2  SerialRcv Program

20.6.3  Serial6465 Program

20.6.4  TTYUsart Program

20.6.5  SerComLCD Program

20.6.6  SerIntLCD Program

Appendix A – Resistor Color Codes

Appendix B – Essential Electronics

B.1   Atom

B.2   Isotopes and Ions

B.3   Static Electricity

B.4   Electrical Charge

B.4.1   Voltage

B.4.2   Current

B.4.3   Power

B.4.4   Ohm’s Law

B.5   Electrical Circuits

B.5.1   Types of Circuits

B.6   Circuit Elements

B.6.1   Resistors

B.6.2   Revisiting Ohm’s Law

B.6.3   Resistors in Series and Parallel

B.6.4   Capacitors

B.6.5   Capacitors in Series and in Parallel

B.6.6   Inductors

B.6.7   Transformers

B.7   Semiconductors

B.7.1   Integrated Circuits

B.7.2   Semiconductor Electronics

B.7.3   P-Type and N-Type Silicon

B.7.4   Diode

Appendix C – Numeric Data

C.1   Numbers in Computing

C.1.1   Counting

C.1.2   Tally System

C.1.3   Roman Numerals

C.2   Origins of the Decimal System

C.2.1   Number Systems for Digital-Electronics

C.2.2   Positional Characteristics

C.2.3   Radix or Base of a Number System

C.3   Types of Numbers

C.3.1   Whole Numbers

C.3.2   Signed Numbers

C.3.3   Rational, Irrational, and Imaginary Numbers

C.4   Radix Representations

C.4.1   Decimal versus Binary Numbers

C.4.2   Hexa decimal and Octal

C.5   Number System Conversions

C.5.1   Binary-to-ASCII-Decimal

C.5.2   Binary-to-Hexa decimal Conversion

C.5.3   Decimal-to-Binary Conversion

Appendix D – Character Data

D.1   Character Representations

D.1.1   Electronic-Digital Machines

D.2   Character Representations

D.2.1   ASCII

D.2.2   EBCDIC and IBM

D.2.3   Unicode

D.3   Storage and Encoding of Integers

D.3.1   Signed and Unsigned Representations

D.3.2   Word Size

D.3.3   Byte Ordering

D.4.4   Sign-Magnitude Representation

D.3.5   Radix Complement Representation

D.4   Encoding of Fractional Numbers

D.4.1   Fixed-Point Representations

D.4.2   Floating-Point Representations

D.4.3   Standardized Floating-Point Representations

D.4.4   IEEE 754 Single Format

D.4.5   Encoding and Decoding Floating-Point Numbers

D.5   Binary-Coded Decimals (BCD)

D.5.1   Floating-Point BCD

Appendix E – Digital Arithmetic and Conversions

E.1   Microcontroller Arithmetic

E.2   Unsigned and Two’s Complement Arithmetic

E.2.1   Operations on Decimal Numbers

E.3   Bit Manipulations and Auxiliary Operations

E.3.1   Bit Shift and Rotate

E.3.2   Comparison Operations

E.3.3   Other Support Operations

E.4   Un signed Binary Arithmetic

E.4.1   Multi-Byte Unsigned Addition

E.4.2   Unsigned Multiplication

E.4.3   Unsigned Division

E.5   Signed Binary Arithmetic

E.5.1   Overflow Detection in Signed Arithmetic

E.5.2   Sign Extension Operations

E.5.3   Multi-Byte Signed Operations

E.6   Data Format Conversions

E.6.1   BCD Digits to ASCII Decimal

E.6.2   Unsigned Binary to ASCII Decimal Digits

E.6.3   ASCII Decimal String to Unsigned Binary

E.6.4   Unsigned Binary to ASCII Hexadecimal Digits

E.6.5   Signed Numerical Conversions

Appendix F – Mid-Range Instruction Set

Appendix G – Printed Circuit Boards

G.1   Introduction

G.2   Printed Circuit Boards (PCBs)

G.3   Parts Lists

G.4   Building Your Own Circuit Boards

G.4.1   Tools and Materials

G.4.2   Single-Sided Demo Board

G.4.3   PCB Images for Demo Board

Drawing the Circuit Diagram

Printing the PCB Diagram

Selecting the Paper

Transferring the PCB Image

Etching the Board

Finishing the Board

Component-Side Image

G.5   Caveats

Appendix H – Additional Code

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.6.194