Você está na página 1de 75

2012 Microchip Technology Incorporated. All Rights Reserved.

1675 AMP Slide 1


1675 AMP
Creating Class D Amplifiers
with PIC

MCUs
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 2
Agenda
Understanding Audio Amplifier
Specs
Class A/B/AB/D overview
OpAmp Based Design
PIC16 Subwoofer Amp Design
dsPIC33 Subwoofer Amp Design
Summary
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 3
Reading Audio Specs
Basic Measurements
Power
Frequency Response
THD+N
Phase
SNR

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 4
Power
Specifying Power you must
define
Average continuous power
Load (8ohm, 4ohm)
Maximum THD+N
Frequency Range
Example: 100W average continuous
power into 8 at less than
1%THD+N, from 20 to 20KHz
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 5
Frequency Response
Defined as the amplitude of
device output over a frequency
range for a constant amplitude
input. Can be a graph or
statement
Example:
+0,-0.4dB, 20Hz to 20KHz at 3dB
below rated power

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 6
THD + N
Specifying total harmonic
distortion plus noise you must
define
Output level
Test frequency
Bandwidth
% THD +N
Example 1%THD+N, 1KHz at
rated power, 10KHz BW


2 2
4
2
3
2
2
2
1
2 2
4
2
3
2
2
..
.. * 100
N
N
H H H H H
H H H H
THD
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 7
THD + N
The human ears sensitivity to sound
varies with frequency, level and
duration
Fletcher-Munson Loudness Curve
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 8
Equal Loudness Actual Test
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 9
THD + N
Harmonic distortion is a non linear
distortion. Essentially we put 1 freq on
input and get multiple freq on output
Even and odd harmonics
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 10
Phase
Phase measurements are used to
describe the time offset in a cycle
of periodic waveform. It is usually
defined over a few frequencies
Not an issue on single channel
single speaker but does become
important on multichannel multi
speaker / multi driver systems


