Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Lm35 interfacing with PIC18F4680 and display on LCD

Status
Not open for further replies.

jatin.chotaliya

Newbie level 4
Joined
Mar 25, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
guys plz help me im beginner for pic n im unable to get output
code :

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned int adc_rd;
#include <built_in.h>



char txt[11];
float temp;

//char txt1[] = "mikroElektronika";
//char txt2[] = "EasyPIC6";
//char txt3[] = "Lcd4bit";
//char txt4[] = "example";

char i;
void display()
{
TRISA = 0xFF ;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
adc_rd =ADC_read(2);
temp = adc_rd/200;



FloatToStr(temp, txt); // Cursor off
Lcd_Out(1,1,txt);
} // Loop variable



void main(){
ANSEL = 0x04; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
ADCON1 |= 0x0C; // Set AN2 channel pin as analog
// TRISA2_bit |= 0x04;

// _ADC_Init();

Lcd_Init(); // Initialize LCD



while(1) { // Endless loop

display();
}
}
 

https://sites.google.com/site/coole...0/tutorial-list/temperature-monitoring-system

Have a look at the above link..
Very Good Tutorial, but for PIC18F4550..

I am reading your code and will try to find any solution..
Till then then have a look at the above link..

Hope this helps

---------- Post added at 22:23 ---------- Previous post was at 22:20 ----------

Also have a look at this code, written in mikroC for PIC16F877A micro-controller, to display the adc_data as it is on LCD,

Code:
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

unsigned int adc_value;
unsigned char string[16];

void main()
{

 TRISB = 0x00;
 Lcd_Init();
 UART1_Init(9600);
 Delay_ms(100);
 Lcd_Cmd(_LCD_CLEAR);               // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
 Lcd_Out(1,1,"TESTING...");
 UART1_Write_Text("Arun Sharma");
 Delay_ms(1000);
 Lcd_Cmd(_LCD_CLEAR);
 TRISA = 0xFF;
 ADCON0 = 0x81;
//Fosc/64 is Selected
//Channel-0 is Selected
//Analog-to-Digital Converter Module is Powered Up
/*************************************************/
 ADCON1 = 0xCE;        //Only Channel One is Analog Channel while all others are Digital I/O
//A/D Result Format Select Bit Right Justified
//and AN0 Channel as Analog Channel
/***************************************************/
 ADC_Init();
 Delay_ms(100);
 Lcd_Out(1,1,"ADC OUTPUT");
 while(1)
 {
   adc_value = ADC_Read(0);
   IntToStr(adc_value,String);
   Lcd_Out(2,1,String);
   UART1_Write_Text("Arun Sharma");
   UART1_Write(10);
   UART1_Write(13);
   Delay_ms(1000);
 }
}

and in your code change these statement as follow :-

Code:
void display()
{
TRISA = 0xFF ;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
adc_rd =ADC_read(2);

IntToStr(adc_rd, txt); // Cursor off
Lcd_Out(1,1,txt);
} // Loop variable

First Check whether your ADC is working or not then try to get the data which you want

Hope this helps
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top