User manual

Table Of Contents
Analog-to-Digital Converter Peripheral Labs
© 2009 Microchip Technology Inc. DS41369A-page 85
5.2.4 Lab 2: Audible Temperature Sensor
5.2.4.1 OVERVIEW
In this lab, the ADC peripheral on the PIC16F690 is used to alter the frequency of
Pulse-Width Modulated Waveform (PWM) in relation to the temperature sensed by a
thermistor connected to the input of the ADC peripheral. The PWM waveform is gener-
ated by simply toggling the RC0 voltage level high and low. The thermistor is used to
create a voltage divider in conjunction with a 1KΩ
resistor to vary the voltage into the
ADC input. This thermistor is a Negative Temperature Coefficient type (NTC) meaning
that as the temperature of the device increases, the resistance effectively decreases.
The voltage drop across the thermistor is converted by the ADC and the ADRESH
result then used to manipulate a TMR0 preload value (see GPIO Lab 3) that will be
used in the Timing() to vary the execution speed of the software control loop and ulti-
mately the frequency of the PWM waveform. The PWM will be connected to an
N-Channel MOSFET used to drive the 8Ω
speaker on the PICDEM Lab Development
Board. The schematic for this lab is shown in Figure 5-5.
FIGURE 5-5: SCHEMATIC FOR ADC LAB 2
Referring to the schematic in Figure 5-5, the RC0 connects to the gate of the IRFD010
N-Channel MOSFET Q1. Resistor R4 pulls the gate input low ensuring the transistor
will remain OFF until a high voltage level is present on the RC0 output. When the PWM
transitions high, Q1 is ON and current flows through the 8Ω
speaker. The 100Ω R3
resistor is used to limit the current through the speaker to maintain manufacturer spec-
ified power ratings. In this way, any change in temperature around the thermistor will
alter the frequency of the PWM, thereby changing the audible frequency emitted from
the speaker.
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
J9J8
V
DD
R1
1K
V
SS
RB4/AN10
U2
RC0
V
SS
V
DD
R3
100
8
R2
10K
J19
SP+
SP-
LS1
Thermistor
Q1
IRFD010 N-Channel
MOSFET
V
SS
R4
10K