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 wrong with the circuit?

Status
Not open for further replies.
Joined
Jul 25, 2012
Messages
1,192
Helped
171
Reputation
342
Reaction score
162
Trophy points
1,343
Activity points
0
Hello!

The resistors connected to 555 should be 730 Ohms each, but if I make it 730 Ohms, the ADC doesn't work. If I make the resistor values 10K it works, but the adc readings are not correct on varying the temperature of LM35. What is the problem?

The code is like this

Code:
// LCD module connections
sbit LCD_RS at P3_0_bit;
sbit LCD_EN at P3_1_bit;

sbit LCD_D4 at P3_2_bit;
sbit LCD_D5 at P3_3_bit;
sbit LCD_D6 at P3_4_bit;
sbit LCD_D7 at P3_5_bit;
// End LCD module connections

#define ADC_SC P2_6_bit // set the start pin to P2_0
#define ADC_EOC P2_7_bit // set the End of Conversion to p2_1
#define ADC_OE P2_5_bit // set the output enable to p2_2
#define ADC_ALE P2_4_bit // aet the Adress Latch Enable to P2_4
#define ADD_A P2_2_bit
#define ADD_B P2_1_bit
#define ADD_C P2_0_bit
#define ADC_DATA P1 // set the 8-bit data to p0 port.

void adc_init();
unsigned char adc_getdata();

double d_adc_val;
unsigned char getdata, adc_val;
char str_adc_val[17];
char txt1[] = "A Project by";
char txt2[] = "Smitha B T";

/*---------------------------------------------------------------------
Initialize the adc
         void adc_init();
---------------------------------------------------------------------*/
void adc_init() //
{
  ADC_EOC = 1;
  //P1 = 0xFF;
  ADC_ALE = 0;
  ADC_OE = 0;
  ADC_SC = 0;
  ADD_A = 0;
  ADD_B = 0;
  ADD_C = 0;
  Delay_ms(2);
}

/*---------------------------------------------------------------------
Get the data from ADC
        unsigned char adc_getdata(void);
---------------------------------------------------------------------*/
unsigned char adc_getdata()
{

   ADC_ALE = 1;                // enable ALE
   Delay_ms(2);
   ADC_SC = 1;                 // Start the ADC conversion
   Delay_ms(1);
   ADC_ALE = 0;
   Delay_ms(1);
   ADC_SC = 0;
   Delay_ms(1);
                               // Waiting for Conversion end
   while(ADC_EOC == 1);
   while(ADC_EOC == 0);
       ADC_OE = 1;             // set the Output Enable
       Delay_ms(1);
       getdata = ADC_DATA;     // Get the ADC data
       ADC_OE = 0;             // clear the Output Enable

   return getdata;
}

void main(){

  Lcd_Init();                                    // Initialize LCD

  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  Lcd_Cmd(_LCD_CURSOR_OFF);                      // Cursor off
  LCD_Out(1,3,txt1);                             // Write text in first row
  LCD_Out(2,4,txt2);                             // Write text in second row
  Delay_ms(2000);                                // 3 sec delay
  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  
  adc_init();

  while(1) {
           adc_val = adc_getdata();  // read adc input and assign the value to adc_val
           d_adc_val = adc_val * 0.588235524798245;
           FloatToStr(d_adc_val, str_adc_val);   // convert adc_val to string
           Lcd_Out(1,3,"Temperature");           //
           Lcd_Out(2,3,str_adc_val);             // Display adc value
  }
}
 

Attachments

  • 0808.rar
    40.5 KB · Views: 95

Check this. I think you tried with 0808.dsn thats why you didn't see the adc value.
 

Attachments

  • 0808_lm35_89c51.rar
    22.6 KB · Views: 90

the problem is with the simulation times. the 500 khz makes the proteus simulation step too low. check the proteus simulation time at the lower left of the proteus window (the messages). the time step is too slow there.
you can make a divider circuit using flipflops. ie 11.092 Mhz /4 and then divide that by 16. then feed it to the clock input. data sheet recommends 500 khz, but that will do just fine.
and this is a big head ache here
Code:
 d_adc_val = adc_val * 0.588235524798245;
           FloatToStr(d_adc_val, str_adc_val);   // convert adc_val to string

is the compiler mikro C pro?
 
Yes. I am using mikroC PRO 8051. Can you show me how to do the clock circuit? I Changed the circuit. It is not working.
 

Attachments

  • 0808_2.rar
    24.1 KB · Views: 89
Last edited:

you can try, but the simulation step will not budge. can you use something like this
FloatToStr(d_adc_val, str_adc_val); // convert adc_val to string
ie directly convert that to string and then see the result.
 
Last edited:
500 khz is enough.
555 timer timer cap : 1nf
R1 : 1k (b/w Vcc and pin 7)
R2 : 1.5k
can you compile with this code, i dont have mikro C pro for C51 with me.
Code:
// LCD module connections
sbit LCD_RS at P3_0_bit;
sbit LCD_EN at P3_1_bit;

sbit LCD_D4 at P3_2_bit;
sbit LCD_D5 at P3_3_bit;
sbit LCD_D6 at P3_4_bit;
sbit LCD_D7 at P3_5_bit;
// End LCD module connections

