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.

What is the problem with the following code?

Status
Not open for further replies.
Joined
Apr 8, 2012
Messages
201
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
0
In my circuit LM35 is connected to ADC0804 and o/p of ADC 0804 (D0-D7) is connected to P0 of 89S52.
WR of 0804 is connected to P3.6, RD of 0804 to P3.7 and INTR of 0804 to P3.2. The following code is giving some 13.9999 as the output. What is wrong in the code. I'm trying to read LM35 into ADC 0804 and then place the o/p of 0804 @ P0 of 89S52, and then display P0 value on lcd.

Code:
[syntax = mikroC]

#define high 1;
#define low 0;

// LCD module connections
sbit LCD_RS at P3_4_bit;
sbit LCD_EN at P3_5_bit;

sbit LCD_D4 at P2_4_bit;
sbit LCD_D5 at P2_5_bit;
sbit LCD_D6 at P2_6_bit;
sbit LCD_D7 at P2_7_bit;
// End LCD module connections

int temp_limit;
float adc_val;
char myStr[23];

void main() {
     Lcd_Init();
     Lcd_Cmd(_LCD_CURSOR_OFF);
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"89S52 and LM35 Based");
     Lcd_Out(2,1,"Temperature Monitor");
     delay_ms(2000);
     Lcd_Cmd(_LCD_CLEAR);
     temp_limit = 27;
     
     do {// Function for A-D conversion
        P3_6_bit = low;                 //WR = 0
        P3_6_bit = high;                //WR = 1
        if (P3_2_bit == 0) {            //INTR of 0804 = 0?
        P3_7_bit = low;                 //RD = 0
        adc_val = P0;                   //0804 [D0-D7] = P0 [89S52]
        }
        FloatToStr(adc_val, myStr);
        Lcd_Out(2,1,myStr);
     
        if (adc_val > temp_limit) {
            P1_1_bit = 1;
        }
        else {
            P1_1_bit = 0;
        }
     } while(1);
}

[/SYNTAX]
 

Calculation:

**broken link removed**



Log on to this site and see whole project, code is on code tab :

**broken link removed**
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top