2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 11
Signal To Noise Ratio
SNR is the ratio of nominal
output level to noise usually
stated in dB
If done at max output it is
called dynamic range
Important to know reference
level of signal

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 12
What About the Loudspeaker?
The capability of speaker will have huge
effect on sound. Watch which harmonics
are generated
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 13
Class A, B and AB Amplifiers
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 14
Linear Amplifiers
There are essentially 3 types of linear audio
amps: Class A, Class B and Class AB.
The focus on each design was to
minimize crossover distortion.
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 15
Efficiencies
Linear amplifiers while being
incredibly linear and can be very
low in distortion have efficiency
draw backs
Theoretical max efficiency on
Class AB is 78% practically seems
to be in 50% region
50 watt amp throws out approx 25
watts of heat!!!

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 16
MCP6HXX OpAmp
Input Offset Voltage: 0.7 mV (typical)
Quiescent Current: 135 A (typical)
Common Mode Rejection Ratio: 100 dB
(typical)
Power Supply Rejection Ratio: 102 dB
(typical)
Rail-to-Rail Output
Supply Voltage Range:
- Single-Supply Operation: 3.5V to 16V
- Dual-Supply Operation: 1.75V to 8V
Gain Bandwidth Product: 1.2 MHz
(typical)
Slew Rate: 0.8V/s (typical)
Unity Gain Stable
Extended Temperature Range: -40C to
+125C
No Phase Reversal
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 17
Class AB OpAmp Design
Very simple circuit. Using a OpAmp
for feedback and 2 BJTs for power
amplification
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 18
Class AB Demo
Demo Amplifier with simple
audio (music)
Measurements
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 19
Audio Measurement Tools
Diagnostic System for Sound Fields
(DSSF) Software
Frequency Response
THD
Real Time Analyzer
Impulse Response
Signal Generator
Oscilloscope
www.ymec.com
M-Audio External Sound Card

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 20
Test Setup
Amplifier PC
External
Sound
Interface
OUT
IN
IN
OUT
OUT
LOAD
ATTENUATION
Oscilloscope
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 21
Test Setup Loopback
Frequency Response
THD vs. Frequency
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 22
Test Setup
Dummy
Load
Signal
Generator
PC
Sound
Card
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 23
Linear Amp Freq Response
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 24
Linear Amp THD vs Freq
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 25
Lessons Learned
Very simple to design and make
Large bulk caps are required
470uF to 1000uF on each of the +/-
power rails
Input amplifier must be clean of
noise, other wise it will be
amplified
50/60Hz hum can be present, if so
larger bulk caps or linear
regulators
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 26
Linear Amplifiers
Any Questions
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 27
Class D Amplifiers
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 28
Class D Basics
Why go to a class D amplifier
Efficiency
As mentioned earlier a class AB is
approx 50% efficient
Theoretically a class D can be 100%
efficient
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 29
Class D Basics
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 30
Class D Topologies
Bridge Drive
Full Bridge Drive
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 31
Class D, Single and Split
Supply
Split supply
bridge dont need large caps, for low
frequency response
Full bridge no advantage
Single supply
bridge need large caps to create
virtual rail, power on pop when
charging caps
Full bridge only need one rail

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 32
Class D, Output Filter
R2
494m
C1
150u
R1
8
AC 8 0
V1
330u
L1
R3
100m
=OUT/IN
OUT IN
F = 1/(2*PI()*SQRT(L*C))
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 33
Overview of New PIC16
Devices
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 34
PIC16F15XX Family
Internal Voltage Ref
2 Comparators
10bit ADC, Cap Sense Module
4 10-bit PWM Channels
Numerically Controlled Oscillator
(NCO)
Complementary Waveform
Generator (CWG)
Configurable Logic Cell (CLC)

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 35
PIC16F178X Family
Internal Voltage Ref
3 Comparators
2-3 OpAmps
12-bit ADC
8-bit DAC
16-bit PSMC PWM
16nsec edge resolution

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 36
PIC16F182X Family
Internal Voltage Ref
2 Comparators
10-bit ADC, Cap Sense Module
Multiple PWM Channels including
ECCP
Data Signal Modulator
5-bit DAC

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 37
Lets Make A
Subwoofer Amp
with a PIC16
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 38
SubWoofer Design
Design goal
Low THD
10-20Watt output
Freq Response 20-200Hz.
Use PIC16 with 10-bit ADC, 10-bit
PWM
Allow for open and closed loop
operation

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 39
Class D PIC16 Block
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 40
Level Shift Circuitry
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 41
Class D, Open Loop
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 42
ISR ADC/PWM Code
// *************************************************************************//
// this routine is the interrupt service routine Timer 2 //
// *************************************************************************//
void interrupt Timer2ISR(void){

// check if its a timer 2 flag
if(TMR2IF == 1)
TMR2IF = 0;
CaptureADC();
UpdatePWM(input);
// turn interrupt on again
GIE = 1;

}
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 43
Bus Pumping
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 44
Class D, Closed Loop
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 45
PID Code
// ********************************************
// calculate the PI control loop
// ********************************************
void CalcPI(void)
{
Error = Input - Feedback;
//*********************************************
// calculate integral with bounded limits
// *********************************************
if(SatFlag !=1){
Integral = Integral + Error;
if(Integral > 1023)
Integral = 1023;
else if (Integral < -1023)
Integral = -1023;
}
//*********************************************
// calculate integral with bounded limits
// *********************************************
Differential = Error - PreviousError;
if(Differential > 1023)
Differential = 1023;
else if (Differential < -1023)
Differential = -1023;
PreviousError = Error;
// *********************************************
// calculate output and scale it
// *********************************************
Output = KP*Error + KI*Integral + KD*Differential;
Output = Output>>10;
// *********************************************
// write output with bounded limits
// *********************************************
if(Output > OUTMAX){
Output = OUTMAX;
SatFlag = 1;
}
else if (Output < OUTMIN){
Output = OUTMIN;
SatFlag = 1;
}
else{
Output = Output;
SatFlag = 0;
}
}
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 46
Amplifier Output
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 47
Lessons Learned
Just like class B it was easy via layout and
components to amplify noise
Separate rail for preamp, PIC ADC
Just like class B it was easy via layout and
components to amplify noise
Ensure 470-1000uF per rail
Synchronize ADC with PWM
Half bridge needs FB and big caps to ensure no
bus pumping
Closed loop troublesome
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 48
Bass Shaker App.
What is a Bass Shaker.
Adding a new level to gaming
industry or home theaters



2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 49
Using dsPIC33 Devices for a
Class D SubWoofer Amp
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 50
Design Goals
>30W output @ 8 ohms
20-500Hz Frequency Response
Closed loop design
< 1% THD in B/W of interest
Achieve transparent bass audio
quality with peripherals available
to us on the dsPIC33 devices
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 51
dsPIC33 Device Families
dsPIC33FJXXMCXXX Family
500KSPS 12-bit or 1.1MSPS 10-bit
ADC
Motor Control PWM (MCPWM)
dsPIC33FJXXGSXXX Family
2 or 4MSPS 10-bit ADC
SMPS PWM

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 52
dsPIC

DSC Device Families


dsPIC33EPXXMCXXX Family
70 MIPS performance
500KSPS 12-bit or 1.1MSPS 10-bit
ADC
Motor Control PWM (MCPWM)
Codec Interface (DCI) peripheral


