You are on page 1of 147

dsPIC Digital Signal Controller (DSC) Introductory Seminar 2005

30 MIPS Computing Power in a 6x6 mm Package

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 1

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am VDI Demonstration 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 2

Learning Objectives

What is a Digital Signal Controller Identify key dsPIC DSC architecture features Identify key dsPIC DSC DSP architecture features Identify the advanced dsPIC DSC peripheral set What software development tools are available What hardware development tools are available What software libraries are available What application libraries are available Where do you go from here

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 3

Who is Microchip?

Leading semiconductor manufacturer:


of high-performance, field-programmable, 8-bit & 16-bit RISC Microcontrollers of Analog & Interface products of related Memory products for high-volume embedded control applications

$699M in product sales in FY04 More than 3,500 employees Headquartered near Phoenix in Chandler, AZ
The Silicon Desert

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 4

Worldwide Technical Support Centers & Manufacturing Facilities

Oregon Manufacturing
Toronto Chicago Detroit Boston San Jose Kokomo New York Los Angeles Atlanta Phoenix Dallas

London Copenhagen Paris Munich Milan

Shanghai Test & Assembly


Seoul Beijing Shin-Yokohama Qingdao Shanghai Chengdu Fuzhou Taipei Bangalore Shenzhen Kaohsiung Hong Kong
Singapore

. .

Arizona Manufacturing and Corporate HQ

Bangkok Test & Assembly


Sydney

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 5

Worldwide 8-Bit Microcontroller Market Share (Units)


1990 No. Rank
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Motorola Mitsubishi NEC Intel Hitachi Philips Matsushita National Siemens TI Sharp Oki Toshiba SGS-Thomson Zilog Matra MHS Sony Fujitsu AMD Microchip

1991 Rank
Motorola Mitsubishi NEC Intel Hitachi Philips Matsushita SGS-Thomson Siemens TI National Toshiba Sony Sharp Oki Zilog Microchip Matra MHS Fujitsu Sanyo

1992 Rank
Motorola Mitsubishi Intel NEC Philips Hitachi Matsushita SGS-Thomson National TI Zilog Toshiba Siemens Microchip Sharp Sanyo Matra MHS Sony Oki Fujitsu

1993 Rank
Motorola Mitsubishi NEC Hitachi Philips Intel SGS-Thomson Microchip Matsushita Toshiba National Zilog TI Siemens Sharp Oki Sony Sanyo Fujitsu AMD

1994 Rank
Motorola Mitsubishi NEC Philips Intel Microchip Zilog SGS-Thomson Matsushita Hitachi Toshiba National TI Ricoh Fujitsu Siemens Sharp Oki Sony Temic

1995/96 Rank
Motorola Mitsubishi SGS-Thomson NEC Microchip Philips Zilog Hitachi Fujitsu Intel Siemens Toshiba Matsushita TI National Temic Sanyo Ricoh Oki Sharp

1997-01 Rank
Motorola Microchip ST-Micro NEC Philips Atmel Hitachi Toshiba Samsung Elan Zilog Matsushita Infineon Fujitsu Mitsubishi Sanyo Winbond National Sony Holtek

2002-2004 Rank
Microchip Motorola ST-Micro NEC Atmel Sunplus Hitachi Fijitsu Philips Toshiba Mitsubishi Samsung Elan Winbond Zilog Sanyo Matsushita Infineon Holtek National

Based on unit shipment volume 1990-2002, Source: Dataquest, July 2003


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 6

PIC Microcontroller Product Migration Path 212 Products


Flash, OTP and ROM Superior Analog functionality Outstanding Flash endurance Industrys strongest product and family migration path
28-Pin Family 40/44-Pin Family

64/68-Pin Family

80/84-Pin Family 8K64K Words

4K64K Words

8-Pin Family

14-Pin Family

18/20-Pin Family

2K16K Words

.5K16K Words

.5K4K Words

1K2K Words

.5K2K Words

m Sea

les

ion rat g i sM

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 7

Where Are We Today?


Digital Pot Precision Voltage Reference Filters RF Xmit/ receive High Voltage I/Os IR Communications Telecom DTMF Codec Power Drivers Microcontrollers Motors Relays Print-heads

Sensors

Amplifiers

A/D

Serial NV Memory

Power

Power Management

D/A

LCD Drivers LED Drivers

SRAM

Xceivers - RS232/485 - CAN bus - USB

Offered by Microchip

Bus Comm. - CAN bus - USB - LinBus

Digital Peripherals PWM RTC

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 8

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 9

16-bit Digital Signal Controller Architecture

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 10

What is DSC ? Digital Signal Control


PERFORMANCE
Embedded Control + Digital Signal Processing

P DS e Th ace Sp
32-bit MCU

16-bit MCU 5 - 15 MIPS 8-bit MCU 1 - 10 MIPS

dsPIC30F
The 16-bit MCU with the power of DSP

PRICE
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 11

Digital Signal Controller

Looks Like a MCU Performs Like a DSP Priced Like a MCU

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 12

Why DSC?

100% Flash with automotive quality Innovation with new hardware modules Focus on low pin count with migration option from day 1 on. Up to 30 MIPS performance
D S

Focus on ease-of-use with common tools

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 13

dsPIC30F Controller Family


Flash Program Memory: RAM Data EEPROM Pin-count Timers 16-bit Input Capture Output Compare/PWM Motor Control PWM A/D converter A/D converter UART SPI (8-/16-bit) 2 I C QEI Codec interface CAN 12 K144 Kbytes 5128 Kbytes 1K4 Kbytes 1880 pins Up to 5 Up to 8 Up to 8 (individual time bases) 6 or 8 with shutdown pins 10-bit, 1 Msps, up to 16 ch 12-bit, 200 ksps, up to 16 ch 12 12 1 1 1 12

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 14

Designed for the Pole Position

High performance 16-bit CPU with industry leading C compiler efficiency Seamless integration of DSP and MCU functionality Flexible, reliable Flash program memory Wide operating voltage range (2.5V5.5 V) Fast, deterministic interrupt system5 cycle latency Competitive DSP performance Advanced peripheral I/O features Fast, precise 10- & 12-bit A-to-D Converters Data EEPROM and SRAM In-circuit debug capabilities

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 15

C Compiler Efficiency
EEMBC industry std. Benchmarks, Automotive Suite dsPIC30F includes features to enhance C code efficiency
32-bit math-intensive code 16-bit competition (~ 50KB code) 194%
186% 161% 141% 118%

New instruction types + More flexible addressing +


=

Smallest C code

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 16

dsPIC30F

Software stack

Nearest Competitor

Furthest Competitor

100%

108%

dsPIC DSC Performance Benchmark


Company Microchip Infineon TI Motorola Hitachi Infineon ST Micro Mitsubishi Motorola MCU Family dsPIC30F XC166 320LF240x 56F80x H8S/26xx C16x ST10F269 M16C MC9S12D Instruction # of Cycles Cycle Rate per (MHz) # Instruction 30 40 40 40 33 25 20 20 25 1-2 1-6 1-4 1-8 1-7 2-4 2-4 1-8 2-6 Average Throughput (MIPS) 1 28 28 21 19 15 12 9 8 6

1. dsPIC30F actual, other estimated based on instruction frequency analysis using control-centric code.
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 17

Seamless integration of DSP and MCU


Data Memory (RAM)
32K x 16 bit DSP: dual access MCU: single access Instruction Pre-fetch & Decode

One instruction set One register file

Engine
PSV/TABLE Access Cntrl

DSP

Y AGU

W Array
16 x 16

X AGU

Program Memory 4M x 24 bit

MCU ALU
Address Path MCU/DSP Data Path

24-bit PC Control
DSP Data Path Program Data/Control Path

Linear

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 18

Flash Performance Summary


All dsPIC DSC devices are Flash PMOS Electrically Erasable Cell (PEEC) Flash Industry leading reliability

Endurance up to 1M E/W Cycles Data retention >40+ years

Flexible operation

Fast programming times for program memory Self-programmable (RTSP)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 19

Flash Performance Summary

25C 85C Retention E/W Cycles E/W Cycles

Program Flash

100,000

10,000

>40 Years

Data EE Memory

1,000,000

100,000

>40 Years

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 20

Operating Parameters

Operating Speed @ 5V (-40C to 85C) : 30 MIPS VDD: Temp: Program Memory: Data Memory: Analog: Package sizes

2.5 to 5.5V -40 C to 125 C Flash (PEEC) SRAM, EEPROM (PEEC) 10-bit & 12-bit precision

18-pin SO & SP 28-pin SO, SP and QFN 40-pin SP; 44-pin TQFP and QFN 64- and 80-pin TQFP
D S

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 21

Knowledge Check #1
Which of these features help the C compiler generate efficient code? A: New addressing modes B: Software stack C: Lots of caffeine D: 16 W registers E: New instructions Bonus Question: Which item above helps the C compiler programmer generate efficient code? C: Lots of caffeine

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 22

dsPIC DSC/PIC MCU Compatibility


Compatibility made easy dsPIC DSC is very compatible with PIC MCU

Compatible pinouts Compatible peripheral look and feel Compatible instructions Compatible tools

RememberdsPIC DSC is: DSP plus a lot of PIC MCU

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 23

Peripheral Compatibility
DSC peripherals have the same I/O as PIC MCU peripherals dsPIC DSC peripherals have the same functionality as PIC MCU peripherals dsPIC

PIC MCU
TMR CCP TMR CCP

dsPIC DSC
TMR IC OC TX TMR IC OC TX UART RX SCK SPI SDI SDO SCL I2C SDA TXx CAN RXx

UART

RX SCK

SPI

SDI SDO SCL

I2C

SDA TXx

CAN

RXx

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 24

Instruction Set Compatibility


dsPIC DSC processor architecture is based on PIC MCU dsPIC DSC Programmers Model is a superset of PIC MCU Many PIC18XXX instructions are included in dsPIC DSC

PIC MCU INSTRUCTIONS

dsPIC DSC INSTRUCTIONS

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 25

Tools Compatibility

All Microchip tools are useable on dsPIC DSC Same user interface PIC MCU customers will be comfortable using dsPIC DSC tools

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 26

Memory Organization

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 27

Program Memory

