Example projects 231 project 1 hello world light a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ter Using the Analog-to-Digital Converter • Project 4: Digital Clock Using Timer1 • Project 5: Brushed DC Speed Control with Optical Encoder Feedback • Project 6: Brushed DC Speed Control with Back EMF Feedback • Project 7: Stepper Motor Control; Single Stepping, Half Stepping and Microstepping • Project 8: PC Interface Using the USART PIC16F690 Project: • Project 9: Brushed DC Motor Control Using the ECCP DS51557B-page 20 © 2005 Microchip Technology Inc. Example Projects 2.3.1 Project 1: Hello World (Light a LED) When learning to use a new computer language, the first practical lesson traditionally instructs the user how to print “Hello World” on the screen. Staying with tradition, this project will make your PICDEM Mechatronics Demo Board say “Hello World” in the most practical way a microcontroller can – lighting a LED. Objectives 1. Use the PIC16F917 to read a tactile switch input. 2. Implement switch debouncing. 3. Toggle a LED when a switch is pushed. Applicable Technical Documents PICkit 1™ Flash Starter Kit User’s Guide (DS40051): Exercise 2 Jumper Configuration • RD7 (J10) to D0 (J14) • RA0 (J13) to SW2 (J4) FIGURE 2-2: PROJECT 1: JUMPER DIAGRAM FIGURE 2-3: PROJECT 1: SCHEMATIC VDD VDD PIC16F917 11/32 R4 10 kΩ SW2 R5 1 kΩ VDD RD7 2 RA0 12/31 VSS © 2005 Microchip Technology Inc. 30 R36 270 Ω D0 DS51557B-page 21 PICDEMTM Mechatronics Demo Board User’s Guide Instructions Pressing SW2 toggles LED (D0) on and off. Discussion Switch debouncing is done to ensure that mechanical contact chatter in the switch is not mistaken for more than one button push. Debouncing also ensures that for every one press of the button, only one function is executed. In this project that function is toggling a LED. Note: DS51557B-page 22 See Section 2.2 “Loading Projects in MPLAB® IDE” for the location of the source files for this project and all subsequent projects. © 2005 Microchip Technology Inc. Example Projects 2.3.2 Project 2: Dusk Indicator Using the Voltage Comparator If you have yard lights or a porch light at home that automatically turns on at dusk then you are familiar with the application we will create in this project. The comparator on the PIC16F917 will be used to compare the voltage level from the potentiometer to the voltage level out from the light sensor. When the intensity of the light to the sensor is reduced below the trip point set by the potentiometer, the LED will turn on. Objectives 1. Use the internal analog comparator module. 2. Implement software hysteresis to stabilize the comparator output. Applicable Technical Documents PICmicro® Comparator Tips ‘n Tricks (DS41215) Jumper Configuration • C1- (J13) to LIGHT (J4) • C1+ (J13) to POT1 (J4) • RD7 (J10) to D0 (J14) FIGURE 2-4: © 2005 Microchip Technology Inc. PROJECT 2: JUMPER DIAGRAM DS51557B-page 23 PICDEMTM Mechatronics Demo Board User’s Guide FIGURE 2-5: PROJECT 2: SCHEMATIC VDD PIC16F917 VDD 11/32 Light Sensor C24 0.1 μF 6 VDD 4 VBAT 7 GND R31 1 kΩ VDD 2 C1- RD7 30 TSL251RD 5 C1+ VDD POT1 10 kΩ VSS 12/31 R36 270 Ω D0 R10 1 kΩ Instructions Provide a light source for the light sensor and set Potentiometer 1 to the desired trip point. Block the light source and LED1 should turn on. Experiment with the set point and the amount to which you block the light from the sensor. Move your hand slowly in front of the sensor and note that the LED does not flicker. This demonstrates how software hysteresis prevents the output of the comparator from chattering near the trip point. Discussion Comparators are found in many PIC microcontrollers due to the versatility and low cost they offer the user. As you can see, the comparator is one of the more easily used peripherals. Refer to the Comparator Tips ‘n Tricks pamphlet included on the CD in this kit for more information on comparators. DS51557B-page 24 © 2005 Microchip Technology Inc. Example Projects 2.3.3 Project 3: Thermometer Using the Analog-to-Digital Converter This project shows how to read an analog temperature sensor and display the temperature on a LCD. The Analog-to-Digital Converter module is used to read the analog voltage output from the temperature sensor. Then, the resulting value is converted into degrees Celsius and displayed. Objectives 1. Use the Analog-to-Digital Converter module on the PIC16F917 to read the analog voltage output of the TC1047A temperature sensor. 2. Gain knowledge about the LCD module and using the LCD module worksheet. Applicable Technical Documents Precision Temperature-to-Voltage Converter (TC1047/A) Data Sheet (DS21498) Jumper Configuration • AN0 (J13) to TEMP (J4) FIGURE 2-6: PROJECT 3: JUMPER DIAGRAM FIGURE 2-7: PROJECT 3: SCHEMATIC VDD VDD PIC16F917 Temp. Sensor C24 0.1 μF 1 VDD 3 Out 2 VSS TC1047A LCD1 11/32 VDD R19 1 kΩ COMX Common pins SEGX Segment pins 2 AN0 C28 0.1 μF 12/31 VSS VIM-332-DP © 2005 Microchip Technology Inc. DS51557B-page 25 PICDEMTM Mechatronics Demo Board User’s Guide Instructions The LCD displays a temperature reading in degrees Celsius. Breathe on the temperature sensor or introduce another heat source. The displayed temperature should rise. Move the jumper wire from the temperature sensor to...
View Full Document

This note was uploaded on 01/29/2014 for the course AA AA taught by Professor Aa during the Winter '10 term at ENS Cachan.

Ask a homework question - tutors are online