2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 53
dsPIC33 Family High Speed
SMPS PWM
1.04 nsec Duty Cycle and Dead
Time resolution
Up to 9 PWM generators
Independent time base and duty
cycle for each generator
Fault and Current-limit inputs
Leading Edge Blanking
Many operating modes for power
supply applications

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 54
dsPIC33 Family SMPS ADC
10-bit Resolution, 2MSPS
4 MSPS devices with two SARs
Up to 6 dedicated S/H circuits
Dedicated conversion trigger for
each analog input pair
Optimized for fast feedback in
power supply applications

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 55
Full Bridge Class D Block
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 56
Full Bridge Class D
Schematic
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 57
Full Bridge Class D
Schematic
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 58
dsPIC33FJ16GS504 Setup
Operate GS504 from Pri PLL and
FRC oscillator at 48 MIPS
Aux PLL used for HS PWM
> 14 bits resolution @48 KHz
(19660 counts)
16x oversample by ADC
TMR2 trigger for AN0/1 and AN2/3
Signal input (AN2)
Differential bridge output (AN0, AN1)
3.072 MSPS throughput

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 59
GS504 Class D Flowchart
Set up Micro
PWM / ADC
Main Loop
Calculate LPF
Set PWM Duty
Calculate PID
Update Feedback
And Signal Input
Accumulate ADC
Results
16x?
PWM Period?
Y
N
Y
ADC Interrupt (768 KHz)
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 60
GS504 ADC ISR
void _ISRFAST _ADCP1Interrupt(void){

SampleCount++;
if(SampleCount > 15){

// Get input signal accumulated result
SignalInput = SampleAccum2 - 8192;
SampleAccum2 = (int)ADCBUF2;

// Get accumulated output feedback results
OutputFeedback = SampleAccum1;
SampleAccum1 = ((int)ADCBUF0 - (int)ADCBUF1);
SampleCount = 0;
}

else{
// Accumulate signal input and differential feedback
SampleAccum1 += ((int)ADCBUF0 - (int)ADCBUF1);
SampleAccum2 += (int)ADCBUF2;
}

// Clear ADC interrupt flag
_ADCP1IF = 0;

}

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 61
GS504 Main Loop
void _ISR _PWMSpEventMatchInterrupt(void){
Flags.PWM = 1;
_PSEMIF = 0;
}
while(1){

if(Flags.PWM == 1){

SignalInput <<= 2;
IIRCanonic( 1, &FilterOut, &SignalInput, &LowpassFilter);
ControlLoop.Setpoint = FilterOut;
ControlLoop.Feedback = OutputFeedback;
CalcPI(&ControlLoop);
PDC1 = PWM_HALF_DUTY + (int)ControlLoop.Output;

Flags.PWM = 0;

}
}
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 62
Class D Demo
Demo Amplifier with simple
audio (music)
Measurements
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 63
Dead Band Effects
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 64
Amplifier Output
Full
Scale
Output
Clamping
-36dB FS
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 65
Frequency Response
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 66
THD
0dB FS
-12dB FS
Measurements taken at 100Hz, 8 ohm load
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 67
THD vs Frequency
-6dB, 8ohm load
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 68
Lessons Learned
Single supply and differential
feedback helped closed loop
operation
High-speed PWM and 16x
oversampling minimized
quantization errors at low signal
levels
Need separate supply rails for
gate drivers
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 69
What Else Can We Do


Pressure Sensor
Using a pressure to determine the position of the
drivers cone and using that as feedback.
Code will capture instantaneous pressure for a
known cabinet and driver and use an algorithm
to get position. The position value is then used
as the negative feedback for the control loop.

Pressure sensors seem to have a 1msec
response rate. So its possible to use them for
subwoofer designs.

Probably requires some calibration and
characterization of cabinet and driver system.
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 70
What Else Can We Do


Accelerometer
Using an accelerometer to determine the position of the drivers cone and using
that as feedback.
Done digitally using code to do integration.
Some accelerometers have about a 1KHz bandwidth, which again could be used
for feedback.
High Gain Servo Technology Patent
Velodyne patents the world's first High Gain Servo-Controlled subwoofer lowering
distortion to below 1%. The patent contains specifications for a sealed accelerometer.
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 71
Setup for Accel Test
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 72
Additional Info
2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 73
Audio Precision
2700 Series Instrument

2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 74
Additional Resources
Weblinks
www.bksv.com Bruel and Kjaer
www.ap.com Audio Precision
www.ymec.com DSSF3 Software
www.diyaudio.com


2012 Microchip Technology Incorporated. All Rights Reserved. 1675 AMP Slide 75
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC, KeeLoq, KeeLoq logo, MPLAB,
PIC, PICmicro, PICSTART, PIC
32
logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL
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, chipKIT, chipKIT logo, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense,
HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified
logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM,
PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC,
UniWinDriver, WiperLock and ZENA 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.

2012, Microchip Technology Incorporated, All Rights Reserved.

Você também pode gostar