Modified Harvard Bus Architecture Single Core : MCU + DSP Instruction is 24-bit wide Total Architecture Reach: 4M x 24-bit Linear Program Space

4M Total

24 Bit Instruction

Devices contain up to 144 Kbytes Flash Memory


144 Kbytes Flash

No Paging or Segmentation

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 28

Programming Flash Memory


Run-Time Self Programming (RTSP):

Run Time Self Programming OR Self Programming Device can program its own Flash memory Programs a block of 96 bytes at a time in ~ 2 ms Ideal for calibration or parameterization in system cal Ideal for remote code update All dsPIC DSC devices support RTSP

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 29

Programming Flash Memory


In-circuit Serial Programming (ICSP) capability:

Device is soldered in the system Programming is done using:


2 data/clock pins + reset pin forced high

Ideal for combined programming and final test at system level Ideal for field update of Flash memory through a small header Programming time: ~18 seconds for 144 Kbytes All dsPIC DSCs support ICSP capability

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 30

Data EEPROM Memory


Up to 4 Kbytes Data EE Memory Run-time programmable Row and word erasable Row and word programmable Modify a row of 16 words in 2 ms Can access data EEPROM for 16-bit data read operations MOV [++w4], [w6++] Data EEPROM Memory used as source address for data read operation

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 31

Data Memory

Data is 16-bit wide


Byte addressable

64 K Total

Total Space: 64 Kbytes Linear Data Space


16 Bit Data

No Banking

Devices contain up to 8 Kbytes User RAM Addressable Indirectly or with Memory Direct MOV Instruction
8 Kbytes RAM

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 32

Program Space Mapping into Data Space using PSV


32 Kbytes of Data Space may be mapped into any 16 K word page in User Program Space

If PSV bit (CORCON<2>) = 1 and EA<15> =1 (e.g. EA<15:1> = 0x8000), then Data Space window in Program Space is used PSVPAG (Program Space Visibility Page Register) supplies the upper byte in the 24-bit PS address Supported for X Data Memory Reads Only May be used for accessing constant coefficients in a FIR or FFT algorithm

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 33

ExampleProgram Space Visibility


0x017FFE 0xFFFF 0xABCD 15 0xABCD 0x9000
+

0x011000 0x010000

32K PSV Window

23

15

0x8000 0x02 PSVPAG 0x0000 0x000000


EA<15>=1 and PSV = 1

Data Memory

Program Memory

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 34

Instruction Set/Addressing Modes

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 35

Instruction Set Functional Groups


Instruction Set Grouped by Function


Move instructions Math and logic instructions Bit instructions Compare/skip instructions Stack control instructions Program flow control instructions CPU operating mode control instructions DSP instructions

MAC class of instructions Non-MAC class of instructions

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 36

Instruction Set Overview


84 instructions (including DSP)


Nearly all are one word (24 bits) Four are two words Program flow changes TABLE instructions Double Move instructions DO instruction Divide instruction A = B op C Boosts code efficiency (assembly or C) (2 cycles) (2 cycles) (2 cycles) (2 cycles) (18 cycles)

Most instructions execute in 1 Cycle, except:


Three operand instructions


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 37

Programmers Model
15 Divide Quotient W0 Divide Remainder W1 W2 W3 W4 W5 W6 W7 W8 W9 W10 W11 W12 W13 Frame Pointer W14 Stack Pointer 0 W15 15 0 Stack Pointer Limit 0

W Registers General Purpose Data Registers or Address Pointers

DSP OPERAND Registers DSP ADDRESS Registers

SPLIM

DSP Accumulators (40-bit)

ACCA ACCB
39 32 31 16 15 0

OA OB SA SB OAB SAB DA DC IPL2 IPL1 IPL0 RA

N OV

Status Register

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 38

Knowledge Check #2
Most dsPIC DSC instructions execute in?

A: not sure B: 1 cycle C: 2 cycles D: 33 ns @ 30 MIPS E: Answers B & D F: Answer B only

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 39

Addressing Modes

Generic Addressing Modes:


Inherent Literal (immediate) Register Memory Direct Register Indirect with:


NOP, RESET, PUSH, POP, etc. MOV #0x1800, W0 ADD W4, W5, W6 ADD 0x500, WREG ADD W4, [++W5], [--W6] MOV [W4++], [W8--] MOV [W4+W5], [W6]

Pre-inc or Pre-dec Post-inc or Post-dec Signed Literal Offset


Register Indexed Modulo (for circular buffers) Bit Reverse (for FFTs)

Special Addressing Modes:


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 40

Modulo Addressing

Modulo or Circular Addressing


Eliminates the software overhead associated with effective address (EA) correction, e.g. in FIR filters Data address boundary checks are performed in hardware Three types of modulo buffers for MCU and DSP operations Decrementing
Buffer Start

Incrementing
Buffer Start

Bi-directional
Buffer Start

Buffer End

Buffer End

Buffer End

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 41

Interrupt Subsystem

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 42

Interrupt Subsystem Highlights


Interrupt Vector Table (IVT) has a unique vector for each source

8 non-maskable trap vectors 54 interrupt vectors Vector location contains ISR address

Alternate IVT for flexible processing of interrupts 7 user-assigned priority levels for each interrupt CPU has 16 priority operating levels

Sources with priority level greater than current CPU level can interrupt the CPU

Interrupt nesting supported 5 cycle latency for entry into ISR 3 cycles to return from ISR

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 43

Interrupt Vector Table


ResetGOTO Instruction ResetGOTO Address Reserved Oscillator Fail Trap Address Error Trap Stack Error Trap Math Error Trap Reserved Reserved Reserved Interrupt Vector 0 Interrupt Vector 1 Interrupt Vector 2 Interrupt Vector 53 Reserved Reserved Reserved Oscillator Fail Trap Interrupt Vector 53 0x000000 0x000004

Interrupt Vector Table (IVT)

Decreasing Natural Order Priority

0x00007E

0x000084

Alternate Interrupt Vector Table (AIVT)

0x0000FE

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 44

Knowledge Check #3
Interrupt Entry Latency is? A: 5 cycles B: No need for interrupts, service in foreground C: 3 cycles D: 167 ns @ 30 MIPS E: Answer A and D Bonus Question: Do traps have a higher natural priority relative to normal interrupts? A: Yes B: No C: In most cases
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 45

Traps for Robust Operation


Oscillator Failure Trap (level 14) Address Error Trap (level 13)

Instruction fetch from illegal program space Data fetch from unimplemented data space Unaligned word access from data space Stack overflow or underflow Divide by Zero Unsaturated Accumulator Overflow (A or B) Catastrophic Accumulator Overflow (either) Accumulator Shift Overflow

Stack Error Trap (level 12)


Arithmetic Error Trap (level 11)


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 46

DSP Engine

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 47

DSP Engine Block Diagram


Round Logic

40-bit Accumulator A 40-bit Accumulator B Saturate Adder


Negate

Saturate

16

40 40
Barrel Shifter

Enable 16

40 40

Key Modules:

17x17-bit Multiplier / Scaler Sign Extend / Zero Backfill Logic 40-bit Adder and two Accumulators Rounding and Saturation Logic 40-bit Barrel Shifter

Sign Extend
Zero-backfill

32 33 16 16

16

17-bit Multiplier/Scaler Operand Pre-processing From W Array

To W Array

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 48

X Data Bus

DSP Features

There is a set of special DSP instructions included in dsPIC DSC that speed processing of the typical mathematic calculations used in filters, control loops and more

MAC instructionMultiply and Accumulate Also Multiply and Subtract, Square and Accumulate, etc. 19 special DSP instructions total MULTIPLY, DIVIDE and bit shift instructions REPEAT instructionrepeats an instruction many times DO instructionrepeats a block of instructions many times

With DSP instructions, this complex equation can be computed using only 2 instruction words and 5 instruction cycles!

y[n]= b0 x[n]+ b1 x[n 1]+ b2 x[n 2]+ b3 x[n 3]

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 49

Single Cycle MAC Instruction


FIR Filter Tap = 1 instruction cycle (33 ns)

Sample Instruction Syntax MAC W4*W5, A, [W8]+=2, W4, [W10]-=6, W5, W13

Source operand registers

Destination accumulator X prefetch source

Y prefetch source

Y prefetch destination

X prefetch destination

Other Acc. Write-back destination

Basic Syntax

Optional Arguments

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 50

Special DSP Features


How does dsPIC DSC assist real time processing? 30 MIPSup to 30 million calculations per second Powerful instructions do many operations at the same time Example: MAC instruction

Gets 2 data values from memory Multiplies them together Adds the result to the accumulator

What does dsPIC DSC have to help with high precision calculations? The working registers of dsPIC DSC are all 16-bits The dsPIC DSC does 32-bit multiply and 32-bit divide The dsPIC DSC has two 40-bit accumulators for calculation results Special instructions allow simple transfers of 16- and 32-bit data

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 51

Special Addressing Modes


DSP calculations involve a lot of data words. dsPIC DSC has special addressing modes that help

Modulo addressing scans through a block of data Bit reversed addressing needed by Fast Fourier Transform (FFT) calculation software 16-bit and 32-bit data move operations

DSP calculations also need to adjust the values of the data this can be termed scaling.

dsPIC DSC has two 40-bit accumulators and automatic scaling of data on reads and writes for each

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 52

Knowledge Check #4 Super Bonus Question:

y[n]= b0 x[n]+ b1 x[n 1]+ b2 x[n 2]+ b3 x[n 3]


What is this equation used for?
This equation represents a digital filter

What is it called?
Finite Impulse Response (FIR) Filter

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 53

DSP Performance Benchmark


Normalized Cycle-Count Comparison Using BDTI Benchmarks
BDTI Benchmark Results Microchip dsPIC 30Fxxx* TI C24x/C24xx Motorola 56F83xx (56800E) ADI 2199x (219x)

Vector Dot Product Real Block FIR Two Bi-Quad IIR Control**

1.00 1.00 1.00 1.00

1.16 1.32 2.12 2.05

1.07 1.11 1.29 2.06

1.32 1.02 1.47 1.76

* Projected Results ** Optimized for memory use; all other benchmarks optimized for speed.
Results 2005 Berkeley Design Technology, Inc. Contact info@BDTI.com for info.
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 54

