tailieunhanh - Interfacing PIC Microcontrollers 17
Interfacing PIC Microcontrollers 17. Explore in detail microcontroller interfacing techniques using the popular PIC 16F877 Work through step-by-step examples interactively using circuit simulation software, supplied as assembly source code Gain the knowledge of a wide range of peripheral devices such as keyboards, displays, sensors and drives and serial communication with other processors, memory and more Use interactive simulation software to design and test circuits. | Interfacing PIC Microcontrollers ADC8 Convert the analogue input to 8-bits and display Hardware P16F877 4MHz Vref 16x2 LCD Initialise PortA Analogue inputs default PortC LCD outputs ADC Select f 8 RA0 input left justify result enable LCD default setup include LCD driver routines Main REPEAT Get ADC 8-bit input Convert to BCD Display on LCD ALWAYS Subroutines Get ADC 8-bit input Start ADC and wait for done Store result Convert to BCD Calculate hundreds digit Calculate tens digit Remainder ones digit Display on LCD Home cursor Convert BCD to ASCII Send hundreds point tens ones Send Volts Include LCD routines Figure ADC test program outline The data acquisition process is similar to the 8-bit system above but the binary to BCD conversion process is rather more complicated. The result is required in the range 0-4095 so the original result 0-1023 is shifted left twice to multiply it by four. One thousand 03E8 is then loop subtracted from the result to calculate the number of thousands in the number. Correct borrow handling between the high and low byte is particularly important. The process stops when the remainder is less that 1000. The hundreds digit is calculated in a similar way but the tens calculation is a little easier as the maximum remainder from the previous stage is 99 so the high byte borrow handling is not necessary. This process is outlined in Figure and the source code shown in Program . 146 Analogue Interfacing IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII Proj ect Interfacing PICs Source File Name Devised by MPB Date 19 -12-05 Status Fi nal version IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII i I Demonstrates simple analogue input I using an external reference voltage of I The 8-bit result is converted to BCD for display I as a voltage using the standard LCD routines. IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII PROCESSOR 16F877 I Clock XT
đang nạp các trang xem trước