Sunteți pe pagina 1din 3

Bansilal Ramnath Agarwal Charitable Trusts

Vishwakarma Institute of Information Technology, Pune Department of Electronics and Telecommunications Content Beyond Syllabus Class: TE ELEX Date: 06 /10 /2011 Subject: Microcontroller

Objective : To Design Embedded Application Using PIC Controller. ( Temp Indicator ) Tools Required : a) Proteus Simulator. b) PIC C| Micro C for PIC\ MPLab. Design step : a) Design a PIC based circuit using Proteus Simulator. b) Write c program to interface various devices using PIC C| Micro C for PIC\ MPLab.
LCD1
+5V LM016L

U2
LM35 118.0

VOUT

VSS VDD VEE

RS RW E 4 5 6

19%

1 2 3

1k

U1
2 3 4 5 6 7 14 13 33 34 35 36 37 38 39 40 RA0/AN0/C1INRC0/T1OSO/T13CKI RA1/AN1/C2INRC1/T1OSI/CCP2B RA2/AN2/C2IN+/VREF-/CVREF RC2/CCP1/P1A RA3/AN3/C1IN+/VREF+ RC3/SCK/SCL RA4/T0CKI/C1OUT RC4/SDI/SDA RA5/AN4/SS/HLVDIN/C2OUT RC5/SDO RA6/OSC2/CLKO RC6/TX/CK RA7/OSC1/CLKI RC7/RX/DT RB0/AN12/FLT0/INT0 RB1/AN10/INT1 RB2/AN8/INT2 RB3/AN9/CCP2A RB4/KBI0/AN11 RB5/KBI1/PGM RB6/KBI2/PGC RB7/KBI3/PGD RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5/P1B RD6/PSP6/P1C RD7/PSP7/P1D RE0/RD/AN5 RE1/WR/AN6 RE2/CS/AN7 RE3/MCLR/VPP PIC18F4520 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30 8 9 10 1

9 6 3

8 5 2 0
2

7 4 1
ON C
1

+
4

=
3

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RV1

VIN

Program:
#include<htc.h> __CONFIG(0x3F3A); #define _XTAL_FREQ 4000000 void Wait(unsigned int delay) { for(;delay;delay--) _delay(100); } void wrcommand(unsigned char command ) { PORTC=0b00000000; PORTD=command; PORTC=0b00000010; Wait(1000); PORTC=0b00000000; Wait(1000); } void wrdata(unsigned char data ) { PORTC=0b00000001; PORTD=data; PORTC=0b00000011; Wait(1000); PORTC=0b000000001; Wait(1000); } lcd_string(unsigned char *string) { while(*string) wrdata(*string++); } LCD_initialisation() { wrcommand(0x38); wrcommand(0x80); wrcommand(0x01); wrcommand(0x06); wrcommand(0x0c); } void main() { TRISC=0; TRISD=0; LCD_initialisation(); lcd_string("WELCOME"); ADCON1=0X80; while(1) { ADCON0=0b10000001; ADON=1; GO=1; //while(GO==1); //wait for the conversion to finish Wait(1000);

int a=ADRESL; int b=ADRESH; int c=a|(b<<8); wrcommand(0xc0); wrdata(c/1000+48); wrdata((c/100)%10+48); wrdata((c/10)%10+48); wrdata(c%10+48); }}

Outcome: 1) Student learn Simulation Software and Tools also they understand the difference between embedded C and Plain C language. 2) After doing simulation they can accelerate their knowledge to build much complex system.

Mr. Rahul S. Pol Subject Teacher, Asst Prof. Dept of E&TC. VIIT, Pune - 48

S-ar putea să vă placă și