DSP Performance Benchmark


Normalized Execution-Time Comparison Using BDTI Benchmarks (Lower is Better)
BDTI Benchmark Results Microchip dsPIC 30Fxxx* (30 MIPS) TI C24x/C24xx (40 MIPS) Motorola 56F83xx (56800E) (60 MIPS) ADI 2199x (219x) (160 MIPS)

Vector Dot Product Real Block FIR Two-Biquad IIR Control**

1.00 1.00 1.00 1.00

0.87 0.99 1.59 1.54

0.53 0.55 0.65 1.03

0.25 0.19 0.28 0.33

* Projected Results ** Optimized for memory use; all other benchmarks optimized for speed.
Results 2005 Berkeley Design Technology, Inc. Contact info@BDTI.com for info.
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 55

DSP Performance Benchmark


Normalized Memory-Use Comparison Using BDTI Benchmarks (Lower is Better)
BDTI Benchmark Results Microchip dsPIC 30Fxxx* TI C24x/C24xx Motorola 56F83xx (56800E) ADI 2199x (219x)

Control

1.00

1.30

0.85

1.44

* Projected Results
Results 2004 Berkeley Design Technology, Inc. Contact info@BDTI.com for info.
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 56

System Management Features

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 57

System Management Features


dsPIC DSC has the same system management features that PIC MCU users love:

Configurable Watchdog Timer with its own RC oscillator


Programmable Time out: 2 ms16 sec

Power-on Reset with a programmable delay 0, 4, 16, 64 ms Brown-out Reset with programmable levels Low VDD Detect Interrupt with programmable levels

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 58

Clock sources
Low Pwr RC 512 kHz Fast RC 7.37 MHz EC Clock XTL, XT, HS Primary Xtal OSC
PLL 4x, 8x, 16x or bypass Clock Divide By 1, 4, 16, 64
System Clock

OSC1

OSC2

SOSCI

32 KHz Timer1 Xtal OSC

Primary oscillator for crystals 32 kHz for teal time clock Includes 2 internal RC oscillators PLL multiplies oscillator source for high frequency operation Clock divide can optionally slow clock to conserve power

SOSCO

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 59

Power Control in dsPIC DSC


How do I manage the dsPIC DSC power consumption? dsPIC DSC PWRSAV Instruction provides 2 power-down modes, Sleep and Idle Sleep mode stops core and all peripherals Idle mode stops core and ...

Optionally stops peripherals Peripherals interrupt will wake-up device

Dynamic PLL mode switching Run-Time input clock divide

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 60

Fail-Safe Operation

Features that make the target system safe!


Clock monitor detects oscillator failure


Automatic switch to an internal RC clock

Illegal Program Instruction


Device resets Oscillator fail Address out-of-range Stack out-of-range Math errors

Traps let software handle error conditions


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 61

Knowledge Check #5
Your application needs to run at 30 MIPS. How can the oscillator circuit be configured?

A: Use the Fast RC oscillator B: Use the XT oscillator and the x16 PLL C: Use the Internal 7.37 MHz Fast RC Oscillator and the x16 PLL The system needs to minimize power, but receive a character from the UART. Which power saving state should the dsPIC DSC be in? A: Sleep mode B: Comatose mode C: Idle mode D: UART mode

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 62

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 63

MPLAB Visual Device Initializer (VDI)


Getting the dsPIC30F2010 Initialized with MPLAB VDI

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 64

MPLAB VDIOverview

Quick configuration of CPU and peripherals with resource conflict checks Generates code for peripheral initialization Readily extensible to other families and variants Currently supports:

PIC18C242, PIC18C252, PIC18C442, PIC18C452 PIC18F2420, PIC18F2520, PIC18F2525, PIC18F2620, PIC18F4420, PIC18F4520, PIC18F4525, PIC18F4620 PIC18F4680 PIC18F6520, PIC18F6620, PIC18F6720, PIC18F8520, PIC18F8620, PIC18F8720 dsPIC30F2010, dsPIC30F2011, dsPIC30F2012, dsPIC30F3010, dsPIC30F3011, dsPIC30F3012, dsPIC30F3013, dsPIC30F3014, dsPIC30F4011, dsPIC30F4012, dsPIC30F4013, dsPIC30F5011, dsPIC30F5013, dsPIC30F5015, dsPIC30F5016 dsPIC30F6010, dsPIC30F6011, dsPIC30F6012, dsPIC30F6013, dsPIC30F6014, dsPIC30F6015 dsPIC30F6010A, dsPIC30F6011A, dsPIC30F6012A, dsPIC30F6013A, dsPIC30F6014A Coming soon: PIC16F785

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 65

MPLAB VDIDevice Configuration


Drag and drop operation Context (right-click) menus


Feature configuration Error (also reflected in Output window) Zoom (shows pin allocation and signal direction) Clicking on a module opens configuration dialog

One-click configuration of individual modules


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 66

MPLAB VDIIntegration into MPLAB Project


VDI is built into the MPLAB menu system as a plug-in (under Tools menu) Code generation

Generates a C-callable assembly function


Uses ASM30 syntax for dsPIC30F Uses MPASM syntax for PIC18XXX


Generates a C header file and an assembly include file Generated code written to project directory, automatically included in project

Project aware

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 67

MPLAB VDIOther Features


Pin mouse-over

Shows pin number, functions and selection

Allocates resources for ICSP programming/ICD, if needed Device package selection (if others are available) Support Information

VDI Report Generation


Separate reports for interrupts, pins and SFRs

Spawns Acrobat for Data Sheet and Errata

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 68

MPLAB IDE

User-friendly interface for editing, compiling, programming and debugging code Color-coded source editor Includes free assembler, linker and simulator Support for several programming tools

MPLAB ICD 2, PRO MATE II, PM3, MPLAB ICE-4000

C source level debugging Supports third party tools MPLAB Visual Device Initializer (VDI) support

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 69

MPLAB VDIDemo 1 See Appendix A


Getting your dsPIC DSC Initialized with MPLAB VDI

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 70

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 71

dsPIC30F Advanced Peripherals

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 72

dsPIC30F Peripheral Summary


Analog Peripherals

Communication

10-bit A/D Converter 12-bit A/D Converter

UART (2) SPI (2) I2C Audio Codec Interface CAN (2)

Digital Peripherals

16-bit Timers (5) Input Capture (8) Output Compare (8) Quadrature Encoder Interface Motor Control PWM

dsPIC30F has advanced peripherals for advanced applications


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 73

dsPIC30F Advanced Peripherals A/D Converters


10- or 12-bit High-speed, Multi-channel

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 74

Feature Summary

Two A/Ds available on dsPIC DSC depending on device family 10-bit A/D 10-bit resolution with 1-bit accuracy Sample time84 ns (typ.) 1 sec/1Msps conversion time Up to 16 analog inputs, 4 S/H amplifiers 12-bit A/D 12-bit resolution with 1-bit accuracy Sample time334 ns (typ.) 5 sec/200 ksps conversion time Up to 16 analog inputs, 1 S/H amplifiers

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 75

Common Feature Summary


External VREF+ and VREFAnalog Input Range: (VREF-) to (VREF+) Allows uni-polar differential measurements

Reject common mode noise 16 sample, dual-ported result buffer Scan mode Alternate sample mode

Programmable sampling sequence


Multiple conversion trigger sources Selectable result formats Conversions in Sleep and Idle modes

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 76

12-bit A/D Block Diagram


VREF+ VREFAN0 AN1 CH0 S/H

Conversion Control

ADC 12-bit 200 ksps

16 word Buffer

Data Format

Bus Interface

Input Muxes

AN15

Sample Sequence Control

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 77

10-bit A/D Block Diagram


VREF+ VREFAN0 AN1 CH1 S/H CH2 S/H CH3 S/H AN15 CH0 S/H

Conversion Control

ADC 10-bit 1 Msps

16 word Buffer

Data Format

Bus Interface

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 78

Input Muxes

Sample Sequence Control

Multi-Channel Sampling
10-bit A/D has 4 Sample/Hold amplifiers

Enable 1, 2, or 4 per conversion sequence Simultaneous sample, then convert OR Sequentially sample

AN0 AN1 AN2 AN3

SIMULTANEOUS SAMPLING

SEQUENTIAL SAMPLING

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 79

Knowledge Check #6
You need to oversample a 50 kHz signal by 10x. Which ADC module can you use?

A: 12-bit ADC B: 10-bit ADC C: Both Which ADC module supports scanning mode? A: 10-bit ADC B: 12-bit ADC C: Answer A only D: Answer A and B

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 80

dsPIC30F Advanced Peripherals Motor Control PWM


Comprehensive Motor Drive

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 81

Motor PWM Feature Summary


Need an inverter control solution for ACIM, BLDC, SR motors? Dedicated 16-bit timebase Four PWM generators

Each PWM generator drives a pair of I/O pins I/O can be complementary or independent Center or edge aligned PWM Programmable output polarity for I/O

Dead time unit prevents power shoot-through Manual override control for motor commutation 2 fault pins control outputs without software

Programmable shutdown state Two operating modes

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 82

Motor Control PWM Block Diagram


Dead Time A 16-bit Time Base
Override Control

Dead Time B PWM4H Dead Time Unit PWM4L Dead Time Unit PWM Override Logic Dead Time Unit PWM3H PWM3L PWM2H PWM2L PWM1H Dead Time Unit PWM1L Fault A Fault B Two fault pins w/ programmable fault states Four PWM output pairs with output polarity control

Duty Cycle Generator #4 Duty Cycle Generator #3 Duty Cycle Generator #2 Duty Cycle Generator #1

A/D Conversion Trigger

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 83

Motor Control PWM


Independent mode used for switched reluctance motor


Special inverter circuit to control current in SR motors Independent mode enables both devices to turn on

+V

PWM1H

PWM2H

PWM3H

PWM4H

PWM1L

PWM2L

PWM3L

PWM4L

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 84

Motor Control PWM


Complementary mode used for 3-Phase AC Motor

Dead time avoids shoot through

+V
PWM1H PWM2H PWM3H

3 Phase ACIM

PWM1L

PWM2L

PWM3L

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 85