#define ADC_SC P2_6_bit // set the start pin to P2_0
#define ADC_EOC P2_7_bit // set the End of Conversion to p2_1
#define ADC_OE P2_5_bit // set the output enable to p2_2
#define ADC_ALE P2_4_bit // aet the Adress Latch Enable to P2_4
#define ADD_A P2_2_bit
#define ADD_B P2_1_bit
#define ADD_C P2_0_bit
#define ADC_DATA P1 // set the 8-bit data to p0 port.

void adc_init();
unsigned char adc_getdata();

int d_adc_val;
unsigned char getdata, adc_val;
char str_adc_val[17];
char txt1[] = "A Project by";
char txt2[] = "Smitha B T";

/*---------------------------------------------------------------------
Initialize the adc
         void adc_init();
---------------------------------------------------------------------*/
void adc_init() //
{
  ADC_EOC = 1;
  //P1 = 0xFF;
  ADC_ALE = 0;
  ADC_OE = 0;
  ADC_SC = 0;
  ADD_A = 0;
  ADD_B = 0;
  ADD_C = 0;
  Delay_ms(2);
}

/*---------------------------------------------------------------------
Get the data from ADC
        unsigned char adc_getdata(void);
---------------------------------------------------------------------*/
unsigned char adc_getdata()
{

   ADC_ALE = 1;                // enable ALE
   Delay_ms(2);
   ADC_SC = 1;                 // Start the ADC conversion
   Delay_ms(1);
   ADC_ALE = 0;
   Delay_ms(1);
   ADC_SC = 0;
   Delay_ms(1);
                               // Waiting for Conversion end
   while(ADC_EOC == 1);
   while(ADC_EOC == 0);
       ADC_OE = 1;             // set the Output Enable
       Delay_ms(1);
       getdata = ADC_DATA;     // Get the ADC data
       ADC_OE = 0;             // clear the Output Enable

   return getdata;
}

void main(){

  Lcd_Init();                                    // Initialize LCD

  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  Lcd_Cmd(_LCD_CURSOR_OFF);                      // Cursor off
  LCD_Out(1,3,txt1);                             // Write text in first row
  LCD_Out(2,4,txt2);                             // Write text in second row
  Delay_ms(2000);                                // 3 sec delay
  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  
  adc_init();

  while(1) {
           adc_val = adc_getdata();  // read adc input and assign the value to adc_val
           IntToStr(adc_val, str_adc_val);   // convert adc_val to string
           Lcd_Out(1,3,"Temperature");           //
           Lcd_Out(2,3,str_adc_val);             // Display adc value
  }
}
 
I checked with the values of C, R1 and R2. Nothing appears on the screen. I am uploading the hex file for your code. With the value of 10k, 10k and 0.11u The 555 works otherwise I get a blank screen.
 

Attachments

  • adc0808_hex.rar
    1.3 KB · Views: 81

reduce the delay.. can you compile?
Code:
// LCD module connections
sbit LCD_RS at P3_0_bit;
sbit LCD_EN at P3_1_bit;

sbit LCD_D4 at P3_2_bit;
sbit LCD_D5 at P3_3_bit;
sbit LCD_D6 at P3_4_bit;
sbit LCD_D7 at P3_5_bit;
// End LCD module connections

#define ADC_SC P2_6_bit // set the start pin to P2_0
#define ADC_EOC P2_7_bit // set the End of Conversion to p2_1
#define ADC_OE P2_5_bit // set the output enable to p2_2
#define ADC_ALE P2_4_bit // aet the Adress Latch Enable to P2_4
#define ADD_A P2_2_bit
#define ADD_B P2_1_bit
#define ADD_C P2_0_bit
#define ADC_DATA P1 // set the 8-bit data to p0 port.

void adc_init();
unsigned char adc_getdata();

int d_adc_val;
unsigned char getdata, adc_val;
char str_adc_val[17];
char txt1[] = "A Project by";
char txt2[] = "Smitha B T";

/*---------------------------------------------------------------------
Initialize the adc
         void adc_init();
---------------------------------------------------------------------*/
void adc_init() //
{
  ADC_EOC = 1;
  //P1 = 0xFF;
  ADC_ALE = 0;
  ADC_OE = 0;
  ADC_SC = 0;
  ADD_A = 0;
  ADD_B = 0;
  ADD_C = 0;
  Delay_ms(2);
}

/*---------------------------------------------------------------------
Get the data from ADC
        unsigned char adc_getdata(void);
---------------------------------------------------------------------*/
unsigned char adc_getdata()
{

   ADC_ALE = 1;                // enable ALE
   Delay_ms(2);
   ADC_SC = 1;                 // Start the ADC conversion
   Delay_ms(1);
   ADC_ALE = 0;
   Delay_ms(1);
   ADC_SC = 0;
   Delay_ms(1);
                               // Waiting for Conversion end
   while(ADC_EOC == 1);
   while(ADC_EOC == 0);
       ADC_OE = 1;             // set the Output Enable
       Delay_ms(1);
       getdata = ADC_DATA;     // Get the ADC data
       ADC_OE = 0;             // clear the Output Enable

   return getdata;
}

