Switch Mode Battery Eliminator Based on a PIC16C72A - Microchip
Switch Mode Battery Eliminator Based on a PIC16C72A - Microchip
Switch Mode Battery Eliminator Based on a PIC16C72A - Microchip
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Author: Brett Duane<br />
<strong>Microchip</strong> Technology<br />
OVERVIEW<br />
The <strong>PIC16C72A</strong> is a member of the PICmicro ® Mid-<br />
Range Family of 8-bit, high-speed microc<strong>on</strong>trollers.<br />
The PIC16C72 provides the following features:<br />
• 5 Channel, 8-bit Analog-to-Digital C<strong>on</strong>verter (A/D)<br />
• CCP Module to generate a PWM output<br />
• I 2 C/SPI Module<br />
• 3 Timers<br />
• 8 Interrupt sources<br />
This applicati<strong>on</strong> note shows how to combine the A/D<br />
and CCP modules with suitable software to produce a<br />
<str<strong>on</strong>g>Switch</str<strong>on</strong>g> <str<strong>on</strong>g>Mode</str<strong>on</strong>g> <str<strong>on</strong>g>Battery</str<strong>on</strong>g> <str<strong>on</strong>g>Eliminator</str<strong>on</strong>g> (SMBE) providing 3.0,<br />
4.5, 5.0, 6.0, 7.5 and 9.0 volt output voltages at up to 1<br />
Amp with an AC or DC input between 12.6V and 30V<br />
peak.<br />
HARDWARE<br />
The system makes use of the A/D to read the input and<br />
output voltages, the Capture/Compare/Pulse module to<br />
generate a PWM output, and Timer2 to regulate how<br />
fast the program runs. External hardware includes a<br />
switching power c<strong>on</strong>verter and a suitable output filter.<br />
Six LEDs <strong>on</strong> PORTB indicate the output voltage as set<br />
by two push butt<strong>on</strong>s <strong>on</strong> PORTA.<br />
Opti<strong>on</strong>al comp<strong>on</strong>ents not installed in this project<br />
include a serial EEPROM to store the last voltage setting<br />
and a level translator to c<strong>on</strong>vert TTL to RS-232 for<br />
communicati<strong>on</strong>s with a PC.<br />
In-Circuit Serial Programming (ICSP) support has<br />
also been provided. LEDs D7 and D8 share clock and<br />
data lines required for ICSP. These LEDs indicate error<br />
c<strong>on</strong>diti<strong>on</strong>s and are opti<strong>on</strong>al.<br />
AN701<br />
<str<strong>on</strong>g>Switch</str<strong>on</strong>g> <str<strong>on</strong>g>Mode</str<strong>on</strong>g> <str<strong>on</strong>g>Battery</str<strong>on</strong>g> <str<strong>on</strong>g>Eliminator</str<strong>on</strong>g> <str<strong>on</strong>g>Based</str<strong>on</strong>g> <strong>on</strong> a <strong>PIC16C72A</strong><br />
Analog-to-Digital C<strong>on</strong>verter Module<br />
The A/D c<strong>on</strong>verts an input voltage between ground and<br />
VDD to an 8-bit value presented in ADRES. In this applicati<strong>on</strong>,<br />
the switching c<strong>on</strong>verter input and output voltages<br />
are sampled. Provisi<strong>on</strong>s have been included to<br />
read the setting of a potentiometer.<br />
Capture/Compare/Pulse Width Modulati<strong>on</strong><br />
Module<br />
The CCP module produces the PWM signal that c<strong>on</strong>trols<br />
the series pass switching transistor. Depending<br />
<strong>on</strong> the PWM period and FOSC, any number of bits<br />
between 2 and 10 bits may be used to specify the PWM<br />
<strong>on</strong>-time. The CCP module requires the use of Timer2,<br />
the Timer2 prescaler, and the PR2 register to produce<br />
a PWM output.<br />
Timer2 Postscaler<br />
Timer2 drives the CCP module to c<strong>on</strong>trol the PWM<br />
period and also drives the Timer2 postscaler. The<br />
postscaler is incremented when Timer2 is reset at the<br />
end of each PWM cycle and will generate an interrupt<br />
when the postscaler overflows.<br />
External Hardware<br />
The switching buck c<strong>on</strong>verter relies <strong>on</strong> three comp<strong>on</strong>ents<br />
to functi<strong>on</strong>:<br />
• Series pass switch (Q1)<br />
• Inductor (L1)<br />
• Commutating diode (D10).<br />
These devices form the core of all switch mode buck<br />
c<strong>on</strong>verters.<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 1
AN701<br />
Power Input Circuit<br />
This circuit is a c<strong>on</strong>venti<strong>on</strong>al linear power supply that<br />
accepts AC or DC power with a peak voltage of 30V<br />
(limited by the 78L05). The c<strong>on</strong>verter operates off the<br />
unregulated bulk power, while the regulator supplies<br />
power and a voltage reference to the c<strong>on</strong>troller.<br />
FIGURE 1: POWER INPUT CIRCUIT<br />
J1<br />
C5<br />
.01uF<br />
BR1<br />
VUNREG<br />
C6<br />
1000uF<br />
35V<br />
Figure 1 shows the Power Input Circuit. Bridge rectifier<br />
BR1 rectifies the raw power input that may be AC or<br />
DC. Capacitor C6 provides rough filtering to reduce ripple<br />
in the input voltage. Capacitor C8 provides the short<br />
current pulses drawn by transistor Q1 when it is turned<br />
<strong>on</strong>. Capacitor C7 provides filtering of regulator U2 output.<br />
C8<br />
1uF<br />
35V<br />
TANT<br />
DS00701A-page 2 © 1999 <strong>Microchip</strong> Technology Inc.<br />
IN<br />
U2<br />
LM7805<br />
OUT<br />
GND<br />
+5V<br />
C7<br />
10uF<br />
16V
Power C<strong>on</strong>verter<br />
Figure 2 shows the switching buck c<strong>on</strong>verter with drive<br />
circuits. Unregulated DC is provided at the emitter of<br />
transistor Q1. Q1, inductor L1 and diode D10 form the<br />
basic buck switching c<strong>on</strong>verter. The output appears at<br />
c<strong>on</strong>nector J4.<br />
When RC2 (PWM output) is high, transistor Q2 is<br />
turned <strong>on</strong>, pulling Q2’s collector to ground. This draws<br />
current from Q1’s base, turning Q1 <strong>on</strong>. When Q1 is <strong>on</strong>,<br />
current from capacitors C6 and C8 charge L1 through<br />
the load. Resistor R19 limits the current drawn from the<br />
base of Q1. Resistor R17 ensures that Q1 switches off<br />
quickly. Resistor R20 ensures that transistor Q2<br />
switches off quickly. Resistor R18 limits Q2’s base current.<br />
When RC2 is low, R20 turns off Q2 and R17 turns off<br />
Q1. When Q1 is off, the current through L1 c<strong>on</strong>tinues to<br />
flow through L1, D10 and the load, discharging L1.<br />
When the current through L1 becomes less than the<br />
current drawn by the load, C10 provides the additi<strong>on</strong>al<br />
current and reduces output voltage ripple.<br />
AN701<br />
To ensure that Q1 remains cool during operati<strong>on</strong>, it<br />
must be driven well into saturati<strong>on</strong>. When driving transistors<br />
as digital switches, divide their hFE (small signal<br />
gain) by 5 and use the resulting gain for your calculati<strong>on</strong>s.<br />
This ensures that the transistor switches through<br />
its linear regi<strong>on</strong> quickly to prevent significant heat generati<strong>on</strong><br />
in the transistor.<br />
As the unregulated input voltage decreases, the drive<br />
applied to Q1 decreases to the point where Q1 starts<br />
operating in its linear regi<strong>on</strong>, producing heat. C<strong>on</strong>tinued<br />
operati<strong>on</strong> in the linear regi<strong>on</strong> will cause Q1 to<br />
overheat and fail. Q1 usually shorts, causing the input<br />
voltage to appear at the c<strong>on</strong>verter output. R19 was<br />
selected to allow Q1 to operate safely as l<strong>on</strong>g as VUN-<br />
REG is above 10V. The c<strong>on</strong>troller software will shut<br />
down the c<strong>on</strong>verter if VUNREG falls below 10V.<br />
The c<strong>on</strong>verter output c<strong>on</strong>tains a c<strong>on</strong>siderable amount<br />
of noise. Capacitors C10 and C11 provide filtering to<br />
reduce that noise. F1 is a PTC resistor acting as a 1<br />
Amp, self-resetting fuse.<br />
FIGURE 2: SWITCHING BUCK CONVERTER WITH DRIVE AND OUTPUT CIRCUITS<br />
PWM<br />
R18<br />
1K<br />
R17<br />
47<br />
R20<br />
220<br />
Q1<br />
ZTX751<br />
R19<br />
270<br />
1W<br />
Q2<br />
2N2222A<br />
L1<br />
100uH<br />
D10<br />
1N5822<br />
C11<br />
10uF<br />
35V<br />
C10<br />
470uF<br />
16V<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 3<br />
F1
AN701<br />
Microc<strong>on</strong>troller Circuits<br />
The microc<strong>on</strong>troller, analog inputs and digital outputs<br />
are shown in Figure 3.<br />
The LEDs indicate the output voltage (D1-6) and c<strong>on</strong>verter<br />
faults (D7-8). <str<strong>on</strong>g>Switch</str<strong>on</strong>g>es S1 and S2 allow the user<br />
to select the desired output voltage. Resistors R3, R4<br />
and capacitor C4 form the voltage feedback circuit.<br />
Resistors R15, R16 and capacitor C13 form the voltage<br />
source sense circuit. PWM is output at pin RC2.<br />
Register packs RN5 and RN6 limit current through<br />
LEDs D1-D8. LEDs D7 and D8 share clock and data<br />
lines required for ICSP. Jumper J1 disables all LEDs.<br />
When programming the c<strong>on</strong>troller using ICSP, J1<br />
should be removed. If ICSP does not functi<strong>on</strong> properly,<br />
D7 and D8 or RN6 should be installed after programming.<br />
S1 is the decrease voltage butt<strong>on</strong> and S2 is the<br />
increase voltage butt<strong>on</strong>. R13 and R14 are pull down<br />
resistors.<br />
Res<strong>on</strong>ator Y1, and capacitors C2 and C3 set Fosc for<br />
the c<strong>on</strong>troller. If Y1 is a ceramic res<strong>on</strong>ator with internal<br />
capacitors, C2 and C3 are not required. Resistor R1<br />
pulls MCLR to +5V while allowing the c<strong>on</strong>troller to be<br />
programmed using ICSP. In additi<strong>on</strong>, c<strong>on</strong>necting pins 1<br />
and 3 of c<strong>on</strong>nector J2 causes a remote reset of the c<strong>on</strong>troller.<br />
(See figure 5.)<br />
FIGURE 3: MICROCONTROLLER, ANALOG INPUTS AND DIGITAL INPUTS AND OUTPUTS<br />
R2<br />
5K<br />
VOUT<br />
R3<br />
1K<br />
R4<br />
1K<br />
+5V<br />
VUNREG<br />
R16<br />
5.6K<br />
C4<br />
.01uF<br />
R15<br />
1K<br />
R1<br />
10K<br />
+5V<br />
C12<br />
.01uF<br />
Y1, 10MHz<br />
Res<strong>on</strong>ator<br />
C2<br />
20pF<br />
C1<br />
.1uF<br />
C13<br />
.01uF<br />
C3<br />
20pF<br />
MCLR<br />
RA2<br />
RA5<br />
<strong>PIC16C72A</strong><br />
UP DN<br />
DS00701A-page 4 © 1999 <strong>Microchip</strong> Technology Inc.<br />
RB6<br />
RB7<br />
PWM<br />
SCL<br />
SDA<br />
RC5<br />
RC6<br />
RC7<br />
RN5<br />
470<br />
RN6<br />
+5V<br />
470<br />
RA5<br />
RA2<br />
R13<br />
5.6K<br />
R14<br />
5.6K<br />
JP1
FIRMWARE<br />
Initializati<strong>on</strong><br />
The c<strong>on</strong>troller is first initialized by c<strong>on</strong>figuring the A/D,<br />
CCP and Timer2 peripherals, followed by clearing the<br />
RAM required for variables and initializing some variables.<br />
C<strong>on</strong>troller pins are c<strong>on</strong>figured as required for<br />
each of the modules, or as digital outputs if they are not<br />
being used.<br />
A/D<br />
Pins RA0, RA1 and RA3 are c<strong>on</strong>figured as analog<br />
inputs. Pins RA2 and RA5 are used as digital inputs.<br />
The c<strong>on</strong>troller VDD is used as VREF for the A/D.<br />
The c<strong>on</strong>versi<strong>on</strong> clock source TAD is selected to be<br />
between 1.6usec and 6.4usec. Since Tosc = 0.1usec<br />
(Fosc = 10MHz), 32Tosc = 3.2usec. The A/D module is<br />
turned <strong>on</strong> and pin RA1 (VOUT) is sampled for c<strong>on</strong>versi<strong>on</strong><br />
later in the loop.<br />
TRISA c<strong>on</strong>figures pin RA4 as an output and all others<br />
as inputs.<br />
CCP (PWM)<br />
The CCP module is set to PWM mode. Timer2 is<br />
enabled with a 1:1 prescaler. PR2 is set to 63 (0x3F).<br />
The resulting PWM frequency is 39.063KHz.<br />
(TPWM=25.6msec). The CCP module uses 8-bit data<br />
to c<strong>on</strong>trol the PWM duty cycle. The PWM duty cycle is<br />
set to 0, ensuring that the PWM output is turned off.<br />
All pins <strong>on</strong> PORTC are c<strong>on</strong>figured as outputs, including<br />
RC2 which is the c<strong>on</strong>troller PWM output.<br />
Timer2 postscaler<br />
Since Timer2 will also c<strong>on</strong>trol the frequency that the<br />
main loop will execute, the Timer2 postscaler is set to a<br />
1:1 ratio and the Timer2 postscaler interrupt is enabled.<br />
This will cause <strong>on</strong>e interrupt for each PWM cycle.<br />
RAM<br />
RAM required for variables is cleared. The 3.0V LED<br />
<strong>on</strong> PORTB is lit. The variable set_pt is initialized to<br />
produce the 3.0V output. Butt<strong>on</strong> debounce counters<br />
are initialized.<br />
Main loop<br />
For a digital c<strong>on</strong>trol loop to functi<strong>on</strong> as well as an analog<br />
c<strong>on</strong>troller, the digital c<strong>on</strong>trol loop should repeat at<br />
least 30 times faster than the fastest expected transient.<br />
The ripple frequency at capacitor C7 is 120Hz, or twice<br />
the AC power line frequency. In this applicati<strong>on</strong>, the<br />
loop must be executed at least 120 x 30, or 3600 times<br />
a sec<strong>on</strong>d to adequately resp<strong>on</strong>d to the bulk power ripple.<br />
Transients at the c<strong>on</strong>verter output are also handled,<br />
but less effectively with increasing frequency.<br />
AN701<br />
The Timer2 postscaler generates interrupts that are<br />
counted by the interrupt service routine. When 8 interrupts<br />
have occurred, the main loop is allowed to execute<br />
<strong>on</strong>ce. This causes the main loop to execute 4883<br />
times a sec<strong>on</strong>d.<br />
The A/D starts a c<strong>on</strong>versi<strong>on</strong> <strong>on</strong> RA1/AN1 (VOUT). The<br />
program loops wait for the c<strong>on</strong>versi<strong>on</strong> to complete. The<br />
8-bit result is placed in VOUT. The A/D is then set to<br />
sample the input voltage (VUNREG).<br />
PID C<strong>on</strong>troller<br />
The c<strong>on</strong>trol algorithm is a software implementati<strong>on</strong> of a<br />
Proporti<strong>on</strong>al-Integral-Differential (PID) c<strong>on</strong>troller. The<br />
<strong>on</strong>ly input to this c<strong>on</strong>troller is the difference between the<br />
desired output voltage and the actual output voltage,<br />
and is known as the error signal.<br />
The first module produces the error signal by finding<br />
the difference between set_pt and VOUT. The result<br />
is saved in the low byte of a 2 byte signed variable<br />
e0h:e0. The high byte is set to reflect a negative value<br />
if needed. The difference is selected to produce a positive<br />
result if set_pt is greater than VOUT.<br />
e0 = set_pt - vout<br />
if e0=0 , e0h = 0x00, else e0h = 0xFF<br />
A proporti<strong>on</strong>al term is generated from the present error<br />
signal. This is simply the signed error multiplied by<br />
some factor Kp. The 2 byte signed result is saved as<br />
proh:pro.<br />
proh:pro = Kp * e0h:e0<br />
Kp = proporti<strong>on</strong>al factor<br />
The difference between the present and previous error<br />
is found and saved as the 2 byte signed result<br />
difh:dif. The previous error e1h:e1 is simply the<br />
error result found in the executi<strong>on</strong> of the previous loop.<br />
The difference between errors is multiplied by some<br />
factor (Kd) and saved as difh:dif.<br />
difh:dif = Kd * (e1h:e1 – e0h:e0)<br />
Kd=difference factor<br />
The integral comp<strong>on</strong>ent is nothing more than a total of<br />
all the errors produced since the last reset. The present<br />
error is multiplied by some factor (Ki) before being<br />
added to the running 2 byte unsigned total inth:int.<br />
inth:int = inth:int + Ki * e0h:e0<br />
Ki = integral factor<br />
The proporti<strong>on</strong>al, integral and difference terms are<br />
summed together. The result of the sum is saved as the<br />
2 byte signed result pwmh:pwm.<br />
pwmh:pwm = proh:pro + difh:dif<br />
+ inth:int<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 5
AN701<br />
The result is never greatly positive, but can sometimes<br />
cause the result to underflow. When pwmh:pwm underflows<br />
(as it does when the load is disc<strong>on</strong>nected), the<br />
PWM drive signal must be forced to zero or the c<strong>on</strong>verter<br />
output becomes unpredictable. The overload<br />
LED is also lit.<br />
If pwmh = 1, then pwmh:pwm = 0x0000 and turn<br />
<strong>on</strong> the OVLD LED, else turn off OVLD LED.<br />
PWM Generator<br />
The PWM generator module (software, not the peripheral)<br />
discards the 3 least and 5 most significant bits,<br />
and uses the remaining 8 bits to generate PWM with a<br />
desired <strong>on</strong> time. Of the remaining 8 bits, the 2 least significant<br />
bits are loaded into CCP1CON. The last<br />
6 bits (with 2 leading zeros to form a byte) are loaded<br />
into CCP1RL.<br />
C<strong>on</strong>versi<strong>on</strong> of the input voltage VUNREG is started.<br />
Reading Butt<strong>on</strong>s<br />
The LED data at PORTB is copied to a temporary variable.<br />
The down butt<strong>on</strong> is read. If it is closed, its debounce<br />
counter is incremented. If no overflow occurs, executi<strong>on</strong><br />
proceeds to reading the up butt<strong>on</strong>. If an overflow<br />
does occur, the LED data is shifted right <strong>on</strong>e bit, unless<br />
bit 0 is already set. Overflows occur approximately<br />
every half sec<strong>on</strong>d.<br />
The up butt<strong>on</strong> is read and processed similar to the<br />
down butt<strong>on</strong>. If it is closed, its debounce counter is<br />
incremented. If no overflow occurs, executi<strong>on</strong> proceeds<br />
to c<strong>on</strong>vert VIN. If an overflow does occur, the<br />
LED data is shifted left <strong>on</strong>e bit, unless bit 5 is already<br />
set. Overflows occur approximately every half sec<strong>on</strong>d.<br />
The LED data is copied back to PORTB to light the corresp<strong>on</strong>ding<br />
LED. The LED data is also used to find the<br />
proper index to use prior to calling a look-up table.<br />
A call to the lookup table is performed. The lookup<br />
table routine adds the index in the W register to the program<br />
counter. The next instructi<strong>on</strong> performed is a<br />
"retlw" instructi<strong>on</strong> that places the new set_pt in the<br />
W register and returns to the next instructi<strong>on</strong> after the<br />
call to the look-up table. The value returned is saved<br />
as the new set_pt.<br />
Both butt<strong>on</strong> debounce counters are reset.<br />
The c<strong>on</strong>versi<strong>on</strong> result of VIN is retrieved from the A/D<br />
and vin is subtracted from 0xC1 (10V set point). If the<br />
result is positive, VIN is less than 10V and program executi<strong>on</strong><br />
is directed to a safety shutdown module. Otherwise,<br />
program executi<strong>on</strong> c<strong>on</strong>tinues normally.<br />
If (0xC1 – vin) is positive, go to shutdown.<br />
The present error, e0h:e0, replaces the previous<br />
error, e1h:e1.<br />
Program executi<strong>on</strong> then returns to the top of the loop to<br />
wait for Timer2 postscaler interrupts.<br />
Interrupts<br />
The Interrupt Service Routine saves the state of the W<br />
and STATUS registers, increments the interrupt counter<br />
and restores the STATUS and W registers.<br />
Safety Shutdown<br />
The safety shutdown module has been included to turn<br />
off the c<strong>on</strong>verter and to light the trip LED. Once<br />
entered, there is no exit from this module except by<br />
resetting the c<strong>on</strong>troller.<br />
Gain c<strong>on</strong>stants Kp, Kd, and Ki<br />
C<strong>on</strong>stants Kp, Ki, and Kd were determined experimentally.<br />
The goal was to maintain VOUT between 4.75V<br />
and 5.25V when the 5V output was selected. VOUT<br />
should remain within this band, regardless of changes<br />
in the load current. This specifically includes 10%<br />
changes in current, unloaded to full-load, and full-load<br />
to unloaded step changes. Other step changes in loading<br />
were also examined.<br />
C<strong>on</strong>stants determined for a 5V output were then used<br />
for other voltage outputs.<br />
Only resistive loads were c<strong>on</strong>sidered. Some degradati<strong>on</strong><br />
of output performance may be expected with inductive<br />
or capacitive loads.<br />
DS00701A-page 6 © 1999 <strong>Microchip</strong> Technology Inc.
APPENDIX A: SWITCH MODE BUCK<br />
CONVERTER<br />
A switch mode buck c<strong>on</strong>verter performs a voltage<br />
reducti<strong>on</strong> by periodically charging an inductor from a<br />
high voltage source, then allowing the charged inductor<br />
to transfer its stored energy to the load at a lower voltage.<br />
This energy transfer occurs with little loss.<br />
FIGURE 4: SWITCH MODE BUCK<br />
CONVERTER TOPOLOGY<br />
Input<br />
L<br />
Output<br />
Q<br />
D C R<br />
In the ideal buck c<strong>on</strong>verter, the average output power<br />
equals the average input power. The switch is operated<br />
at a c<strong>on</strong>stant frequency, but the duty cycle (<strong>on</strong> time /<br />
cycle time) c<strong>on</strong>trols the output voltage.<br />
When the switch Q (a transistor or MOSFET) is closed,<br />
current from the source flows through the inductor L,<br />
through the load R and back to the source. Energy is<br />
being stored in the inductor by increasing inductor current<br />
and building up a magnetic field.<br />
When the switch is open, the source no l<strong>on</strong>ger supplies<br />
energy. The energy stored in the magnetic field is<br />
transferred to the load as the magnetic field collapses.<br />
Inductor current is decreasing as current flows from the<br />
inductor through the load R and diode D and back to<br />
the inductor L.<br />
No energy is lost in the inductor during this c<strong>on</strong>versi<strong>on</strong>.<br />
The majority of losses occur in the switching device as<br />
it switches though its linear regi<strong>on</strong>, and the commutati<strong>on</strong><br />
diode when it c<strong>on</strong>ducts due to its forward voltage<br />
drop. Most electrolytic filter capacitors also have high<br />
resistance to the high frequency ripple current.<br />
If current flows through the inductor at all times, the<br />
c<strong>on</strong>verter is operating in the c<strong>on</strong>tinuous mode. The<br />
average inductor current is the same as the load current.<br />
If the load current is c<strong>on</strong>stant, variati<strong>on</strong>s in the<br />
inductor current average to zero. The peak inductor<br />
current will be no greater than twice the average current,<br />
and can be reduced by raising the switching frequency.<br />
This is normally the desired operating mode.<br />
If the current through the inductor stops, the c<strong>on</strong>verter<br />
is operating in the disc<strong>on</strong>tinuous mode. All the current<br />
that flows through the load c<strong>on</strong>tinuously must flow<br />
through the switch and charge the inductor during the<br />
time the switch is turned <strong>on</strong>. This can result in very high<br />
currents in both the switch and inductor and risks saturating<br />
the inductor. When the inductor is saturated, its<br />
inductance decreases drastically. C<strong>on</strong>siderable noise<br />
is also produced as large currents are switched, requiring<br />
a greater amount of filtering. This mode is normally<br />
AN701<br />
used <strong>on</strong>ly when there is very light loading of the c<strong>on</strong>verter,<br />
but it is easier to stabilize than the c<strong>on</strong>tinuous<br />
mode c<strong>on</strong>verter.<br />
In both c<strong>on</strong>tinuous and disc<strong>on</strong>tinuous modes, charging<br />
or discharging a filter capacitor at the c<strong>on</strong>verter output<br />
makes up the difference between the inductor and load<br />
currents. This filter capacitor also reduces output ripple<br />
voltage and noise that switching c<strong>on</strong>verters produce.<br />
The equati<strong>on</strong>s presented here assume an ideal circuit,<br />
but actual circuits have similar results.<br />
The approximate duty cycle D.C. can be approximated<br />
by:<br />
D.C. = VOUT = IIN = TON<br />
VIN IOUT TPWM<br />
Where VOUT = output voltage,<br />
IIN = average input current,<br />
TON = switch <strong>on</strong> time<br />
VIN = input voltage,<br />
IOUT = output current,<br />
TPWM = PWM period = 1/FPWM<br />
The ripple current magnitude due to switching is<br />
approximated by:<br />
IRIPPLE = (VIN-VOUT) * D.C. * TPWM<br />
L<br />
Where L = inductor inductance,<br />
IRIPPLE = ripple current peak-to-peak<br />
FPWM = PWM frequency<br />
The ripple current is absorbed by the output filter<br />
capacitor C, but produces a small output ripple voltage<br />
that is approximated by:<br />
VRIPPLE = IRIPPLE * D.C. * TPWM<br />
C<br />
Where VRIPPLE = output voltage ripple peak-to-peak<br />
EXAMPLE 1: CAPACITOR AND<br />
INDUCTOR SELECTION<br />
Given: VUNREG = 20V, VOUT = 6V,<br />
VRIPPLE = 0.1V, IRIPPLE = 1A,<br />
FPWM = 39.063KHz<br />
Soluti<strong>on</strong>:<br />
D.C. = VOUT = 6 = 0.30<br />
VIN 20<br />
TPWM = 1 = 1 = 25.6uS<br />
FPWM 39KHz<br />
C = IRIP*D.C.*TPWM = (1A)(.3)(25.6uS)<br />
VRIPPLE 0.1V<br />
= 76.8uF<br />
IRIP = (VIN-VOUT)*D.C.*TPWM<br />
L<br />
L = (VIN-VOUT)*D.C.*TPWM<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 7<br />
IRIP<br />
= (20V-6V)(0.30)(25.6uS)<br />
1A<br />
= 107.5uH
AN701<br />
APPENDIX B: ACCESSORY<br />
COMPONENTS<br />
These accessory comp<strong>on</strong>ent are not installed <strong>on</strong> the<br />
board, but can provide additi<strong>on</strong>al capabilities. C<strong>on</strong>nector<br />
J2 provides for In-Circuit Serial Programming<br />
(ICSP) and offers a remote MCLR reset by c<strong>on</strong>necting<br />
FIGURE 5: ACCESSORY COMPONENTS<br />
+5V<br />
MCLR<br />
RB7<br />
RB6<br />
J2<br />
+5V<br />
R21<br />
4.7K<br />
SCL<br />
+5V<br />
J3<br />
VCC<br />
SCL<br />
WP<br />
GND<br />
C29<br />
.1uF<br />
pins 1 and 3. Integrated circuit U3 and c<strong>on</strong>nector J3<br />
provide RS-232 communicati<strong>on</strong>s with the c<strong>on</strong>troller.<br />
Integrated circuit U4 is a serial EEPROM that communicates<br />
with the c<strong>on</strong>troller using the I 2 C protocol.<br />
DS00701A-page 8 © 1999 <strong>Microchip</strong> Technology Inc.<br />
C16<br />
.1uF<br />
U4<br />
24LC01BD<br />
R31<br />
10<br />
SDA<br />
A0<br />
A1<br />
A2<br />
+5V<br />
VCC<br />
RXin<br />
NC<br />
TXout<br />
U3<br />
DS275<br />
RXout<br />
Vdrv<br />
TXin<br />
GND<br />
+5V<br />
R22<br />
4.7K<br />
SDA<br />
RC7<br />
RC6<br />
+5V
APPENDIX C: CODE<br />
MPASM 02.20 Released SW_REG1A.ASM 3-9-1999 19:28:40<br />
LOC OBJECT CODE LINE SOURCE TEXT<br />
VALUE<br />
AN701<br />
00001<br />
;****************************************************************************<br />
00002 ;* Filename: APPNOTE.ASM<br />
00003<br />
;****************************************************************************<br />
00004 ;* Author: Brett Duane<br />
00005 ;* Company: <strong>Microchip</strong> Technology<br />
00006 ;* Revisi<strong>on</strong>: Rev 1.0<br />
00007 ;* Date: 3-9-99<br />
00008 ;* Assembled using MPASM rev 4.00.00<br />
00009<br />
;****************************************************************************<br />
00010 ;* Include files: p16c72a.inc Rev 1.01<br />
00011<br />
;****************************************************************************<br />
00012 ;*<br />
00013 ;* <str<strong>on</strong>g>Switch</str<strong>on</strong>g>ing buck regulator using 16C72A using A/D,<br />
00014 ;* PWM (CCP) and timer2 modules.<br />
00015 ;*<br />
00016 ;* PID c<strong>on</strong>trol loop implementati<strong>on</strong>.<br />
00017 ;* Executes 4883 loops per sec<strong>on</strong>d.<br />
00018 ;* Spends most of its time looping waiting for timer2 overflows.<br />
00019 ;*<br />
00020 ;* A/D inputs and PWM output are 8 bits,<br />
00021 ;* with internal calculati<strong>on</strong>s d<strong>on</strong>e in 16 bits<br />
00022 ;*<br />
00023 ;* Timer2 postscaler (1:16) generates an interrupt.<br />
00024 ;*<br />
00025 ;* RA0 c<strong>on</strong>verts a 0-5V input from trimmer, but is not used.<br />
00026 ;* RA1 m<strong>on</strong>itors VOUT.<br />
00027 ;* RA2 is the up voltage push butt<strong>on</strong> input.<br />
00028 ;* RA3 m<strong>on</strong>itors VUNREG.<br />
00029 ;* RA5 is the down voltage push butt<strong>on</strong> input.<br />
00030 ;*<br />
00031 ;* RB drives LEDs to indicate the output voltage.<br />
00032 ;* RB drives LEDs to indicate overload or shutdown.<br />
00033 ;*<br />
00034 ;* RC2 is the PWM source for the switching c<strong>on</strong>verter.<br />
00035 ;*<br />
00036 ;*<br />
00037 ;* C<strong>on</strong>figurati<strong>on</strong> Bit Settings<br />
00038 ;* Brown-out detect is off<br />
00039 ;* Code protect is off<br />
00040 ;* Power-up timer is enabled<br />
00041 ;* Watchdog timer is disabled<br />
00042 ;* 10MHz res<strong>on</strong>ator is driven in XT mode<br />
00043 ;*<br />
00044 ;* Program Memory Words Used: 230<br />
00045 ;* Program Memory Words Free: 1818<br />
00046 ;*<br />
00047 ;* Data Memory Bytes Used: 24<br />
00048 ;* Data Memory Bytes Free: 104<br />
00049 ;*<br />
00050<br />
;****************************************************************************<br />
00051 ;* What’s Changed<br />
00052 ;*<br />
00053 ;* Date Descripti<strong>on</strong> of Change<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 9
AN701<br />
00054 ;*<br />
00055 ;* 3-3-99 This is the initial release.<br />
00056 ;*<br />
00057<br />
;****************************************************************************<br />
00058<br />
00059 list p=16c72a<br />
00060 #include <br />
00001 LIST<br />
00002 ; P16C72A.INC Standard Header File,Versi<strong>on</strong> 1.01 <strong>Microchip</strong> Technology, Inc.<br />
00249 LIST<br />
00061<br />
2007 3FB1 00062 __c<strong>on</strong>fig _BODEN_OFF & _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC<br />
00063<br />
00064<br />
00065 cblock 0x020<br />
00066<br />
00000020 00067 UPCL ;up butt<strong>on</strong> debounce<br />
00000021 00068 UPCH ;up butt<strong>on</strong> debounce<br />
00000022 00069 DNCL ;down butt<strong>on</strong> debounce<br />
00000023 00070 DNCH ;down butt<strong>on</strong> debounce<br />
00000024 00071 SETPOINT ;voltage setpoint - RA0 result (unsigned)<br />
00000025 00072 VOUT ;output voltage feedback - RA1 result<br />
00000026 00073 VUNREG ;source voltage feedback - RA3 result<br />
00000027 00074 TEMPA ;temp variable<br />
00000028 00075 TEMPB ;temp variable<br />
00000029 00076 INT ;integral comp<strong>on</strong>ent<br />
0000002A 00077 INTH ;integral comp<strong>on</strong>ent<br />
0000002B 00078 PRO ;proporti<strong>on</strong>al comp<strong>on</strong>ent<br />
0000002C 00079 PROH ;proporti<strong>on</strong>al comp<strong>on</strong>ent<br />
0000002D 00080 DIF ;difference comp<strong>on</strong>ent<br />
0000002E 00081 DIFH ;difference comp<strong>on</strong>ent<br />
0000002F 00082 PWM ;PWM drive<br />
00000030 00083 PWMH ;PWM drive<br />
00000031 00084 E0 ;present error<br />
00000032 00085 E0H ;present error<br />
00000033 00086 E1 ;past error<br />
00000034 00087 E1H ;past error<br />
00000035 00088 T2POST ;postscaler interrupt counter<br />
00000036 00089 ISRS ;isr variable<br />
00000037 00090 ISRW ;isr variable<br />
00091<br />
00092 endc<br />
00093<br />
000000F9 00094 DEL1 equ 0xf9 ;text equate - debounce delay<br />
00000089 00095 AVOUT equ 0x89 ;text equate - select VOUT channel<br />
00000099 00096 AVUNREG equ 0x99 ;text equate - select VUNREG channel<br />
00097<br />
00098<br />
;****************************************************************************<br />
00099 ;* Reset vector<br />
00100 ;* This is the reset vector<br />
00101 ;*<br />
00102<br />
;****************************************************************************<br />
00103<br />
0000 00104 org 0x00 ;reset vector<br />
0000 280E 00105 goto Main ;program start<br />
00106<br />
00107<br />
00108<br />
;****************************************************************************<br />
00109 ;* INTERRUPT SERVICE ROUTINE<br />
00110 ;* This ISR counts timer2 interrupts<br />
00111 ;*<br />
00112 ;* Input Variables:<br />
DS00701A-page 10 © 1999 <strong>Microchip</strong> Technology Inc.
AN701<br />
00113 ;* T2POST Counts overflow interrupts<br />
00114 ;*<br />
00115 ;* Output Variables:<br />
00116 ;* T2POST Counts overflow interrupts<br />
00117 ;*<br />
00118<br />
;****************************************************************************<br />
00119<br />
0004 00120 org 0x04 ;interrupt service routine<br />
00121<br />
0004 00B7 00122 movwf ISRW ;save W<br />
0005 0E03 00123 swapf STATUS,W ;get status<br />
0006 00B6 00124 movwf ISRS ;save status<br />
00125<br />
0007 108C 00126 bcf PIR1,TMR2IF;clear interrupt request flag<br />
00127<br />
0008 0AB5 00128 incf T2POST,F ;increment interrupt counter<br />
00129<br />
0009 0E36 00130 swapf ISRS,W ;get status<br />
000A 0083 00131 movwf STATUS ;restore status<br />
000B 0EB7 00132 swapf ISRW,F ;restore W<br />
000C 0E37 00133 swapf ISRW,W ;restore W<br />
00134<br />
000D 0009 00135 retfie ;return from interrupt<br />
00136<br />
00137<br />
;****************************************************************************<br />
00138 ;* Main Beginning of main loop<br />
00139 ;* First segment of code initializes c<strong>on</strong>troller<br />
00140<br />
;****************************************************************************<br />
00141<br />
000E 00142 Main<br />
000E 1303 00143 bcf STATUS,RP1;bank1 initializati<strong>on</strong><br />
000F 1683 00144 bsf STATUS,RP0;bank1<br />
00145 ;adc<br />
0010 3004 00146 movlw 0x04 ;RA0,1,3 analog, RA2,5 digital, Vref=Vdd<br />
0011 009F 00147 movwf ADCON1<br />
00148<br />
0012 302F 00149 movlw 0x2f ;RA0,1,3 analog in; RA2,5 digital in, RA4 dig out<br />
0013 0085 00150 movwf TRISA<br />
00151 ;PWM<br />
0014 30FF 00152 movlw 0xFF ;set portC to all inputs<br />
0015 0087 00153 movwf TRISC<br />
0016 1107 00154 bcf TRISC,2 ;make RC2/PWM output<br />
00155<br />
0017 303F 00156 movlw .63 ;PWM period = 78.125KHz (8 bit resoluti<strong>on</strong>)<br />
0018 0092 00157 movwf PR2<br />
00158<br />
00159 ;timer2<br />
0019 148C 00160 bsf PIE1,TMR2IE;enable timer2 postscaler interrupts<br />
00161<br />
00162 ;display<br />
001A 0186 00163 clrf TRISB ;make PORTB all outputs<br />
00164<br />
001B 1283 00165 bcf STATUS,RP0;select bank0<br />
00166 ;adc<br />
001C 3089 00167 movlw AVOUT ;(10MHz osc)set A/D c<strong>on</strong>v clock(Fosc/32),<br />
001D 009F 00168 movwf ADCON0 ;select RA1(AN1), turn <strong>on</strong> A/D<br />
00169 ;PWM<br />
001E 1217 00170 bcf CCP1CON,4;clear ls bits of PWM duty cycle<br />
001F 1297 00171 bcf CCP1CON,5<br />
0020 0195 00172 clrf CCPR1L ;set PWM to 0 (turn off PWM)<br />
00173<br />
0021 3004 00174 movlw 0x04 ;enable timer2, set prescale=1:1,<br />
postscale=1:1<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 11
AN701<br />
0022 0092 00175 movwf T2CON<br />
0023 300C 00176 movlw 0x0C ;set CCP1 to PWM mode<br />
0024 0097 00177 movwf CCP1CON<br />
00178<br />
00179 ;****************************************************************************<br />
00180 ;* Restart Clears memory<br />
00181 ;*<br />
00182 ;* Initializes display LEDs, desired output voltage,<br />
00183 ;* debounce counters<br />
00184 ;*<br />
00185 ;* Enables interrupts<br />
00186 ;*<br />
00187 ;* Output Variables:<br />
00188 ;* SETPOINT desired output voltage, set to 3.0V<br />
00189 ;* DNCL, DNCH Down voltage butt<strong>on</strong> debounce counter<br />
00190 ;* UPCL, UPCH Up voltage butt<strong>on</strong> debounce counter<br />
00191 ;*<br />
00192 ;****************************************************************************<br />
00193<br />
0025 3020 00194 Restart movlw 0x20 ;clear memory from 0x20 to 0x3f<br />
0026 0084 00195 movwf FSR<br />
0027 0180 00196 ClrMem clrf INDF<br />
0028 0A84 00197 incf FSR,F<br />
0029 1F04 00198 btfss FSR,6<br />
002A 2827 00199 goto ClrMem<br />
00200<br />
002B 3001 00201 movlw 0x01 ;light 3.0V LED<br />
002C 0086 00202 movwf PORTB<br />
00203<br />
002D 304D 00204 movlw 0x4d ;initial 3.0V setting<br />
002E 00A4 00205 movwf SETPOINT<br />
00206<br />
002F 01A2 00207 clrf DNCL ;clear down butt<strong>on</strong> debounce counter<br />
0030 01A0 00208 clrf UPCL ;clear up butt<strong>on</strong> debounce counter<br />
00209<br />
0031 30F9 00210 movlw DEL1<br />
0032 00A3 00211 movwf DNCH ;preset down butt<strong>on</strong> debounce counter byte<br />
0033 00A1 00212 movwf UPCH ;preset up butt<strong>on</strong> debounce counter high byte<br />
00213<br />
0034 170B 00214 bsf INTCON,PEIE ;enable peripheral interrupt sources<br />
0035 178B 00215 bsf INTCON,GIE ;enable all interrupts<br />
00216<br />
00217 ;****************************************************************************<br />
00218 ;*<br />
00219 ;* Again Top of main loop<br />
00220 ;*<br />
00221 ;* Waits for 8 timer2 interrupts<br />
00222 ;*<br />
00223 ;* A/D c<strong>on</strong>verts VOUT<br />
00224 ;*<br />
00225 ;* Acquires VUNREG channel<br />
00226 ;*<br />
00227 ;* Input Variables:<br />
00228 ;* T2POST Timer2 interrupt counter<br />
00229 ;*<br />
00230 ;* Output Variables:<br />
00231 ;* VOUT C<strong>on</strong>versi<strong>on</strong> result<br />
00232 ;*<br />
00233 ;****************************************************************************<br />
00234<br />
0036 00235 Again<br />
0036 1DB5 00236 btfss T2POST,3 ;l<strong>on</strong>g delay<br />
0037 2836 00237 goto Again ;try again<br />
00238<br />
0038 01B5 00239 clrf T2POST ;clear counter<br />
00240<br />
DS00701A-page 12 © 1999 <strong>Microchip</strong> Technology Inc.
00241 ;--- start c<strong>on</strong>versi<strong>on</strong> - feedback<br />
0039 151F 00242 bsf ADCON0,GO_DONE ;start c<strong>on</strong>versi<strong>on</strong><br />
003A 0000 00243 nop<br />
003B 191F 00244 Wc2 btfsc ADCON0,GO_DONE ;test if d<strong>on</strong>e<br />
003C 283B 00245 goto Wc2 ;no, wait some more<br />
003D 081E 00246 movf ADRES,W ;get c<strong>on</strong>versi<strong>on</strong> result<br />
003E 00A5 00247 movwf VOUT ;save result<br />
00248 ;--- end c<strong>on</strong>versi<strong>on</strong><br />
003F 3099 00249 movlw AVUNREG ;select VUNREG channel<br />
0040 009F 00250 movwf ADCON0<br />
00251<br />
00252<br />
;****************************************************************************<br />
00253 ;* FErr Finds difference (error) between SETPOINT and VOUT<br />
00254 ;* E0H:E0 = SETPOINT - VOUT<br />
00255 ;*<br />
00256 ;* Input Variables:<br />
00257 ;* SETPOINT Desired output voltage<br />
00258 ;*<br />
00259 ;* Output Variables:<br />
00260 ;* E0H:E0 Signed error<br />
00261<br />
;****************************************************************************<br />
00262<br />
0041 00263 FErr<br />
0041 01B2 00264 clrf E0H ;clear error high byte<br />
00265<br />
0042 0825 00266 movf VOUT,W<br />
0043 0224 00267 subwf SETPOINT,W ;f-w=d<br />
0044 00B1 00268 movwf E0 ;save new error<br />
00269<br />
0045 1C03 00270 btfss STATUS,C ;was there a borrow?<br />
0046 09B2 00271 comf E0H,F ;yes<br />
00272<br />
00273<br />
;****************************************************************************<br />
00274 ;* Ppp Produces proporti<strong>on</strong>al term by multiplying E0H:E0 by Kp<br />
00275 ;*<br />
00276 ;* PROH:PRO = E0H:E0 * Kp<br />
00277 ;* Kp = 2^3 - Produced by 3 left shifts<br />
00278 ;*<br />
00279 ;* This term forces the output close to the desired output<br />
00280 ;* quickly, but will never completely eliminate the error.<br />
00281 ;*<br />
00282 ;* Input Variables:<br />
00283 ;* E0H:E0 Error found at top of loop<br />
00284 ;* Kp Proporti<strong>on</strong>al gain factor (c<strong>on</strong>stant)<br />
00285 ;*<br />
00286 ;* Output Variables:<br />
00287 ;* PROH:PRO Proporti<strong>on</strong>al comp<strong>on</strong>ent<br />
00288 ;*<br />
00289<br />
;****************************************************************************<br />
00290<br />
0047 00291 Ppp<br />
0047 0831 00292 movf E0,W ;move E0 to temp space<br />
0048 00A7 00293 movwf TEMPA<br />
0049 0832 00294 movf E0H,W<br />
004A 00A8 00295 movwf TEMPB<br />
00296<br />
004B 1003 00297 bcf STATUS,C ;mult E0 by 2<br />
004C 0DA7 00298 rlf TEMPA,F<br />
004D 0DA8 00299 rlf TEMPB,F<br />
00300<br />
004E 1003 00301 bcf STATUS,C ;mult E0 by 2<br />
004F 0DA7 00302 rlf TEMPA,F<br />
AN701<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 13
AN701<br />
0050 0DA8 00303 rlf TEMPB,F<br />
00304<br />
0051 1003 00305 bcf STATUS,C ;mult E0 by 2<br />
0052 0DA7 00306 rlf TEMPA,F<br />
0053 0DA8 00307 rlf TEMPB,F<br />
00308<br />
0054 0827 00309 PppD movf TEMPA,W ;move result in temp space to pro<br />
0055 00AB 00310 movwf PRO<br />
0056 0828 00311 movf TEMPB,W<br />
0057 00AC 00312 movwf PROH<br />
00313<br />
00314<br />
;****************************************************************************<br />
00315 ;* DifCom Computes differential comp<strong>on</strong>ent<br />
00316 ;*<br />
00317 ;* Finds difference between this loop error and previous<br />
loop error<br />
00318 ;* DIFH:DIF = (E1H:E1 - E0H:E0) * Kd<br />
00319 ;*<br />
00320 ;* Kd = 2^3 - Produced by 3 left shifts<br />
00322 ;* This term tends to slow c<strong>on</strong>troller resp<strong>on</strong>se.<br />
00323 ;*<br />
00324 ;* Input Variables:<br />
00325 ;* E1H:E1 Previous loop error<br />
00326 ;* E0H:E0 Present loop error<br />
00327 ;* Kd Differential gain factor (c<strong>on</strong>stant)<br />
00328 ;*<br />
00329 ;* Output Variables:<br />
00330 ;* DIFH:DIF differential comp<strong>on</strong>ent<br />
00331 ;*<br />
00332<br />
;****************************************************************************<br />
00333<br />
0058 00334 DifCom<br />
0058 0834 00335 movf E1H,W ;get prev error high byte<br />
0059 0232 00336 subwf E0H,W ;f-w=d E0-E1=w<br />
005A 00AE 00337 movwf DIFH ;save difference high byte<br />
00338<br />
005B 0833 00339 movf E1,W ;get prev error low byte<br />
005C 0231 00340 subwf E0,W ;f-w=d E0-E1=w<br />
005D 00AD 00341 movwf DIF ;save difference low byte<br />
00342<br />
005E 1C03 00343 btfss STATUS,C ;was there a borrow?<br />
005F 03AE 00344 decf DIFH,F ;yes<br />
00345<br />
00346 ;allow difference to be modified here<br />
00347<br />
0060 1003 00348 bcf STATUS,C ;mult dif by 2<br />
0061 0DAD 00349 rlf DIF,F<br />
0062 0DAE 00350 rlf DIFH,F<br />
00351<br />
0063 1003 00352 bcf STATUS,C ;mult dif by 2<br />
0064 0DAD 00353 rlf DIF,F<br />
0065 0DAE 00354 rlf DIFH,F<br />
00355<br />
0066 1003 00356 bcf STATUS,C ;mult dif by 2<br />
0067 0DAD 00357 rlf DIF,F<br />
0068 0DAE 00358 rlf DIFH,F<br />
00359<br />
00360<br />
00361<br />
00362<br />
;****************************************************************************<br />
00363 ;* IntCom Computes integral comp<strong>on</strong>ent<br />
00364 ;*<br />
00365 ;* Multiplies present error by Ki,<br />
DS00701A-page 14 © 1999 <strong>Microchip</strong> Technology Inc.
00366 ;* adds result to INTH:INT<br />
00367 ;*<br />
00368 ;* INTH:INT = INTH:INT + E0H:E0 * Ki<br />
00369 ;*<br />
00370 ;* Ki = 2^3 -- Produced by 3 left shifts<br />
00371 ;*<br />
00372 ;* This term will eliminate all error,<br />
00373 ;* but not quickly<br />
00374 ;*<br />
00375 ;* Input Variables:<br />
00376 ;* E0H:E0 Present loop error<br />
00377 ;* INTH:INT Running total of errors<br />
00378 ;* Ki Integral gain factor (c<strong>on</strong>stant)<br />
00379 ;*<br />
00380 ;* Output Variables:<br />
00381 ;* DIFH:DIF differential comp<strong>on</strong>ent<br />
00382<br />
;****************************************************************************<br />
00383<br />
0069 00384 IntCom<br />
0069 0832 00385 movf E0H,W ;move E0 to temp space<br />
006A 00A8 00386 movwf TEMPB<br />
006B 0831 00387 movf E0,W<br />
006C 00A7 00388 movwf TEMPA<br />
00389<br />
00390 ;allow error to be modified here before adding to integral<br />
00391<br />
006D 1003 00392 bcf STATUS,C<br />
006E 0DA7 00393 rlf TEMPA,F ;E0<br />
006F 0DA8 00394 rlf TEMPB,F ;E0H<br />
00395<br />
0070 1003 00396 bcf STATUS,C<br />
0071 0DA7 00397 rlf TEMPA,F ;E0<br />
0072 0DA8 00398 rlf TEMPB,F ;E0H<br />
00399<br />
0073 1003 00400 bcf STATUS,C<br />
0074 0DA7 00401 rlf TEMPA,F ;E0<br />
0075 0DA8 00402 rlf TEMPB,F ;E0H<br />
00403<br />
0076 0827 00404 IntD movf TEMPA,W ;get current error, E0<br />
0077 07A9 00405 addwf INT,F ;add to INT, store in INT<br />
0078 1803 00406 btfsc STATUS,C ;was there a carry?<br />
0079 0AAA 00407 incf INTH,F ;yes, inc INT high byte<br />
00408<br />
007A 0828 00409 movf TEMPB,W ;get E0 high byte, E0H<br />
007B 07AA 00410 addwf INTH,F<br />
00411<br />
00412<br />
;****************************************************************************<br />
00413 ;* Total Sums proporti<strong>on</strong>al, integral, and differential terms<br />
00414 ;*<br />
00415 ;* PWMH:PWM = INTH:INT + PROH:PRO + DIFH:DIF<br />
00416 ;*<br />
00417 ;* If the result should ever go negative,<br />
00418 ;* the result is forced to 0,and the overload LED is set.<br />
00419 ;* (This is an error c<strong>on</strong>diti<strong>on</strong>.Can’t have a negative PWM.)<br />
00420 ;*<br />
00421 ;* Input Variables:<br />
00422 ;* INTH:INT Integral term<br />
00423 ;* PROH:PRO Proporti<strong>on</strong>al term<br />
00424 ;* DIFH:DIF Differential term<br />
00425 ;*<br />
00426 ;* Output Variables:<br />
00427 ;* PWMH:PWM Sum of terms<br />
00428<br />
;****************************************************************************<br />
AN701<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 15
AN701<br />
00429<br />
007C 00430 Total<br />
007C 082C 00431 PCom movf PROH,W ;add in proporti<strong>on</strong>al term<br />
007D 00B0 00432 movwf PWMH<br />
00433<br />
007E 082B 00434 movf PRO,W<br />
007F 00AF 00435 movwf PWM<br />
00436<br />
0080 082A 00437 ICom movf INTH,W ;add in integral term<br />
0081 07B0 00438 addwf PWMH,F<br />
00439<br />
0082 0829 00440 movf INT,W<br />
0083 07AF 00441 addwf PWM,F<br />
0084 1803 00442 btfsc STATUS,C<br />
0085 0AB0 00443 incf PWMH,F<br />
00444<br />
0086 082E 00445 DCom movf DIFH,W ;add in differential term<br />
0087 07B0 00446 addwf PWMH,F<br />
00447<br />
0088 082D 00448 movf DIF,W<br />
0089 07AF 00449 addwf PWM,F<br />
008A 1803 00450 btfsc STATUS,C<br />
008B 0AB0 00451 incf PWMH,F<br />
00452<br />
008C 1BB0 00453 Ovrld btfsc PWMH,7 ;did PWM go negative?<br />
008D 2890 00454 goto NegPwm ;yes<br />
008E 1306 00455 bcf PORTB,6 ;no - turn off overload LED<br />
008F 2893 00456 goto PwmGen<br />
00457<br />
0090 1706 00458 NegPwm bsf PORTB,6 ;turn <strong>on</strong> overload LED<br />
0091 01B0 00459 clrf PWMH ;set PWM to 0<br />
0092 01AF 00460 clrf PWM<br />
00461<br />
00462<br />
;****************************************************************************<br />
00463 ;* PwmGen Divides PWHM:PWM by 8 (3 right shifts)<br />
00464 ;* 2 LSbits of PWM sent to 2 LSbits of duty cycle register<br />
00465 ;* remaining 6 bits sent to CCPR1L (duty cycle register)<br />
00466 ;*<br />
00467 ;* A/D has been acquiring VUNREG, start c<strong>on</strong>versi<strong>on</strong>.<br />
00468 ;*<br />
00469 ;* Input Variables:<br />
00470 ;* PWMH:PWM PWM drive<br />
00471<br />
;****************************************************************************<br />
00472<br />
009 00473 PwmGen<br />
0093 0CB0 00474 rrf PWMH,F ;PWMH<br />
0094 0CAF 00475 rrf PWM,F ;PWM<br />
00476<br />
0095 0CB0 00477 rrf PWMH,F ;PWMH<br />
0096 0CAF 00478 rrf PWM,F ;PWM<br />
00479<br />
0097 0CB0 00480 rrf PWMH,F ;PWMH - can ignore c<strong>on</strong>tents of PWMH now<br />
0098 0CAF 00481 rrf PWM,F ;PWM<br />
00482<br />
0099 1217 00483 bcf CCP1CON,4 ;clear ls bits of PWM duty cycle<br />
009A 1297 00484 bcf CCP1CON,5<br />
00485<br />
009B 0CAF 00486 rrf PWM,F ;shift carry INTo PWM, lsbit INTo carry<br />
009C 1803 00487 btfsc STATUS,C ;is carry set?<br />
009D 1617 00488 bsf CCP1CON,4 ;set PWM duty cycle lsb<br />
00489<br />
009E 0CAF 00490 rrf PWM,F ;shift carry INTo PWM, lsbit INTo carry<br />
009F 1803 00491 btfsc STATUS,C ;is carry set?<br />
00A0 1697 00492 bsf CCP1CON,5 ;set PWM duty cycle lsb<br />
DS00701A-page 16 © 1999 <strong>Microchip</strong> Technology Inc.
AN701<br />
00493<br />
00A1 082F 00494 movf PWM,W ;get PWM<br />
00A2 393F 00495 andlw 0x3f ;mask off 2 ms bits (78.125KHz)<br />
00A3 0095 00496 movwf CCPR1L ;put in PWM duty cycle<br />
00497<br />
00A4 151F 00498 bsf ADCON0,2 ;start c<strong>on</strong>versi<strong>on</strong> VUNREG<br />
00499<br />
00500<br />
;****************************************************************************<br />
00501 ;* up/dn butt<strong>on</strong>s<br />
00502 ;* Debounces UP and DOWN butt<strong>on</strong>s<br />
00503 ;* Increments counters <strong>on</strong>ce for each pass<br />
00504 ;* through the loop when butt<strong>on</strong> pressed.<br />
00505 ;*<br />
00506 ;* If butt<strong>on</strong> not pressed, counter is reset.<br />
00507 ;*<br />
00508 ;* If a butt<strong>on</strong> is successfully debounced,<br />
00509 ;* both counters are reset.<br />
00510 ;*<br />
00511 ;* Debounce delay is about 0.5 sec<strong>on</strong>ds<br />
00512 ;*<br />
00513 ;* Moves voltage indicator bit as required.<br />
00514 ;*<br />
00515 ;* Finds index into lookup table, and calls table.<br />
00516 ;*<br />
00517 ;* Saves result from lookup table as new SETPOINT<br />
00518 ;*<br />
00519 ;* Input Variables:<br />
00520 ;* PORTB Current indicator data<br />
00521 ;* DNCH:DNCL Down butt<strong>on</strong> debounce counter<br />
00522 ;* UPCH:UPCL Up butt<strong>on</strong> debounce counter<br />
00523 ;*<br />
00524 ;* Output Variables:<br />
00525 ;* PORTB Current indicator data<br />
00526 ;* DNCH:DNCL Down butt<strong>on</strong> debounce counter<br />
00527 ;* UPCH:UPCL Up butt<strong>on</strong> debounce counter<br />
00528 ;* SETPOINT New voltage setpoint<br />
00529<br />
;****************************************************************************<br />
00530<br />
00A5 0806 00531 movf PORTB,W ;move LED data to temp space<br />
00A6 393F 00532 andlw 0x3f ;mask off n<strong>on</strong>-voltage LEDs<br />
00A7 00A7 00533 movwf TEMPA<br />
00534<br />
00A8 1E85 00535 Dnb btfss PORTA,5 ;down<br />
00A9 28B3 00536 goto Upb ;down not pushed<br />
00AA 0FA2 00537 incfsz DNCL,f ;down is pushed, inc debounce<br />
00AB 28CE 00538 goto Wc3 ;no carry - go to next module<br />
00AC 0FA3 00539 incfsz DNCH,f ;inc debounce counter high byte<br />
00AD 28CE 00540 goto Wc3 ;no carry - go to next module<br />
00541 ;---------------------- select next lower LED<br />
00AE 1003 00542 bcf STATUS,C ;select next lower LED<br />
00AF 0CA7 00543 rrf TEMPA,F ;shift LED data down 1 voltage<br />
00B0 1803 00544 btfsc STATUS,C ;3V LED was set before rotate, so<br />
00B1 1427 00545 bsf TEMPA,0 ;set it again<br />
00546<br />
00B2 28BE 00547 goto Dunb<br />
00548<br />
00B3 1D05 00549 Upb btfss PORTA,2 ;up butt<strong>on</strong><br />
00B4 28C9 00550 goto Nob ;up not pushed - no butt<strong>on</strong>s pushed<br />
00B5 0FA0 00551 incfsz UPCL,f ;down is pushed, inc debounce<br />
00B6 28CE 00552 goto Wc3 ;no carry - go to next module<br />
00B7 0FA1 00553 incfsz UPCH,F ;inc debounce counter high byte<br />
00B8 28CE 00554 goto Wc3 ;no carry - go to next module<br />
00555 ;-------------------- select next higher LED<br />
00B9 1003 00556 bcf STATUS,C ;select next higher voltage LED<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 17
AN701<br />
00BA 0DA7 00557 rlf TEMPA,F ;shift LED data up 1 voltage<br />
00BB 1B27 00558 btfsc TEMPA,6 ;if 9V LED was set before,<br />
00BC 16A7 00559 bsf TEMPA,5 ;set it again, and<br />
00BD 1327 00560 bcf TEMPA,6 ;clear the overload LED<br />
00561<br />
00BE 0827 00562 Dunb movf TEMPA,W ;move LED data back to PORTB<br />
00BF 0086 00563 movwf PORTB<br />
00564<br />
00C0 01A8 00565 clrf TEMPB<br />
00C1 03A8 00566 decf TEMPB,F ;set TEMPB to -1<br />
00567<br />
00C2 0AA8 00568 NewSetincf TEMPB,F ;count up<br />
00C3 0CA7 00569 rrf TEMPA,F ;rotate least sig bit INTo carry<br />
00C4 1C03 00570 btfss STATUS,C ;is carry set now?<br />
00C5 28C2 00571 goto NewSet ;no, try again<br />
00572<br />
00C6 0828 00573 movf TEMPB,W ;yes, put count in w<br />
00C7 20DD 00574 call Tbl ;get corresp<strong>on</strong>ding value for PWM<br />
00C8 00A4 00575 movwf SETPOINT ;put value in SETPOINT<br />
00576<br />
00C9 01A2 00577 Nob clrf DNCL ;clear down butt<strong>on</strong> debounce counter<br />
00CA 01A0 00578 clrf UPCL ;clear up butt<strong>on</strong> debounce counter<br />
00CB 30F9 00579 movlw DEL1<br />
00CC 00A3 00580 movwf DNCH ;preset down butt<strong>on</strong> debounce counter<br />
00CD 00A1 00581 movwf UPCH ;preset up butt<strong>on</strong> debounce counter high byte<br />
00582<br />
00583<br />
;****************************************************************************<br />
00584 ;* Wc3 VUNREG has been c<strong>on</strong>verted by now,<br />
00585 ;* Get result, save in VUNREG.<br />
00586 ;*<br />
00587 ;* Select VOUT to aquire.<br />
00588 ;*<br />
00589 ;* Test VUNREG to see if it has dropped too low.<br />
00590 ;* If too low, call protective shut-down.<br />
00591 ;*<br />
00592 ;* Input Variables:<br />
00593 ;* VUNREG Input voltage.<br />
00594<br />
;****************************************************************************<br />
00595<br />
00CE 00596 Wc3<br />
00CE 191F 00597 btfsc ADCON0,GO_DONE ;test if d<strong>on</strong>e<br />
00CF 28CE 00598 goto Wc3 ;no, wait some more<br />
00D0 081E 00599 movf ADRES,W ;get c<strong>on</strong>versi<strong>on</strong> result<br />
00D1 00A6 00600 movwf VUNREG ;save result<br />
00601<br />
00D2 3089 00602 movlw AVOUT ;select feedback channel to aquire<br />
00D3 009F 00603 movwf ADCON0<br />
00604<br />
00D4 0826 00605 movf VUNREG,W ;get UNREG<br />
00D5 3C50 00606 sublw 0x50 ;10V-VUNREG=? C=1 if VUNREG
00620 ;* Output Variables:<br />
00621 ;* E1H:E1 Previous error<br />
00622<br />
;****************************************************************************<br />
00623<br />
00D8 00624 Shift<br />
00D8 0831 00625 movf E0,W<br />
00D9 00B3 00626 movwf E1<br />
00627<br />
00DA 0832 00628 movf E0H,W<br />
00DB 00B4 00629 movwf E1H<br />
00630<br />
00DC 2836 00631 goto Again<br />
00632<br />
00633<br />
;****************************************************************************<br />
00634 ;* Tbl Look up table.<br />
00635 ;*<br />
00636 ;* Called with an index in W.<br />
00637 ;*<br />
00638 ;* Index is added to program counter.<br />
00639 ;*<br />
00640 ;* Executi<strong>on</strong> jumps to "retlw" which will return<br />
00641 ;* to the calling program with table value in w.<br />
00642 ;*<br />
00643 ;* Input Variables:<br />
00644 ;* w Offset index into table<br />
00645 ;*<br />
00646 ;* Output Variables:<br />
00647 ;* w Value from table<br />
00648<br />
;****************************************************************************<br />
00649<br />
00DD 00650 Tbl ;call with index in w<br />
00DD 0782 00651 addwf PCL,F ;add index to PC<br />
00652<br />
00DE 344D 3474 3482 00653 dt 0x4d, 0x74, 0x82, 0x9b, 0xc2, 0xea<br />
349B 34C2 34EA<br />
00654 ;output voltage 3.0 4.5 5.0 6.0 7.5 9.0<br />
00655<br />
00656<br />
;****************************************************************************<br />
00657 ;* ShutDn Protective shutdown. Entry into this routine is a result<br />
00658 ;* of a low input voltage. This turns off the c<strong>on</strong>verter<br />
00659 ;* before the series pass transistor can overheat.<br />
00660 ;*<br />
00661 ;* PWM <strong>on</strong>-time is set to 0, turning off the c<strong>on</strong>verter.<br />
00662 ;*<br />
00663 ;* The c<strong>on</strong>verter trip LED is lit, indicating shutdown.<br />
00664 ;*<br />
00665 ;* Executi<strong>on</strong> then loops without exit. The <strong>on</strong>ly exit is to<br />
00666 ;* reset the c<strong>on</strong>troller.<br />
00667<br />
;****************************************************************************<br />
00668<br />
00E4 00669 ShutDn<br />
00E4 1217 00670 bcf CCP1CON,4 ;turn off PWM<br />
00E5 1297 00671 bcf CCP1CON,5<br />
00E6 0195 00672 clrf CCPR1L<br />
00673<br />
00E7 1786 00674 bsf PORTB,7 ;light trip LED<br />
00675<br />
00E8 00676 Dead<br />
00E8 28E8 00677 goto Dead ;stays here<br />
00678<br />
00679<br />
00680 END<br />
AN701<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 19
AN701<br />
MEMORY USAGE MAP (’X’ = Used, ’-’ = Unused)<br />
0000 : X---XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX<br />
0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX<br />
0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX<br />
00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXX------- ----------------<br />
2000 : -------X-------- ---------------- ---------------- ----------------<br />
All other memory blocks unused.<br />
Program Memory Words Used: 230<br />
Program Memory Words Free: 1818<br />
Errors : 0<br />
Warnings : 0 reported, 0 suppressed<br />
Messages : 0 reported, 7 suppressed<br />
DS00701A-page 20 © 1999 <strong>Microchip</strong> Technology Inc.
AN701<br />
© 1999 <strong>Microchip</strong> Technology Inc. DS00701A-page 21
Note the following details of the code protecti<strong>on</strong> feature <strong>on</strong> PICmicro ® MCUs.<br />
The PICmicro family meets the specificati<strong>on</strong>s c<strong>on</strong>tained in the <strong>Microchip</strong> Data Sheet.<br />
<strong>Microchip</strong> believes that its family of PICmicro microc<strong>on</strong>trollers is <strong>on</strong>e of the most secure products of its kind <strong>on</strong> the market today,<br />
when used in the intended manner and under normal c<strong>on</strong>diti<strong>on</strong>s.<br />
There are dish<strong>on</strong>est and possibly illegal methods used to breach the code protecti<strong>on</strong> feature. All of these methods, to our knowledge,<br />
require using the PICmicro microc<strong>on</strong>troller in a manner outside the operating specificati<strong>on</strong>s c<strong>on</strong>tained in the data sheet.<br />
The pers<strong>on</strong> doing so may be engaged in theft of intellectual property.<br />
<strong>Microchip</strong> is willing to work with the customer who is c<strong>on</strong>cerned about the integrity of their code.<br />
Neither <strong>Microchip</strong> nor any other semic<strong>on</strong>ductor manufacturer can guarantee the security of their code. Code protecti<strong>on</strong> does not<br />
mean that we are guaranteeing the product as “unbreakable”.<br />
Code protecti<strong>on</strong> is c<strong>on</strong>stantly evolving. We at <strong>Microchip</strong> are committed to c<strong>on</strong>tinuously improving the code protecti<strong>on</strong> features of<br />
our product.<br />
If you have any further questi<strong>on</strong>s about this matter, please c<strong>on</strong>tact the local sales office nearest to you.<br />
Informati<strong>on</strong> c<strong>on</strong>tained in this publicati<strong>on</strong> regarding device<br />
applicati<strong>on</strong>s and the like is intended through suggesti<strong>on</strong> <strong>on</strong>ly<br />
and may be superseded by updates. It is your resp<strong>on</strong>sibility to<br />
ensure that your applicati<strong>on</strong> meets with your specificati<strong>on</strong>s.<br />
No representati<strong>on</strong> or warranty is given and no liability is<br />
assumed by <strong>Microchip</strong> Technology Incorporated with respect<br />
to the accuracy or use of such informati<strong>on</strong>, or infringement of<br />
patents or other intellectual property rights arising from such<br />
use or otherwise. Use of <strong>Microchip</strong>’s products as critical comp<strong>on</strong>ents<br />
in life support systems is not authorized except with<br />
express written approval by <strong>Microchip</strong>. No licenses are c<strong>on</strong>veyed,<br />
implicitly or otherwise, under any intellectual property<br />
rights.<br />
© 2002 <strong>Microchip</strong> Technology Inc.<br />
Trademarks<br />
The <strong>Microchip</strong> name and logo, the <strong>Microchip</strong> logo, FilterLab,<br />
KEELOQ, microID, MPLAB, PIC, PICmicro, PICMASTER,<br />
PICSTART, PRO MATE, SEEVAL and The Embedded C<strong>on</strong>trol<br />
Soluti<strong>on</strong>s Company are registered trademarks of <strong>Microchip</strong> Technology<br />
Incorporated in the U.S.A. and other countries.<br />
dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,<br />
In-Circuit Serial Programming, ICSP, ICEPIC, microPort,<br />
Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM,<br />
MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select <str<strong>on</strong>g>Mode</str<strong>on</strong>g><br />
and Total Endurance are trademarks of <strong>Microchip</strong> Technology<br />
Incorporated in the U.S.A.<br />
Serialized Quick Turn Programming (SQTP) is a service mark<br />
of <strong>Microchip</strong> Technology Incorporated in the U.S.A.<br />
All other trademarks menti<strong>on</strong>ed herein are property of their<br />
respective companies.<br />
© 2002, <strong>Microchip</strong> Technology Incorporated, Printed in the<br />
U.S.A., All Rights Reserved.<br />
Printed <strong>on</strong> recycled paper.<br />
<strong>Microchip</strong> received QS-9000 quality system<br />
certificati<strong>on</strong> for its worldwide headquarters,<br />
design and wafer fabricati<strong>on</strong> facilities in<br />
Chandler and Tempe, Ariz<strong>on</strong>a in July 1999. The<br />
Company’s quality system processes and<br />
procedures are QS-9000 compliant for its<br />
PICmicro ® 8-bit MCUs, KEELOQ ® code hopping<br />
devices, Serial EEPROMs and microperipheral<br />
products. In additi<strong>on</strong>, <strong>Microchip</strong>’s quality<br />
system for the design and manufacture of<br />
development systems is ISO 9001 certified.
M<br />
AMERICAS<br />
Corporate Office<br />
2355 West Chandler Blvd.<br />
Chandler, AZ 85224-6199<br />
Tel: 480-792-7200 Fax: 480-792-7277<br />
Technical Support: 480-792-7627<br />
Web Address: http://www.microchip.com<br />
Rocky Mountain<br />
2355 West Chandler Blvd.<br />
Chandler, AZ 85224-6199<br />
Tel: 480-792-7966 Fax: 480-792-7456<br />
Atlanta<br />
500 Sugar Mill Road, Suite 200B<br />
Atlanta, GA 30350<br />
Tel: 770-640-0034 Fax: 770-640-0307<br />
Bost<strong>on</strong><br />
2 Lan Drive, Suite 120<br />
Westford, MA 01886<br />
Tel: 978-692-3848 Fax: 978-692-3821<br />
Chicago<br />
333 Pierce Road, Suite 180<br />
Itasca, IL 60143<br />
Tel: 630-285-0071 Fax: 630-285-0075<br />
Dallas<br />
4570 Westgrove Drive, Suite 160<br />
Addis<strong>on</strong>, TX 75001<br />
Tel: 972-818-7423 Fax: 972-818-2924<br />
Detroit<br />
Tri-Atria Office Building<br />
32255 Northwestern Highway, Suite 190<br />
Farmingt<strong>on</strong> Hills, MI 48334<br />
Tel: 248-538-2250 Fax: 248-538-2260<br />
Kokomo<br />
2767 S. Albright Road<br />
Kokomo, Indiana 46902<br />
Tel: 765-864-8360 Fax: 765-864-8387<br />
Los Angeles<br />
18201 V<strong>on</strong> Karman, Suite 1090<br />
Irvine, CA 92612<br />
Tel: 949-263-1888 Fax: 949-263-1338<br />
New York<br />
150 Motor Parkway, Suite 202<br />
Hauppauge, NY 11788<br />
Tel: 631-273-5305 Fax: 631-273-5335<br />
San Jose<br />
<strong>Microchip</strong> Technology Inc.<br />
2107 North First Street, Suite 590<br />
San Jose, CA 95131<br />
Tel: 408-436-7950 Fax: 408-436-7955<br />
Tor<strong>on</strong>to<br />
6285 Northam Drive, Suite 108<br />
Mississauga, Ontario L4V 1X5, Canada<br />
Tel: 905-673-0699 Fax: 905-673-6509<br />
WORLDWIDE SALES AND SERVICE<br />
ASIA/PACIFIC<br />
Australia<br />
<strong>Microchip</strong> Technology Australia Pty Ltd<br />
Suite 22, 41 Raws<strong>on</strong> Street<br />
Epping 2121, NSW<br />
Australia<br />
Tel: 61-2-9868-6733 Fax: 61-2-9868-6755<br />
China - Beijing<br />
<strong>Microchip</strong> Technology C<strong>on</strong>sulting (Shanghai)<br />
Co., Ltd., Beijing Liais<strong>on</strong> Office<br />
Unit 915<br />
Bei Hai Wan Tai Bldg.<br />
No. 6 Chaoyangmen Beidajie<br />
Beijing, 100027, No. China<br />
Tel: 86-10-85282100 Fax: 86-10-85282104<br />
China - Chengdu<br />
<strong>Microchip</strong> Technology C<strong>on</strong>sulting (Shanghai)<br />
Co., Ltd., Chengdu Liais<strong>on</strong> Office<br />
Rm. 2401, 24th Floor,<br />
Ming Xing Financial Tower<br />
No. 88 TIDU Street<br />
Chengdu 610016, China<br />
Tel: 86-28-6766200 Fax: 86-28-6766599<br />
China - Fuzhou<br />
<strong>Microchip</strong> Technology C<strong>on</strong>sulting (Shanghai)<br />
Co., Ltd., Fuzhou Liais<strong>on</strong> Office<br />
Unit 28F, World Trade Plaza<br />
No. 71 Wusi Road<br />
Fuzhou 350001, China<br />
Tel: 86-591-7503506 Fax: 86-591-7503521<br />
China - Shanghai<br />
<strong>Microchip</strong> Technology C<strong>on</strong>sulting (Shanghai)<br />
Co., Ltd.<br />
Room 701, Bldg. B<br />
Far East Internati<strong>on</strong>al Plaza<br />
No. 317 Xian Xia Road<br />
Shanghai, 200051<br />
Tel: 86-21-6275-5700 Fax: 86-21-6275-5060<br />
China - Shenzhen<br />
<strong>Microchip</strong> Technology C<strong>on</strong>sulting (Shanghai)<br />
Co., Ltd., Shenzhen Liais<strong>on</strong> Office<br />
Rm. 1315, 13/F, Shenzhen Kerry Centre,<br />
Renminnan Lu<br />
Shenzhen 518001, China<br />
Tel: 86-755-2350361 Fax: 86-755-2366086<br />
H<strong>on</strong>g K<strong>on</strong>g<br />
<strong>Microchip</strong> Technology H<strong>on</strong>gk<strong>on</strong>g Ltd.<br />
Unit 901-6, Tower 2, Metroplaza<br />
223 Hing F<strong>on</strong>g Road<br />
Kwai F<strong>on</strong>g, N.T., H<strong>on</strong>g K<strong>on</strong>g<br />
Tel: 852-2401-1200 Fax: 852-2401-3431<br />
India<br />
<strong>Microchip</strong> Technology Inc.<br />
India Liais<strong>on</strong> Office<br />
Divyasree Chambers<br />
1 Floor, Wing A (A3/A4)<br />
No. 11, O’Shaugnessey Road<br />
Bangalore, 560 025, India<br />
Tel: 91-80-2290061 Fax: 91-80-2290062<br />
Japan<br />
<strong>Microchip</strong> Technology Japan K.K.<br />
Benex S-1 6F<br />
3-18-20, Shinyokohama<br />
Kohoku-Ku, Yokohama-shi<br />
Kanagawa, 222-0033, Japan<br />
Tel: 81-45-471- 6166 Fax: 81-45-471-6122<br />
Korea<br />
<strong>Microchip</strong> Technology Korea<br />
168-1, Youngbo Bldg. 3 Floor<br />
Samsung-D<strong>on</strong>g, Kangnam-Ku<br />
Seoul, Korea 135-882<br />
Tel: 82-2-554-7200 Fax: 82-2-558-5934<br />
Singapore<br />
<strong>Microchip</strong> Technology Singapore Pte Ltd.<br />
200 Middle Road<br />
#07-02 Prime Centre<br />
Singapore, 188980<br />
Tel: 65-334-8870 Fax: 65-334-8850<br />
Taiwan<br />
<strong>Microchip</strong> Technology Taiwan<br />
11F-3, No. 207<br />
Tung Hua North Road<br />
Taipei, 105, Taiwan<br />
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139<br />
EUROPE<br />
Denmark<br />
<strong>Microchip</strong> Technology Nordic ApS<br />
Regus Business Centre<br />
Lautrup hoj 1-3<br />
Ballerup DK-2750 Denmark<br />
Tel: 45 4420 9895 Fax: 45 4420 9910<br />
France<br />
<strong>Microchip</strong> Technology SARL<br />
Parc d’Activite du Moulin de Massy<br />
43 Rue du Saule Trapu<br />
Batiment A - ler Etage<br />
91300 Massy, France<br />
Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79<br />
Germany<br />
<strong>Microchip</strong> Technology GmbH<br />
Gustav-Heinemann Ring 125<br />
D-81739 Munich, Germany<br />
Tel: 49-89-627-144 0 Fax: 49-89-627-144-44<br />
Italy<br />
<strong>Microchip</strong> Technology SRL<br />
Centro Direzi<strong>on</strong>ale Colle<strong>on</strong>i<br />
Palazzo Taurus 1 V. Le Colle<strong>on</strong>i 1<br />
20041 Agrate Brianza<br />
Milan, Italy<br />
Tel: 39-039-65791-1 Fax: 39-039-6899883<br />
United Kingdom<br />
Ariz<strong>on</strong>a <strong>Microchip</strong> Technology Ltd.<br />
505 Eskdale Road<br />
Winnersh Triangle<br />
Wokingham<br />
Berkshire, England RG41 5TU<br />
Tel: 44 118 921 5869 Fax: 44-118 921-5820<br />
01/18/02<br />
© 2002 <strong>Microchip</strong> Technology Inc.