MCPWM Dead Time Insertion


Use in Complementary mode Two programmable dead times One dead time per pair for multiple inverters OR Two dead times per pair for distortion optimization 33 nsec minimum resolution, up to 10 sec

Dead Time A

Dead Time B

PWM1H PWM1H

PWM1L PWM1L

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 86

MCPWM A/D Synchronization


SEVTCMP register sets A/D conversion start time in PWM cycle Ensure A/D properly captures shunt current Can also used to minimize control loop update delay

Trigger conversion at end of bottom transistor on-time

PWM1H

PWM1H

PWM1L
To A/D

PWM1L
T

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 87

Knowledge Check #7
How many PWM outputs does the MC PWM peripheral support? A: 4 complementary pairs B: 8 independent pins C: Answer A and B Dead-time insertion may be implemented to prevent shoot-through for which PWM mode? A: Independent mode B: Overworked mode C: Complementary mode D: Answer A and C

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 88

dsPIC30F Advanced Peripherals Quadrature Encoder Interface


Motion Control Feedback Peripheral

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 89

Incremental Encoders

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 90

Encoder Timing Diagram


State machine determines relative phase at each edge

PHASE A

PHASE B COUNT
+1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 91

Quadrature Encoder Interface


Hardware to assist in calculations of position and speed? Three Input Quadrature Encoder Interface

Two inputs for Phase A and Phase B signals Index pulse input (output from encoder)

16-bit position counter Rollover count register (MAXCNT) simplifies RPM detection Module may function as 16-bit Up/down Timer Digital noise filter on all inputs

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 92

dsPIC30F Advanced Peripherals Data Converter Interface (DCI)


Audio Interface Peripheral

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 93

DCI Applications
Digital interface for higher quality audio & speech

Typical sample rate, 8 to 48 kHz Typical codec word size 13 to > 24 bits

Modem/telephony Musical instrument effects Speech recognition Speech/audio compression Echo cancellation Consumer-quality audio AC Power Quality Analyzer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 94

Codec Communication

DCI designed for continuous, streaming data Works like SPI, but SCK is continuous Streaming data is organized into frames

TDM data slots Multiple data words can be transferred Specific data assigned to a timeslot

Frame Sync (FS) signal marks the frame


FS starts a data transfer FS usually occurs at the audio sample rate

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 95

Multi-channel (Slot) Timing

SCK

FS Data
MSB LSB MSB

Single Word Transfer

SCK

FS Data
MSB LSB MSB LSB MSB LSB MSB LSB

Timeslot 0

Timeslot 1

Timeslot 2

Timeslot n

Multiple Word Transfer


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 96

DCI Features
Automatic synchronous serial data transfer TDM features support up to 16 data timeslots

Automatic slot management

Module has up to 4 word buffer (16-bit words) Master or slave operation Separate baud generator for SCK signal Support for I2S (Inter-IC Sound) and AC97 protocols

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 97

I2S Protocol

Philips specification (Inter-IC Sound) Common interface for high fidelity 2 channel stereo codecs FS has 50% duty cycle FS edge initiates transfer of appropriate channel

COFS CSDx
MSB LSB MSB LSB

Left Channel

Right Channel

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 98

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 99

Live Demonstrations
Using dsPIC30F tools in MPLAB Integrated Development Environment

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 100

MPLAB IDE
Integrated Development Environment
Built-In Editor
Languages

Project Manager
Low cost Debugging

Source Level Debug

Open Interface
3rd party Tools RTOS OSEK Compilers IAR, HiTech
Application Libraries

Emulation

Device Programming MPLAB PM3

Assembler

Software Simulator

MPLAB ICE 4000

Linker Librarian MPLAB C30 Compiler

MPLAB ICD 2 In-Circuit Debugger

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 101

MPLAB C30 C Compiler

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 102

MPLAB C30 Compiler


GNU-based Assembler, linker and librarian included ANSI C compliant, with standard libraries Optimized for dsPIC DSC architectural features

Utilizes advanced addressing modes Efficient multi-bit shift operations Efficient signed/unsigned comparisons Flexible memory usage models Support for constants stored in program memory

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 103

Compiler Optimization

Compiler supports 5 levels of code optimization


-O1, -O2, -O3, -Os, and no optimization Replacing loops with repeated code, to reduce execution time

Optional Loop Unrolling


Optional Procedural Abstraction


Combining similar pieces of code into common functions, to reduce code size

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 104

Compiler Optimization

Code size examples for different optimization levels for a brushless DC motor control application

No optimization: Loop Unrolling only: Optimization Level 1 (-O1): Optimization Level 2 (-O2): Optimization Level 3 (-O3): Optimization for Size (-Os):
MPLAB C30 v1.31.00

19584 bytes 14031 bytes 14361 bytes 12096 bytes 17292 bytes 13632 bytes

See Application Note AN901 (v1.00)


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 105

Run-Time Startup

Executes before the applications main( ) Initializes C framework


Initializes stack Initializes constants Initializes data memory Calls the users main function

If no data memory needs to be initialized Link with the --no-data-init option


Saves 50 instruction words

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 106

MPLAB IDEDemo 2 See Appendix B


Getting started with dsPIC30F and MPLAB IDE

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 107

Advanced Breakpoints

MPLAB ICD 2 provides breakpoints triggered by the following events


X bus read/write X bus read/write of a specific byte/word Y bus read Y bus read of a specific word Program memory execution TBLRD/TBLWT program memory PSV read
Select Debugger > Advanced Breakpoints

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 108

MPLAB IDEDemo 3 See Appendix C


Debugging an application with MPLAB ICD 2

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 109

Whats For LUNCH? Thats what Im talking about!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 110

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 111

dsPIC DSC Software and Hardware Tools


Vital building blocks to get your application running

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 112

dsPIC30F The Essential Software Tools


Product

Description
Integrated Dev. Environment Microchip ANSI C Compiler Assembler Linker Librarian Soft. Simulator (w/ Peripherals) Visual Device Initializer

Prod.
now now now now now now now

MPLAB v7.10 MPLAB C30 MPLAB ASM30 MPLAB LINK30 MPLAB LIB30 MPLAB SIM MPLAB VDI

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 113

dsPIC30F The Essential Hardware Tools Product / Description


Prod.
now now now now now now now now June 05

MPLAB ICD 2 - In Circuit Debugger MPLAB ICE 4000 - In Circuit Emulator MPLAB PM3 - Universal Device Programmer Motor Control Development Board dsPICDEM 28-pin Demo Board dsPICDEM 1.1 General Purpose Development Board dsPICDEM Starter Demo Board dsPICDEM.net Connectivity Development Board dsPICDEM 2 Development Board

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 114

Application Development Platforms

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 115

dsPICDEM MC1 Motor Control Development Board


dsPICDEM MC1 Development BoardDM300020


Full featured development boardUS $299 retail Excellent starting point for motor control-based applications Example code with Documentation CD Works with MPLAB ICD 2 In-Circuit Debugger/Programmer MPLAB ICE 4000 Emulator-ready

Supports AC Induction Motor (ACIM) Supports Brushless DC (BLDC)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 116

dsPICDEM MC1 Motor Control Development Board


37-pin Interface to Power Module Power supply dsPIC DSC emulation header MPLAB ICD interface and comm. selection switch RS-232 interface Motor control test points Hall-effect sensor terminals to capture pins Encoder input terminals to QEI QEI direction status LED Prototyping area CAN interface LEDs (4) RS-485 interface 16 x 2 LCD display Potentiometers (2) Buttons (4), plus PWM fault button
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 117

dsPIC DSC Motor Control Development Kit


Motor Connections (not shown)

3-Phase High Voltage Power Module

Input Source Connections

Motor Control Development Board

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 118

ACIM Development Components


dsPICDEM MC1 Motor Control Development Board DM300020(US $299 retail) dsPICDEM MC1H 3-Phase High Voltage Power Module DM300021(US $800 retail) 3-Phase ACIM High Voltage Motor (208/460V) AC300021(US $120 retail) Comes with example software and documentation CD

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 119

BLDC Development Components


dsPICDEM MC1 Motor Control Development Board DM300020(US $299 retail) dsPICDEM MC1L 3-Phase Low Voltage Power Module DM300022(US $700 retail) 3-Phase BLDC Low Voltage Motor (24V) AC300020(US $120 retail) Comes with getting started documentation

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 120

dsPICDEM 28-pin Starter Demo Board


dsPICDEM 28-pin Starter Demo BoardDM300017


Simple low-cost demo boardUS $79 retail Basic step-by-step getting started with dsPIC DSC Good starting point for 1st time user and beginners Simple demo and source code provided exercising

Interrupts, UART, I/O

Complete Users Guide available Works with MPLAB ICD 2 In-circuit Debugger/Programmer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 121

dsPICDEM 28-pin Starter Demo Board


UART

MPLAB ICD 2 Reset Switch Power-on LED LED(1)

+9Vdc
dsPIC DSC

XTAL

I/O Pin Header

Prototyping Area

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 122

dsPICDEM 1.1 Development Board


dsPICDEM 1.1 Development BoardDM300014

Full featured development boardUS $299 retail Excellent starting point for all general purpose applications Step-by-step getting started with simple tutorial project Enhanced digital signal processing demo and source code provided Complete Users Guide Works with MPLAB ICD 2 In-circuit Debugger/Programmer MPLAB ICE 4000 Emulator-ready

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 123

dsPICDEM 1.1 Development Board


RS-485 UARTs (2) +9Vdc In ICD 2 CAN dsPIC DSC Clock dsPIC DSC XTAL Plug-In Module Header +5V Reg. Codec

Codec Clock LCD 122x32 Dot-Addressable

Temp Sensor

Codec MIC In/ Spkr Out Switches (4) LEDs (4) POTs (3)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 124

dsPICDEM Starter Demo Board

dsPICDEM Starter Demo Board (SDB)DM300016


Simple low-cost demo boardUS $79 retail/($209 w/ MPLAB ICD 2) Basic step-by-step getting started with dsPIC DSC Good starting point for first time user and beginners Simple demo and source code provided Complete Users Guide available Works with MPLAB ICD 2 In-circuit Debugger/Programmer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 125

dsPICDEM Starter Demo Board


UART

