Unformatted text preview: the potentiometer
(POT1 on J4). Move the potentiometer to view the full range of temperature conversion. Discussion
The project introduces you to use of the Analog-to-Digital Converter module. One of
the biggest advantages to using a PICmicro® microcontroller in applications that
require temperature sensing is that the microcontroller can be used to calibrate the
temperature sensor reading automatically (over varying supply voltages and process
variations in the parts themselves). This saves the manufacturer costly calibration time
at the factory that is typically required by traditional temperature sensing technologies.
LCD functions were introduced in this project for displaying data on the provided LCD.
Take a look at the LCD worksheet in Appendix B. “LCD Segment Mapping
Worksheet”. This is the same worksheet located in the PIC16F91X Data Sheet, only
it has been filled in using the information from the PICDEM Mechatronics Schematic
(see Appendix A. “Hardware Schematics” for the schematic). In the LCD source
code provided in this project, you can see that the information in this worksheet has
been converted into #define statements for each of the segments. DS51557B-page 26 © 2005 Microchip Technology Inc. Example Projects
2.3.4 Project 4: Digital Clock Using Timer1 Most appliances that have a LCD show a clock readout when the appliance is not in
use. In this project, Timer1 is used to create a real-time clock readout on the LCD. Objectives
1. Configure the PIC16F917 to use the 32.768 kHz crystal to clock Timer1.
2. Convert Timer1 into seconds, minutes and hours. Applicable Technical Documents
Clock Design Using Low Power/Cost Techniques Application Note, AN615 (DS00615) Jumper Configuration
• T1OSI (J13) to OSI (J4) – See note.
T1OSO (J13) to OSO (J4) – See note.
RA3 (J13) to SW2 (J4)
RA4 (J12 to SW3 (J4)
RA5 (J13) to SW4 (J4) FIGURE 2-8: Note: © 2005 Microchip Technology Inc. PROJECT 4: JUMPER DIAGRAM Crystal circuits are very sensitive to noise and stray capacitances. In
general, the traces between a crystal and a microcontroller should be as
short as possible. The reason the PICDEM Mechatronics Demo Board
strayed from good design practice was to give you the option to use pins
RA7 and RA6 for other functions. DS51557B-page 27 PICDEMTM Mechatronics Demo Board User’s Guide
FIGURE 2-9: PROJECT 4: SCHEMATIC
32.768 kHz 14 Segment pins T1OSO VIM-332-DP
10 kΩ R8
R5 2 1 kΩ
VDD RA0 RA3 5 SW4 R9
1 kΩ 3 SW3 Common pins T1OSI C34
22 pF VDD SW2 COMX SEGX C35
22 pF RA1
VSS 12/31 R6
1 kΩ Instructions
Use Switch 2 to set the hours and Switch 3 to set the minutes. Pressing and holding
either of these switches will make the hours or minutes increment at a fast rate. Toggle
between displaying the time (hours and minutes) and displaying the seconds by
pressing Switch 4. Discussion
The 32.768 kHz crystal is used to take the guess work out of creating a clock display.
You may recognize this frequency as being 215 kHz. This makes it very easy to convert
clock pulses to seconds in the binary world of a microcontroller. Every time bit 15 in
Timer1 changes, one second has elapsed. A crystal is used because an RC oscillator
will have an unacceptable degree of error after several days. DS51557B-page 28 © 2005 Microchip Technology Inc. Example Projects
2.3.5 Project 5: Brushed DC Motor Speed Control with Optical
Encoder Feedback Motor control is required in many mechatronic applications ranging from power
windows to washing machine cycle control. This project will demonstrate speed control
of a brushed DC motor. Brushed DC motor control is simple as the commutation, or
sequencing of power to the various windings, is automatically performed by the motor’s
brushes. In this project, the Capture Compare PWM (CCP) module will be used in
PWM mode to generate a brushed DC motor drive. Timer1 will measure speed
feedback from the optical interrupter on the board. The optical interrupter circuit
generates a high signal when light passes through the slots in the encoder disk. By
measuring the time between pulses, the speed of the motor can be determined. A
real-life application example includes precision speed control of a fan or hard disk
1. Configure the CCP module to generate a PWM signal.
2. Use a PWM signal to vary the speed of a brushed DC motor.
3. Configure Timer1 to use the optical interrupter as its clock source. Applicable Technical Documents
Brushed DC Motor Fundamentals Application Note, AN905 (DS00905)
Low-Cost Bidirectional Brushed DC Motor Control Using the PIC16F684 Application
Note, AN893 (DS00893) Jumper Configuration
• RD7 (J10) to P1 (J1)
CCP2 (J10) to N2 (J1)
AN0 (J13) to POT1 (J4)
RC5 (J10) to Optical Interrupter (J7)
Attach the motor leads to DRIVE1 (P9) and DRIVE2 (P10).
J2 and J3 should be unpopulated (no shunts present).
Connect the right and center pins of JP8 using a shunt. © 2005 Microchip Technology Inc. DS51557B-page 29 PICDEMTM Mechatronics Demo Board User’s Guide 32.768 kHz
CRYSTAL TM BRUSHED DC MOTOR OPTICAL
INTERRUPTER PROJECT 5:...
View Full Document
- Winter '10
- ........., MicrOChip Technology Inc