EEE305 Microcontroller Systems
220 likes | 358 Vues
This lecture covers the process of analogue to digital conversion using PIC microcontrollers with a focus on C programming. The session outlines how to read ADC values, convert them into a scaled output for visual representation, and use the USART serial port for outputting results. An example is provided for creating a thermometer application that translates thermistor readings into temperature displays. Code examples, along with detailed explanations of data types and scaling, will enhance understanding of microcontroller systems in EEE305.
EEE305 Microcontroller Systems
E N D
Presentation Transcript
Lecture 8: Analogue to Digital Conversion using PIC microcontrollers and the C compiler (NB As of 18/04/13 this code uses the older HTC compiler, I will change it to the more modern XC8 compiler in class) Teaching resources are at www.eej.ulst.ac.uk My office 5B18, telephone 028 90 366364 My email IJ.McCrum@ulster.ac.uk EEE305 Microcontroller Systems http://www.eej.ulst.ac.uk/~ian/modules/EEE305
Further experiments • If the ADC returns a number from 0 to 1024 • Scale this to 80 (the width of a PUTTY screen) • Use a for loop For(i=0;i<scaled_reading;i++){putchar(‘*’);} Printf(“\r\n”); • This will print a “graph” across the screen.
Making a Thermometer • Assume the thermistor initially reads 20 degrees • After holding for 60 seconds assume it reads 35 degrees • Scale the readings to display degrees • i.e If you get a reading of XX for 20 degrees and YY for 35 degrees. Don’t forget to use variables of type float if they are needed 35⁰C ??⁰C 20⁰C XX ZZ YY