MPLAB ICD 2

+9Vdc
Plug-in Module

LEDs

XTAL Digital Pot Low Pass Filter

Switches Reset Switch

Potentiometer
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 126

dsPICDEM.net Connectivity Board


dsPICDEM.net Connectivity BoardDM300004-1/2


Full-featured Connectivity boardUS $389 retail Excellent starting point for connectivity-based applications Step-by-step getting started with simple tutorial project Enhanced demo project utilizing all board functions

Full C and assembly code provided

V.22bis Soft-Modem Demo(full source code provided) CMX-MicroNet WEB Server Demo(.hex file) CMX-MicroNet FTP Server Demo(.hex file) Complete and Comprehensive Users Guide MPLAB ICD 2 and MPLAB ICE 4000 Emulator-ready

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 127

dsPICDEM.net Connectivity Board


UART +9Vdc In +5Vdc Reg. XTAL 10-Base T Ethernet NIC Plug-in Module Header 64Kx16 SRAM 2x16 Characters RS-485 24LC515 MPLAB ICD 2 CAN

PSTN Interface

Call Progress Speaker Temp Sensor LCD POTs (2) LEDs (3) Switches (3)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 128

General Purpose Development Board


UART MPLAB ICD 2 compatible CAN +9Vdc In

dsPICDEM 2

Motor Control Family dsPIC DSCs or MPLAB ICE 4000 device adapter installed here

Sensor and General Purpose Family dsPIC devices or MPLAB ICE 4000 device adapter installed here

LCD

2x16 Characters

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 129

General Purpose Development Board


Available June

dsPICDEM 2

dsPICDEM 2 Demo Board DM300018 Simple low-cost demo board - US $99 retail Development platform for 11 dsPIC30F devices

18-, 28- and 40-pin packages Motor Control, Sensor and General Purpose

MPLAB ICD 2 and MPLAB ICE 4000 -ready On-board CAN and UART support Support for Multiple Oscillator options C Example Code and User Guide provided

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 130

Desktop Tools
Windows-based applications to assist you with your design

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 131

dsPIC Digital Filter Design


Whats so great about digital filters?


More accuracy than analog filters


No age or temperature drift Better phase response, frequency response Hardware doesnt changejust coefficients! Fewer components Less board space Lower cost

Simple to modify

Benefits of replacing analog filters


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 132

dsPIC Digital Filter Design


Graphically design all types of digital filters


Low-pass, high-pass Band-pass, band-stop FIRFinite Impulse Response IIRInfinite Impulse Response

Digital filter algorithm kernels are provided for:


Designing coefficients to control the filter response is the tricky part


You can do the math or use this tool!!

Quickly observe filters response Generated code and coefficients fully compatible with MPLAB C30 C Compiler language tools

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 133

dsPIC Digital Filter Design

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 134

dsPICWorks Data Analysis and DSP Software


FREE

Graphical signal analysis and generation tool


Create waveforms and process them Signal generation


SIN, square, swept SIN, triangular, etc... Add, Flip and Shift, Multiply, etc... Filtering, correlation, FFT, LPC analysis, etc...

Signal operations

DSP operations

Designed especially for the dsPIC30F


Import/export data with MPLAB compatible files Processes filter files saved from dsPIC Digital Filter Design

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 135

dsPICWorks Data Analysis and DSP Software

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 136

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 137

Hands-on SessionPart 1 dsPIC Digital Filter Design & dsPICworks Visual Algorithm Analyzer
Digital Filtering and DSP Simulations in a Jiffy!!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 138

Hands-on SessionObjectives

Design a Filter

Use dsPIC Filter Design Lite IIR band-stop filter specification: Sampling Rate = 11127 Hz Stop Band: 1200 Hz to 1250 Hz Stop Band Attenuation Pass Band Ripple = 50 dB Pass Band: Up to 1000 Hz and > 1400 Hz = 0.1 dB

Simulate Filter Operation


Use dsPICworks Analyzer Use the designed filter to remove 1225 Hz tone component from a WAV file

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 139

The Essential DSP Tools


dsPIC DSC Digital Filter Design


Design optimal IIR and FIR filters


Band-pass, band-stop, high-pass and low-pass filters

Graphical user interface to further ease design Plots and graphs include

Magnitude and phase response Pole-zero plots on the unit circle Impulse and step response Filter coefficient and code generation

dsPIC DSC support


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 140

Digital Filter Design Lite


Digital Filter Design Tool available in two flavors:

Full-blown version Lite version


Lite version provided with dsPIC DSC Seminar Software

Get StartedInvoke our enLitened Filter Guru


from the Windows Start Menu OR Start > Programs > MDS > dsPICfdlite click on the short-cut on your desktop

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 141

Digital Filter Design Lite

Click here to load filter specification file

Lets load an existing filter specification file Click on the SPC icon to load a specification file created for this demo

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 142

The Essential DSP ToolsExercise 1

See Appendix D
Using Digital Filter Design Lite

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 143

The Essential DSP Tools


dsPICworks Analyzer: Data Analysis & DSP Software


Simulate complex DSP functions & mathematical expressions


Difference equations, scaling etc. Digital Filters, FFT, Inverse-FFT etc. Sine, triangular, square etc. Add noise to signals 1-, 2- and 3-d FFT plots

Generate Signals

Analyze data in frequency-domain


Import/export capabilities

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 144

dsPICworks Analyzer: Filters in Action


A sample Windows WAV file is provided to you <Your Path:\>dsPIC Seminar\Follow_Along\Part 1


WAV file has spurious tonal noise at 1225 Hz You could listen to it on your PC! Import the WAV file Run the data through the designed filter Export the filtered data to a Windows WAV file Listen to the WAV file Click on the desktop icon OR from the Windows Start menu Start > Programs > MDS > dsPICworks

We will now use dsPICworks Analyzer to


Get StartedInvoke dsPICworks Analyzer


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 145

The Essential DSP ToolsExercise 2

See Appendix E
Using dsPICworks Visual Algorithm Analyzer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 146

Thank You

That was pretty easy! I want to see some closed loop action!! Take me to the PID Control Demo Now!!!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 147

Hands-on SessionPart 2
PI Controller

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 148

PI Controller Follow-Along

Use tools and dsPIC30F to simulate closed loop process Control loop examples:

Motor position servo Temperature control Fluid level control Adjust for quickest response without overshoot

Use PI controller to stabilize control loop


Use the Digital Filter Design tool to model the controlled process Write code in C for PI controller Call assembly code digital filter code from C Display simulation results using dsPICworks Analyzer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 149

PI Control

Control Loop

Measure feedback representing plant output Calculate error based on desired output Calculate input to plant using PI controller

Develop plant function with dsPIC Digital Filter Design Write PI Controller in C code Display controller output in dsPICworks analyzer

Setpoint

Error

PI Control Feedback

Plant

Plant Output

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 150

PI Control

What does a PI(D) controller do?


(P)roportional term responds to magnitude of error (I)ntegral term responds to time accumulation of error (D)erivative term responds to time change in error

Proportional term sets overall response of controller Integral term corrects small steady-state errors Derivative term speeds up/slows down response PID controller allows empirical tuning of system

Tweak knobs until system is well-behaved

PID_Output = err*Kp + err*Ki + err*Kd


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 151

Hands-on SessionPart 2 See Appendix F


PI Controller Hands-on

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 152

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 153

dsPIC30F Libraries and Tools


Trusted software to speed up your development cycle

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 154

dsPIC30F Libraries

Developed by Microchip and reputable third parties


Ease of use for getting your application running Smallest footprint (RAM and Flash) Fast execution

Optimized for dsPIC30F architecture


Compliant with Microchip MPLAB C30 C Compiler development tools Three Classes of Tools and Libraries

General LibrariesDSP, Math and Peripheral Application LibrariesEncryption, Noise Suppression, more. Desk Top ToolsdsPIC Digital Filter Design, dsPICworks Visual Algorithm Analyzer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 155

General Libraries
These libraries are generic enough to be used by most applications

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 156

Math Library

FREE

Supports all of <MATH.H> from ANSI C


Trigonometric Functions Exponent and Log Functions Power, Square Root, Floor, Ceiling, etc.

IEEE-754 Compliant Optimized for code size, developed in Assembly Supports 2 data types

32-bit floating point 64-bit double

Benefits any application which uses floats/doubles C and assembly callable

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 157

DSP Library

FREE

Libraries for your DSP requirements Collection of 49 of the most common DSP functions

Vector and Matrix Functions


Add, Subtract, Multiply, Max, Min Convolution, Correlation, Power, etc... FIR, IIR, Adaptive LMS, Lattice and more FFT, Inverse FFT, Discrete Cosine Transform Bartlett, Blackman, Hamming, Hanning, Kaiser

Filter Functionsblock and single sample processing


Transform Functions

Window Functions

Most functions are hand coded in assembly language


Fast execution time, C and assembly callable

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 158

Peripheral Library

FREE

Libraries for initializing the

dsPIC

DSC Peripherals

275 driver functions for all dsPIC30F modules ADC (10-bit and 12-bit) CAN, DCI I2C, SPI, UART Input capture, output compare Motor control PWM, QEI External interrupts, I/O Ports, reset module Timers Peripheral Library is written in C Compiled for size optimization Benefits Master the peripheral learning curve Easy-to-learn standard interface

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 159

Real-Time Operating Systems (RTOS)


What is an RTOS? What are the benefits of an RTOS?


Easy real-time managementwell suited for...


Large applications Scalable applications Event flags, queues and message mailboxes Independent processes or tasks Provides true preemption capability

Inter-task communication and event handling


Code becomes well structured


Faster than the usual while(1) loop


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 160

RTOS and the dsPIC30F


RTOS was written by CMX Systems, Inc.


Industry leading RTOS developer CMX-RTXfull featured RTOS CMX-Tiny+contains many features of CMX-RTX CMX Schedulerlimited to 5 tasks, minimal features Small memory footprint Fast context switch times Reasonable interrupt latency No royalty payments

3 different flavors were ported to the dsPIC DSC


FREE


Each RTOS features


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 161

Application Specific Libraries


These libraries provide a system solution which can be used as a major building block for your design

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 162

Embedded Modem Library


Software Modem (soft-modem) Support