void main(){

  Lcd_Init();                                    // Initialize LCD

  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  
  adc_init();

  while(1) {
           adc_val = adc_getdata();  // read adc input and assign the value to adc_val
           IntToStr(adc_val, str_adc_val);   // convert adc_val to string
           Lcd_Out(1,3,"Temperature");           //
           Lcd_Out(2,3,str_adc_val);             // Display adc value
  }
}
 
Yes. I compiled.
 

Attachments

  • adc0808_hex2.rar
    1.3 KB · Views: 91

can you compile?
Code:
// LCD module connections
sbit LCD_RS at P3_0_bit;
sbit LCD_EN at P3_1_bit;

sbit LCD_D4 at P3_2_bit;
sbit LCD_D5 at P3_3_bit;
sbit LCD_D6 at P3_4_bit;
sbit LCD_D7 at P3_5_bit;
// End LCD module connections

#define ADC_SC P2_6_bit // set the start pin to P2_0
#define ADC_EOC P2_7_bit // set the End of Conversion to p2_1
#define ADC_OE P2_5_bit // set the output enable to p2_2
#define ADC_ALE P2_4_bit // aet the Adress Latch Enable to P2_4
#define ADD_A P2_2_bit
#define ADD_B P2_1_bit
#define ADD_C P2_0_bit
#define ADC_DATA P1 // set the 8-bit data to p0 port.

void adc_init();
unsigned char adc_getdata();

int d_adc_val;
unsigned char getdata, adc_val;
char str_adc_val[17];
char txt1[] = "A Project by";
char txt2[] = "Smitha B T";

/*---------------------------------------------------------------------
Initialize the adc
         void adc_init();
---------------------------------------------------------------------*/
void adc_init() //
{
  ADC_EOC = 1;
  //P1 = 0xFF;
  ADC_ALE = 0;
  ADC_OE = 0;
  ADC_SC = 0;
  ADD_A = 0;
  ADD_B = 0;
  ADD_C = 0;
  Delay_ms(2);
}

/*---------------------------------------------------------------------
Get the data from ADC
        unsigned char adc_getdata(void);
---------------------------------------------------------------------*/
unsigned char adc_getdata()
{

   ADC_ALE = 1;                // enable ALE
   Delay_ms(2);
   ADC_SC = 1;                 // Start the ADC conversion
   Delay_ms(1);
   ADC_ALE = 0;
   Delay_ms(1);
   ADC_SC = 0;
   Delay_ms(1);
                               // Waiting for Conversion end
   while(ADC_EOC == 1);
   while(ADC_EOC == 0);
       ADC_OE = 1;             // set the Output Enable
       Delay_ms(1);
       getdata = ADC_DATA;     // Get the ADC data
       ADC_OE = 0;             // clear the Output Enable

   return getdata;
}

void main(){

  Lcd_Init();                                    // Initialize LCD

  Lcd_Cmd(_LCD_CLEAR);                           // Clear Display
  
  adc_init();

  while(1) {
           adc_val = adc_getdata();  // read adc input and assign the value to adc_val
           adc_val = adc_val *100;
           IntToStr(adc_val, str_adc_val);   // convert adc_val to string
           Lcd_Out(1,3,"Temperature");           //
           Lcd_Out(2,3,str_adc_val);             // Display adc value
  }
}
 
The voltage between Vref + and GND should be 2.5 V, but it is showing 1.25 V. Why?
 

i recon use a pot for the V+ ref

- - - Updated - - -

i compiled the code with keil uvision too. but of no use. the same result both ways
.
Code:
#include<reg51.h>
sbit ale=P2^4;  
sbit oe=P2^5;  
sbit sc=P2^6;  
sbit eoc=P2^7; 
sbit ADD_A=P2^2; 
sbit ADD_B=P2^1;
sbit ADD_C=P2^0;


void delay(unsigned int count) 
{
int i,j;
for(i=0;i<count;i++)
  for(j=0;j<1275;j++);
}

void main()
{
eoc=1;
P1=0xFF;
ale=0;
oe=0;
sc=0;
while(1)
{
  ADD_C=0; 
  ADD_B=0;
  ADD_A=0;
  delay(2);
  ale=1;
  delay(2);
  sc=1;
  delay(1);
  ale=0;
  delay(1);
  sc=0;
  while(eoc==1);
  while(eoc==0);
  oe=1;
  P3=P1;
  delay(2);
  oe=0;
}
}

- - - Updated - - -

i think solved your problem. run this ;)
View attachment Magvitron.zip

- - - Updated - - -

hellow.....?
 
Can you upload the hex file you got compiling in uVision? Was the ports of ADC inverted in proteus?
 

Thank you. Can you tell me how to generate 640KHz Clock. I think the problem is with the timing? Isn't it?
 

no you just reversed the connections that's all. the timing cannot be done by using 555, maximum freq is ≈ 500 kHz, for that, use something like this (in real time applications)

0808.gif

the problem with simulation is that it takes a whole lot long to simulate the 640 MHz timing. So, its kind of impractical. did you see the simulation?

Untitled.jpg
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top