Replacing external modem chip with software! Single-chip integrated solution (up to 14.4 kbps) Quick dialup and connection times

Benefits

Perfect for small transactions on analog phone line

Application Examples

Home automation, remote access, security systems POS applications, web-enabled devices Tele-metering, remote upgrades

Library supplied with full DTMF Generation/Detection modules

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 163

Soft-Modem Resource Summary


dsPIC30F implementation leaves room for other tasks...


Program Memory (Kbytes) 36 31 22 15 13 14

ITU-T Specification V.32bis V.32 V.22bis V.23 V.21 V.42 (Error Corr.)

Bit Rate (bps) 14400 9600 2400 600/1200 300 na

RAM (Bytes) 3600 3200 1700 1000 1000 2000

MIPS 15 12 7 4.5 4.5 1.5

FREE

Includes DTMF Library

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 164

Microchip FREE TCP/IP Stack for dsPIC


Main Features

Portable across dsPIC30F microcontrollers Out of the box support for Microchip MPLAB C30 compiler RTOS Independent Full TCP State machine Modular Design Socket support for TCP and UDP Microchip File System (MPFS)

Use it as a HTTP Server (included) or any customer TCP/IP based application

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 165

CMX-MicroNet Library

Features

A complete connectivity solution which supports...


HTTP Server File transfers E-mail client

Benefits

Single-chip solution Small Flash and RAM requirements One time feeno royalties on deployed products Web browsers, remote monitoring, file transfer

Target Products

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 166

CMX-MicroNet Protocols

Base Protocols

TCP (robust) UDP (no handshaking) IP (must have) SLIP (serial port) PPP (modem layer to ISP) ARP (Ethernet address) BOOTP HTTP FTP Server TFTP Client SMTP Client DHCP Client (Web Server) (File Transfer) (UDP) (E-Mail)

Supported Physical Connections


Direct connect Ethernet Dialup (modem)

Application Layer Protocols


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 167

Speech Coding Library


Performs speech compression / decompression Encoder - 16:1 compression ratio


Speech input: 8 KHz, 16-bit mono Encoded output: 8kbps data stream Decoder input: 8 kbps data stream Speech output: 8 KHz, 16-bit mono Open source technology Numerous PC plug-ins / apps readily available www.speex.org

Decoder

Based on Speex

Includes PC Utility for making playback files

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 168

Speech Coding Library


How may it be used?
By any application with voice communication Benefits

Reduces communication bandwidth Reduces storage requirements Digital radios / walkie-talkies Answering machines / voice recorders Playback-only systems

Sample Applications

Security Systems (building evacuation) Museum Guides Application Voice Prompts

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 169

Speech Coding Library


Resource Requirements

Small Decoder footprint / Encoder is RAM intensive MIPs RAM Flash Encoder 19 5.4 KB 33 KB Decoder 3 3.2 KB 15 KB

2 analog interfaces supported


Silicon Labs Si-3000 Codec Alternate interface for cost-sensitive applications


ADC for microphone input Output compare for speaker output Sample circuits provided in Users Guide

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 170

Acoustic Echo Cancellation Library


Provides far-end echo cancellation


Speaker output is picked up by the local microphone and transmitted back to the sender G.167-compliant algorithm (up to 64 msec) Supports full-duplex operation

Features

G.167

G.167

Acoustic Echo

Speech

Sender

Transmission Medium

Receiver

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 171

Acoustic Echo Cancellation Library


G.167 CPU Resources


Echo Delay 16 msec 32 msec 64 msec RAM (KB) 4.6* 5.4* 7.7* Program Memory (KB) 6 6 6 MIPS 7.5 10.5 16.5

* Includes up to 2KB for CODEC and UART buffers and A/U-law compression

Target Applications

Speakerphone Hands-free car phone Intercom Emergency alarm units

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 172

Noise Suppression Library


Removes extraneous noise picked up by microphone


Voice activity detector differentiates noise and speech Noise reduction filters adjust every 10 ms during periods of speech inactivity (uses FFT analysis) Speech is continuously filtered, reducing noise
Noise

Speech

Noise Suppression Library Comm. System

SpeechNoise

Noise

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 173

Noise Suppression Library


Noise Suppression CPU Resources


3.3 MIPS 5 Kbytes Flash memory 2 Kbytes RAM


Includes up to 1 Kbyte for buffering Codec data

Target Applications

Front end for any voice based system


Headsets Hands-free telephone Intercom Speech recognition Speech coding

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 174

Embedded Encryption Libraries


dsPIC30F Symmetric Key Library


Message Digests: SHA-1, MD5 Symmetric Key Encryption: T-DES, AES Deterministic Random Bit Generator: ANSI X9.82

dsPIC30F Asymmetric Key Library


Signing and Verification: RSA, DSA Public Key Encryption: RSA Key Agreement Protocol: Diffie-Hellman Big Integer Arithmetic Package

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 175

Embedded Encryption Applications


Secure Web Transactions


Secure web access (SSL/TLS) E-mail (S/MIME), secure XML transactions, and Virtual Private Networks (IPsec)

Smart Card Readers PDAs and other mobile devices Secure communications between a dsPIC DSC application and personal computers

Trusted Computing Group (TCG) Microsoft Next Generation Secure Computing Base (NGSCB)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 176

Motor Control Solutions

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 177

dsPIC30F for Motor Control


When is dsPIC30F needed for motor control?

Closed loop variable speed control Eliminate sensors High speed operation Support other tasks

dsPIC30F benefits

16-bit math Fast 10-bit A/D converter - (1 Msps) Dedicated motor peripherals (PWM and QEI) Large program memory, large RAM

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 178

Motor Control Solutions


Vector Control of AC Induction Motor Open Loop AC Induction Motor Control Sensorless Control of Brushless DC Motor Sensored Control of Brushless DC Motor dsPICDEM MC1 Motor Control Development System PICDEM MCLV Motor Control Development Board

dsPICDEM MC1 Motor Control Development System allows rapid development of motor control software.

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 179

Vector Control of ACIM


ACIM is widely used

Why? Simple construction and AC power

Can be difficult to control variable speed Vector math makes AC motor look like DC motor

Less expensive ACIM is better controlled Current, torque and speed controlled closedloop Transient response to load changes Efficiency

Benefits of vector control


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 180

Vector Control of ACIM


FREE

Closed-loop control for 3-phase motors Microchip Application Note: AN-908


Well-documented solution including source code Designed to run on motor control board Residential

Example Applications

Washing machine, electric scooter Conveyor, hoist, mixer Electrically driven engine accessories

Industrial

Automotive

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 181

Open Loop Control of ACIM


FREE

Open-loop control for 1-phase 3-phase motors Microchip Application Note: AN-984

Well-documented solution including source code Designed to run on dsPICDEM MC1 System

Introductory application note to help you get started with AC Induction Motor control

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 182

Sensorless BLDC Control


BLDC is an inside-out brush DC motor External sensors replace the function of brushes and tell external logic when to energize phases (similar to automotive engine distributor) Sensorless approach monitors motor phases during non-driven periods to find timing reference points using A/D converter dsPIC DSC performs sensorless commutation, current control, speed control, and sensorless error detection

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 183

Sensorless BLDC Control


FREE

Microchip Application Note: AN-901 Who can use sensorless BLDC control?

Application needs efficiency of BLDC motor Low speed operation not required Closed loop control needed, but not fast response Want to eliminate cost of sensors, wiring Sensors cannot tolerate operating environment HVAC blower motor Refrigerator compressor Automotive fuel pump, radiator fan Medical tool/instruments

Sensorless algorithm well suited for fans, pumps


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 184

Sensorless BLDC Control


FREE

Microchip Application Note: (June 2005 release)


Sensorless BLDC motor Control using 28-pin dsPIC30F devices AN901 code transferred to dsPIC30F2010 Operates on PICDEM MCLV board Code has optional ASCII Serial User Interface to set all Control, Motor and User Parameters

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 185

Sensorless BLDC Control


Sensorless BLDC Motor Control GUI


Available Q3

Included for free with

MPLAB

software

Tune control loops and starting parameters with MPLAB ICD 2 Shorten sensorless software development time

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 186

PICDEM MCLV Board


New

Supports dsPIC30F2010 and PIC18F23X1 Supports BLDC from 10V to 40V DC Hall sensor or sensorless control Out-of-Box: 24V Pwr. Supply, Hurst BLDC motor dsPIC30F2010 and PIC18F23X1 firmware MPLAB ICD 2 Debug/Programming capability Serial Interface

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 187

Motor Control Solutions


CPU Resource Requirements for Advanced Algorithms


Program RAM Memory (Bytes) (KB) 244 7.3 268 10

Algorithm Vector ACIM Sensorless BLDC

MIPS 9 5

Small code footprints!


ACIM and BLDC will run on the dsPIC30F2010

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 188

Seminar Agenda
Session

Time 9:009:15am 9:1510:30am 10:3010:45am 10:4511:15am 11:1511:50am 11:5012:30pm 12:301:30pm 1:301:50pm 1:502:50pm 2:503:15pm 3:153:30pm

Corporate Overview Architecture Break MPLAB VDI Demonstration Peripherals Live Demonstrations Lunch Software/Hardware Tools Hands-on Libraries/Applications Session Wrap-up

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 189

Where do you go from here?


Microchip web site Web Seminars Workshop-in-a-Box Key dsPIC DSC documents to review Microchip online discussion groups Application development platforms buy.microchip.com MASTERs 2005

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 190

dsPIC30F Product Families


Motor Control & Power Conversion Family
Product P i n s Flash KB 12 24 48 24 48 66 144 SRAM Bytes 512 1024 2048 1024 2048 2048 8192 EE Bytes 1024 1024 1024 1024 1024 1024 4096 Timer 16-bit 3 5 5 5 5 5 5 Input Cap 4 4 4 4 4 4 8 10-bit Output Motor A/D Quad Comp/ Cntrl 500 Ksps Enc Std PWM (2 us) PWM 2 2 2 4 4 4 8 6 6 6 6 6 8 8 6 ch 6 ch 6 ch 9 ch 9 ch 16 ch 16 ch Yes Yes Yes Yes Yes Yes Yes U A R T 1 1 1 2 2 1 2 S I C P 2 A I C N 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 2 1

dsPIC30F2010 28 dsPIC30F3010 28 dsPIC30F4012 28 dsPIC30F3011 40 dsPIC30F4011 40 dsPIC30F5015 64 dsPIC30F6010 80

All

dsPIC

DSC Released to Production (except 5015)


Brushless DC motor control AC induction motor control Switch reluctance motor control UPS, inverters and power supplies

Appliances Power tools Automotive Industrial

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 191

dsPIC30F Product Families


General Purpose Family
Product Flash KB 24 48 66 132 144 66 132 144 Output SRAM EE Timer Input Compare Bytes Bytes 16-bit Capture Std PWM 2048 2048 4096 6144 8192 4096 6144 8192 1024 1024 1024 2048 4096 1024 2048 4096 3 5 5 5 5 5 5 5 2 4 8 8 8 8 8 8 2 4 8 8 8 8 8 8 A/D 12-bit 100 KSPS 13 ch 13 ch 16 ch 16 ch 16 ch 16 ch 16 ch 16 ch U A R T 2 2 2 2 2 2 2 2 S P I 1 1 2 2 2 2 2 2 I
2

Pins

C 1 1 1 1 1 1 1 1

C A N

Codec Interface

dsPIC30F3014 dsPIC30F4013 dsPIC30F5011 dsPIC30F6011 dsPIC30F6012 dsPIC30F5013 dsPIC30F6013 dsPIC30F6014

40 40 64 64 64 80 80 80

1 2 2 2 2 2 2

AC97, I2S AC97, I2S

AC97, I2S AC97, I2S

AC97, I2S

All dsPIC DSC listed are Released to Production


Classic General Purpose 16-bit Controller Family Members with codec are ideal for speech/audio applications

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 192

dsPIC30F Product Families


Sensor Processor Family
Product Pins Flash KB 12 24 12 24 Output SRAM EE Timer Input Compare Bytes Bytes 16-bit Capture Std PWM 1024 2048 1024 2048 1024 1024 3 3 3 3 2 2 2 2 2 2 2 2 12-bit A/D 100 Ksps (10us) 8 ch 8 ch 8 ch 8 ch U A R T 1 1 1 2 S P I 1 1 1 1 I
2

C 1 1 1 1

C A N

dsPIC30F2011 dsPIC30F3012 dsPIC30F2012 dsPIC30F3013

18 18 28 28

All dsPIC DSC listed are Released to Production


Glass break detect Gas sensor Torque sensor Steering angle sensor Voice activation Bar code reader

Low power, smart sensor Airbag smart sensor Pressure sensors Vibration measurement Gyroscope

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 193

Microchip Application Support

www.microchip.com
Data Sheets, Application Notes, Design Centers

Select Best Devices

Order Free Samples

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 194

dsPIC30F On-Line Web Seminars


What is a dsPIC DSC? Introduction to the dsPIC30F Architecture (2 modules) dsPIC30F Addressing Modes (2 modules) dsPIC30F DSP Engine & ALU dsPIC30F Interrupts dsPIC30F 12-bit ADC Module (2 modules) dsPIC30F 10-bit ADC Module (2 modules) dsPIC30F Motor Control PWM Module dsPIC30F Quadrature Encoder Interface Module dsPIC30F UART Communication Module dsPIC30F SPI Communication Module dsPIC30F CAN Communication Module dsPIC30F I2C Communication Module dsPIC30F General Purpose Timer Module

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 195

Workshop in a Box Training Getting Started


dsPIC DSC Workshop in a Box (WIB)


6 hour training session with hands-on exercises


Focused on Getting Started with the basics

Use laptops and MPLAB ICD 2 (supplied) Purchase a kit for US $99.00 retail

Includes dsPICDEM 1.1 Development Board

Microchip and Distributor FAEs conduct the training

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 196

Workshop in a Box Training BLDC Motor Control


dsPIC DSC Workshop in a Box (WIB)


6 hour training session with hands-on exercises


Focused on BLDC motor, Sensored and Sensorless control

Use laptops, MPLAB ICD 2 and BLDC motor (supplied) Purchase a kit for US $99.00 retail (w/o motor)

Includes PICDEM MCLV Development Board


Microchip and Distributor FAEs conduct the training

Release: CQ3 2005


Coming Soon !

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 197

dsPIC DSC Key Support Documents

Device Selection Reference


Document# DS70083 DS70082 DS70043

General Purpose and Sensor Family Data Sheet Motor Control and Power Conv. Data Sheet Product Family Overview

Base Design Reference


Document# DS70046 DS70030 DS51284 DS51317

dsPIC30F Family Reference Manual dsPIC30F Programmers Reference Manual MPLAB C30 C Compilers Users Guide MPLAB ASM30, LINK30 & Utilities Users Guide

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 198

dsPIC DSC Key Support Documents

Device Specific Reference


Document# DS70117 DS70119 DS70118 DS70116 DS70135 DS70139 DS70138

dsPIC30F6011/12/13/14 Data Sheet dsPIC30F6010 Data Sheet dsPIC30F2010 Data Sheet dsPIC30F5011/5013 Data Sheet dsPIC30F4011/4012 Data Sheet dsPIC30F2011/2012/3012/3013 dsPIC30F3014/4013 Data Sheet

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 199

Online Discussion Group

Join Now
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 200

MASTERs Conference

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 201

dsPIC30F

Looks Like a MCU Performs Like a DSP Priced Like a MCU

The 16-bit MCU with the power of DSP

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 202

Thats It!! Thank You!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 203

Appendices

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 204

Demos/Hands-on
Demos

Appendix AGetting started with MPLAB VDI Appendix BMPLAB IDE Demo Appendix CDebugging with MPLAB ICD 2 Hands-on

Appendix DUsing dsPIC Filter Design Lite Appendix EUsing dsPICworks Analyzer Appendix FPI Controller

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 205

Appendix A Demo 1
Getting your dsPIC DSC initialized with MPLAB VDI

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 206

MPLAB VDIDemo 1

Open tools1.mcw Click Tools > Visual Initializer to open MPLAB VDI

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 207

MPLAB VDIDemo

Click on the 16-bit Timer1 icon Configure the Timer1 peripheral


Enable module Enable interrupt Prescaler = 1:256 Time period = 500 ms

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 208

MPLAB VDIDemo

Build, program and run LED blinks every 1 sec!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 209

Appendix B Demo 2

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 210

MPLAB IDEDemo 2

Learn to use dsPIC30F tools in MPLAB IDE Four steps Step 1Create a project in MPLAB IDE Step 2Compile code using the MPLAB C30 C Compiler Step 3Program a dsPIC30F device on a dsPICDEM 28-pin Starter Demo Board using MPLAB ICD 2 Step 4Run and debug code on a dsPICDEM 28-pin Starter Demo Board using MPLAB ICD 2

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 211

Step 1
Creating an MPLAB IDE Project

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 212

Creating an MPLAB IDE Project


Start MPLAB IDE

Tool Bar Project View

Menu Bar

Output View Status Bar


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 213

Creating an MPLAB IDE Project


Click Project menu Select Project Wizard

Project Wizard screen opens Click Next

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 214

Creating an MPLAB IDE Project


Select dsPIC30F2010 Click Next

Select Microchip C30 Toolsuite Click Next

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 215

Creating an MPLAB IDE Project


Type the Project Name Click Browse

Navigate to project path Click Select Click Next

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 216

Creating an MPLAB IDE Project


Select the required source files and linker script file (p30F2010.gld) Click Add and Next

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 217

Creating an MPLAB IDE Project

Summary screen appears Click Finish This creates a Workspace (.mcw) and a Project (.mcp) file

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 218

Creating an MPLAB IDE Project


Project Window now shows the demo project Files can also be added by right-clicking a file category Include files can also be added for reference Double-click any file to view and edit the file

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 219

Step 2
Compile and Link the Project

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 220

Compiling and Linking an MPLAB IDE Project


Before we compile and link:


Tell compiler where to find device header file #include <p30F2010.h> Tell linker to reserve RAM for MPLAB ICD 2 Click Project menu, and select Build Options > Project

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 221

Compiling and Linking an MPLAB IDE Project


Find Include Path Click Browse

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 222

Compiling and Linking an MPLAB IDE Project


Include path now points to header files

Click MPLAB LINK30 tab Select Link for ICD 2 and click OK
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 223

Compiling and Linking an MPLAB IDE Project

Click Project menu Select Make

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 224

Compiling and Linking an MPLAB IDE Project


Build results, and sizes of various code sections, are shown in Output window

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 225

Step 3
Use the MPLAB ICD 2 to program the code

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 226

Programming the Device


Hardware

MPLAB ICD 2 dsPICDEM 28-pin Starter Demo Board

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 227

Programming the device


Set up the hardware


Connect power to the dsPICDEM 28-pin Demo Board Connect USB cable from PC to MPLAB ICD 2 Connect MPLAB ICD 2 to the board Choose Select Tool and MPLAB ICD 2


Click Debugger menu


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 228

Programming the device


Click Debugger menu Choose Connect

Operating System Download


MPLAB IDE may ask to download a new operating system Click Yes

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 229

Programming the Device


Output window

MPLAB ICD 2 automatically identifies the target device

Click Debugger menu and Program

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 230

Step 4
Use the MPLAB ICD 2 debugging features

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 231

Running and Debugging


Click View menu


Choose Program Memory

Press F6 to Reset Press F9 to Run Press F5 to Halt

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 232

Running and Debugging


3 different debugging options


Program Memory window (shown in previous slide) C or assembly source file


Simply open source file Click View menu and Disassembly Listing

Disassembly window

Observe the compact code!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 233

Running and Debugging


Reset, Right-click the line to run to, and choose Run to Cursor Instructions up to the next line are executed, and the arrow points to the next line

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 234

Running and Debugging


Find the line on which you want to break Right-click and choose Set Breakpoint Press F6 and then F9 to Run Green arrow points to line with breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 235

Running and Debugging


Press F7 to single step a line of code Press F8 to step over a function call After each single step, green arrow points to the next instruction to be executed

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 236

Running and Debugging


Click View menu Choose Watch

Select the register to be watched Click Add SFR For user variables, use Add Symbol instead

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 237

Running and Debugging


Watch window gets updated on a Breakpoint, Halt or Reset


Watch window can also be refreshed by right-clicking and choosing Refresh Double-clicking the Value field enables modifying the value of SFRs or variables added to Watch

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 238

Running and Debugging


Watch window values can be displayed in several data formats


Right-click the variable and select Properties

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 239

Advanced Breakpoints

Breakpoint on X bus write


Specify the X bus write address which should trigger a breakpoint Reset and run the code

Write Breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 240

Advanced Breakpoints

Breakpoint on X bus read


Specify the X bus read address which should trigger a breakpoint Reset and run the code
Read Breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 241

Advanced Breakpoints

Breakpoint on X bus write of specific word (or byte)


Specify the required write address and data value which should trigger a breakpoint
Write Breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 242

Advanced Breakpoints

Breakpoint on X bus read of specific word (or byte)


Specify the required read address and data value which should trigger a breakpoint
Read Breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 243

Advanced Breakpoints

Now change Data Value


Now the code does not break in either case!!

Similar functionality for X bus byte reads/writes as well as Y bus word reads

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 244

Advanced Breakpoints

Breakpoint Pass Count2 types

Break 5 instructions after breakpoint

Break 5 instructions after breakpoint

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 245

Advanced Breakpoints

Reset and run the code for each Pass Count Type

Code execution halts in either case

Break on 100 breakpoint hits

Break on 100 breakpoint hits

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 246

Appendix C Demo 3
Debugging with MPLAB ICD 2

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 247

MPLAB IDEDemo 3

Learn to troubleshoot an application with MPLAB ICD 2 Objective: To blink the LED every 1 sec

Timer1 used to generate a 5 ms period A variable TimerTicks counts the number of period matches When TimerTicks = 100 (0.5 sec), LED is toggled Build, program and run LEDs are blinking too fast!! Use Advanced Breakpoints to find the bug Hint : Is TimerTicks prematurely getting set to 100 somehow? But where??

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 248

MPLAB IDEDemo 3

Set up an Advanced Breakpoint to test if TimerTicks is getting set to 100 in the code

Reset and run the program

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 249

MPLAB IDEDemo 3

Code halted immediately after if (TimerTicks = 100)

Ah, there it is!!

Should be if (TimerTicks == 100), not if (TimerTicks = 100)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 250

Appendix D Hands-on
Using dsPIC Filter Design Lite

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 251

Loading a Filter Spec File

Click here to load filter specification file

Select bsiir.spc file in the browse window from under <Your Path:\>dsPIC Seminar\Follow_Along\Part 1\

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 252

Choosing the Filter Type

Click Next

For this demo the band-stop IIR filter has been selected The *.spc file contains information on the nature of filtering action (high-pass, low-pass, band-pass or bandstop) and the filters exact specification

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 253

Specifying the Filter Parameters

User may enter desired filter characteristics here

Click Next

The filter specification will appear on this dialog box


This information is also retrieved from the *.SPC file

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 254

Filter Estimate

Best filter option advised by the tool

Click Next

dsPIC Filter Design estimates the filter order for several popular filter structures The filter option with the best response for the given specification is pre-selected for the user by the tool!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 255

And you really wanted to calculate H(z) by hand!!!


Phase Response Magnitude Response Group Delay

Impulse Response

Poles and Zeros around the Unit Circle

Step Response
2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 256

Saving Off the Filter Coefficients

We now need to save the coefficients for the generated filter to a file The filter coefficient file will be used in dsPICworks Analyzer to simulate filter action

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 257

Saving Off the Filter Coefficients

Save the filter coefficients to a file named bsiir.flt under <Your Path:\>dsPIC Seminar\Follow_Along\Part 1\ Close dsPIC Filter Design Lite We will use the filter coefficient file in the next exercise Return to foil 144

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 258

Appendix E Hands-on
Using dsPICworks Visual Algorithm Analyzer

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 259

dsPICworks Analyzer Importing Files

First, well import the WAV file into dsPICworks Analyzer native file format (*.TIM)

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 260

dsPICworks Analyzer Importing Files

In the Import File dialog, first select the Windows Wave file option as the file format to be imported

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 261

dsPICworks Analyzer Importing Files

Next, we select the Source file flushtone.wav, for the import operation, using the Select Waveform File dialog

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 262

dsPICworks Analyzer Importing Files

For WAV files, dsPICworks Analyzer will read the sampling rate information from the file

When finished selecting the required options click OK

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 263

dsPICworks Analyzer Time Files

The imported time samples are stored in a TIM file that is automatically displayed

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 264

dsPICworks Analyzer Computing FFT

Lets perform an FFT operation on the TIM file to view the strength of the 1225 Hz tone in the spectrum We will use the defaults in the FFT Dialog

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 265

dsPICworks Analyzer Computing FFT

dsPICworks Analyzer natively uses float data types to store frequency domain information

This information can be exported out of dsPICworks Analyzer in fixed point format if required You may acknowledge the message by clicking OK

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 266

dsPICworks Analyzer Input Data Spectrum

Spurious tone

A frequency file (*.FRE) is created and displayed when the FFT algorithm executes Can you spot the 1225 Hz tone?

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 267

dsPICworks Analyzer Signal Filtering

Next, we will try to filter the 1225 Hz tone out by using the Signal Filtering option

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 268

dsPICworks Analyzer Signal Filtering

We will use the Filter Coefficient file bsiir.flt, generated earlier in dsPIC Digital Filter Design Lite, to perform signal filtering

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 269

dsPICworks Analyzer Signal Filtering

Next, we also select an output file for the filtered data. We will call it flush.tim and place it at: <Your Path:\>dsPIC Seminar\Follow_Along\Part 1

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 270

dsPICworks Analyzer Signal Filtering

Once all the input and output files have been chosen, click on OK

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 271

dsPICworks Analyzer Filtered Output in Time-domain

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 272

dsPICworks Analyzer Computing FFT

Once again, we will compute an FFT


Use the filtered output time-domain file as input

Use all the defaults in the FFT Dialog and click OK

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 273

dsPICworks Analyzer Input v/s Output Spectrum

Filtered Output Spectrum

Input Signal Spectrum

Notice the effect of filtering on the tone at 1225 Hz

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 274

dsPICworks Analyzer Exporting Data

Next we will export the filtered output to a 16-bit WAV file

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 275

dsPICworks Analyzer Exporting Data

Once the Export File dialog has been set up, click OK

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 276

dsPICworks Analyzer WAV Playback

WAV file containing filtered signal

In Windows Explorer, notice the new WAV file. You may play this back on a Windows Media Player and notice the absence of the tonal component at 1225 Hz Return to foil 148

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 277

Appendix F Hands-on
PI Controller

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 278

Plant Response
Use dsPIC Digital Filter Design Lite to generate plant function

Lowpass IIR filter


1000 Sampling frequency 50 Passband frequency 200 Stopband frequency 1 Passband ripple 40 Stopband ripple

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 279

Plant Response

Use dsPIC Digital Filter Design Lite to generate plant function Use 4th order Butterworth filter

1000 Hz sampling, 50 Hz corner frequency

Set filter specifications Next, select Butterworth option.

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 280

dsPIC Digital Filter Design

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 281

Plant Response

Generate code:

In dsPIC Filter Design Lite select Codegen-MicrochipdsPIC30 from pull down menu Check:

Use General Subroutine C Header File X Data Space

Type in Plant as file name, the .s extension will be added automatically

Open the PID project and verify/add Plant.s to the PID project <Your Path:\>dsPIC Seminar\Follow_Along\Part 2\PID.mcw

Build the project

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 282

Plant Response

Add breakpoints:

Add 2 breakpoints in the PI demo.c file as described in the comments, one at the Nop(); statements and the other at the while loop at the end. Open the watch window, and verify the FilterOutput array is displayed Right click the array, select Export Table, select OK, and export the table with a file name. Display the watch window Right click the array, select Export Table, select OK, and export the table with a different file name.

Using the simulator, run the program to the first breakpoint


Run the program to the next breakpoint


2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 283

Plant Response

Start dsPICworks Analyzer


Select File-Import File or click the IMP icon Set Import File Format to Fractional/Integer ASCII Hexadecimal, sampling rate 8000, 1 channel For the Source File select the first exported table, and the select OK

Note the overshoot and undershoot as seen in the next slide:

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 284

dsPICworks Analyzer Open Loop Response

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 285

Plant Response

In dsPICworks Analyzer

Select File-Import or click the IMP icon Set Import File Format to Fractional/Integer ASCII Hexadecimal, sampling rate 8000, 1 channel For the Source File select the second exported table, and the select OK

Note the overshoot and undershoot has been removed as seen in the next slide: Go to Window->Graph Control->Y Direction->Zoom out to adjust the X/Y graph ratio

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 286

dsPICworks Analyzer Closed Loop Response

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 287

Plant Response

In the PI demo.c file as described in the comments, remove the comments allowing the second set of PI gains to be used. Rebuild the PID project Using the simulator, run the program to the second breakpoint

Open the watch window, and verify the FilterOutput array is displayed Right click the array, select Export Table, select OK, and export the table with a different file name.

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 288

Plant Response

In dsPICworks Analyzer

Select File-Import or click the IMP icon Set Import File Format to Fractional/Integer ASCII Hexadecimal, sampling rate 8000, 1 channel For the Source File select the third exported table, and the select OK

Note the results of the bad PI tuning:

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 289

dsPICworks Analyzer Bad PI Tuning

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 290

Plant Response

Note effectiveness of being able to choose the tuning values and perform software simulation to witness the effects of the PI variables Return to foil 153

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 291

Thank You!

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 292

Trademarks & Disclaimers

The Microchip name and logo, the Microchip logo, Accuron, dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, PowerSmart, rfPIC, and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. AmpLab, FilterLab, MXDEV, MXLAB, PICMASTER, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB, rfPICDEM, Select Mode, Smart Serial, SmartTel and Total Endurance are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. 2004, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. All rights reserved. Copyright 2004 Microchip Technology Incorporated. Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by updates. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchips products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights.

2005 Microchip Technology Incorporated dsPIC DSC Introductory Seminar Slide 293

You might also like