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.

89s52 consumes more power

Status
Not open for further replies.
Hi,

Do you have a known resistor of 200...300 ohms and validate measurement reading?
Code us still missing. I don't know why. It seems to be top secret how you set the microcontroller in idle mode.

Klaus
 

no its broken.... if it would be broken.... the display would show me 00.00 and not 1
 

Hi,

Your test circuit:
For testing the current consumption you need to build the same situation like in the darasheet.
I don't know your microcontroller, but most likely you need:
* to connect all Vcc and all gnd lines
* connect bypass and bulk capacitors between VCC and gnd.
* need a valid setup for the reset input
* need capacitors for the xtal circuit.

Klaus
 

no klausST... there's nothing a top secret...
here's my code...
Code:
#include<reg51.h>
#include<stdio.h>
#include<avrio.h>
#include<keypad.h>
sfr ROW=0x80;	//assigning PORT-0 to read rows
sfr COL=0xA0;	//assigning PORT-2 to read colomns
sfr ldata=0x90;	//assigning PORT-1 for LCD data
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sbit busy=P1^7;

void lcdcmd(unsigned char value) ;
void lcddata(unsigned char value);
void lcdready(void)	   ;
void printstring(unsigned char ch[]) ;
void LCDclear(void);
void msdelay(unsigned int value)  ;
int keypad();
void timer(unsigned int msec);
	
void main()
{	
     unsigned int i,k;
	 lcdcmd(0x38);
     lcdcmd(0x0F);
     lcdcmd(0x06);
     lcdcmd(0x01);
	 while(1)                
    {	
                 P0=0xff;
		 P1=0xff;
                 P2=0xff;
		 P3=0xff;
		 PCON |= 0x01;
	     do
	   		 {
		      k=keypad();
			 }
		 
	         while(k!='A');
		     switch(k)
			    {
				  case 'A' :while(1) 											//CASE 1
				    {
		 	         printstring("idle mode exited");
					 msdelay(200);
					 main();
					}
}	 
}}
 /* sending commands to  LCD display to act in command mode */ 
void lcdcmd(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=0;
 rw=0;
 en=1;
 msdelay(10);
 en=0;
 }
 /* sending commnad to LCD to display characters*/
void lcddata(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=1;
 rw=0;
 en=1;
 msdelay(10);
 en=0;
 }
 /* checking LCD buffer for free */
void lcdready(void)
{
busy=1;
 rs=0;
 rw=1;
 if(busy==1)
  {
   en=0;
   msdelay(1);
   en=1;
  }
}

void printstring(unsigned char ch[])
{
 unsigned int i;
 for(i=0;ch[i]!='\0';i++)
 lcddata(ch[i]);
 }
/* generating delay*/
void msdelay(unsigned int value)
{
 unsigned int i,j;
 for(i=0;i<value;i++)
 for(j=0;j<500;j++);
 }

 void locklong(unsigned int value)
{
 unsigned int i,j;
 for(i=0;i<value;i++)
 for(j=0;j<10000;j++);
}

void LCDclear(void)
 {
  lcdcmd(0x01);
  }
int keypad() 
 {
   unsigned char dat[4][4]={'1','2','3','A',	 // assigning key matrix
                            '4','5','6','B',
						    '7','8','9','-',
						    'C','0','=','+',
						   };
 unsigned char colloc,rowloc;
 COL=0xFF;
 ROW=0x00;
 rs=0;
 rw=0;
 en=0;
 busy=0;
  /* setting LCD screen*/ 
 ldata=0x00;
 lcdcmd(0x38);
 lcdcmd(0x0E);
 lcdcmd(0x06);

 while(1)
 {
/* reading character from keyboard */
   do
   {
    ROW=0x00;
   	colloc=COL;
	colloc&=0x0F;
	}while(colloc!=0x0F);
	do
	{
	 do
	 {
	  msdelay(10);
	  colloc=COL;
	  colloc&=0x0F;
	  }while(colloc==0x0F);
	  msdelay(10);
	  colloc=COL;
	  colloc&=0x0F;
	  }while(colloc==0x0F);
    while(1)
	{
	 ROW=0xFE;	  msdelay(5);
	 colloc=COL;
	 colloc&=0x0F;
	 if(colloc!=0x0F)
	 { 
	  rowloc=0;
	  break;
	  }
	  ROW=0xFD;	  msdelay(5);
	  colloc=COL;
	  colloc&=0x0F;
	   if(colloc!=0x0F)
	   {
	    rowloc=1;
		break;
		}
	  ROW=0xFB;		msdelay(5);
	  colloc=COL;
	  colloc&=0x0F;
	   if(colloc!=0x0F)
	   {
	    rowloc=2;
		break;
		}
	  ROW=0xF7;		  msdelay(5);
	  colloc=COL;
	  colloc&=0x0F;
	if(colloc!=0x0F)
	  {  
	      rowloc=3;
	      break;
	    }
	   }
   if(colloc==0x0E)
   return(dat[rowloc][0]);
   else if(colloc==0x0D)
   return(dat[rowloc][1]);
   else if(colloc==0x0B)
   return(dat[rowloc][2]);
   else
    return(dat[rowloc][3]);
	}
	}
 void timer(unsigned int msec)     // Function for timer
{
unsigned int i;
for(i=0;i<msec;i++)
{
TMOD=0x20;         // Mode2
TH1=0xD1;
TL1=0xFF;

TR1=1;
while(TF1==0);
TF1=0;
TR1=0;
}
}
 

Hi Klaus.... is my code proper.... or do i need to change anything.....
 

Hi,

Hi Klaus.... is my code proper.... or do i need to change anything.....
As said before i`m not familiar with your controller.

But there should be a lot of experieced users to help you with this code.

***
From what I see, from a quick view:
* I can´t see ALL ports to be configured. direction and state.
* I ´don´t know wich periferals you need and what periferals need to be switched OFF
* I´m a bit confused about two "while (1)" loops. I don´t know if this is correct
* just to check power consuption: I´d reduce the code to a minimum. No LCD, no keypad, no timer ... code.

Make it simple and focussed.

Klaus
 

i have even stimulated using Proteus. its work well.... all the port get low as well as it enters the idle mode. i am sure because as u can see the code... on keypress A it prints Exited idle mode on lcd... but when i press A it doesn't prints anything on lcd due to idle mode. if it would not had enter idle mode it would has easily print the text on lcd. so in that case i am sure that it has entered idle mode. but why does it consumes so much current even in idle as well as active mode. do xtal play a big role in balancing the current. do changing the xtal value..... say 6 or 8MHz will lesser the consumption of current. and also even confused why my microcontroller does not get hot when it consumes more than 200ma as u said it get hot at even 150ma.....
dont know where the problem is....
do u have any other way out then please let me know....
 

Hi,

i have even stimulated using Proteus. its work well.... all the port get low
Yesyou say it is low. But i am still unsure. It makes a big difference in current consuption whether the pin is truely LOW or HIGH IMPEDANCE.
In both cases if you measure the voltage agains GND it will show 0V. !!! Again. it makes a big difference.
*****
because as u can see the code... on keypress A it prints Exited idle mode on lcd...
Sorry. Only you can see what is printed on the LCD.
(although i doubt you can see this, because I can´t find any connectins on your breadboard picture)
****

I still don´t trust the current measurement. Again, did you verify the current reading with a known resistor?. If not, please do this, because if the current reading is wrong we don´t need to discuss further.
***

For sure the XTAL frequency has influence on the current consumption. Read datasheet.

Klaus
 

I still don´t trust the current measurement. Again, did you verify the current reading with a known resistor?. If not, please do this,
Klaus

How can i verify with known resistor....
how can i do this
 

Hi,

Just use Ohms law:

If you have a 4.8V voltage (are you sure it truely is 4.8V, or is this the "nominal value"?) and connect a 200 ohms resistor and your current meter in series, then:

R = U / I
-->
I = U / R = 4.8V / 200Ohms = 24mA.

This should be the reading of your measurement tool (with some tolerance).

Klaus
 

Hi,

Just use Ohms law:

If you have a 4.8V voltage (are you sure it truely is 4.8V, or is this the "nominal value"?) and connect a 200 ohms resistor and your current meter in series, then:

R = U / I
-->
I = U / R = 4.8V / 200Ohms = 24mA.

This should be the reading of your measurement tool (with some tolerance).

Klaus

yes i have done so...
but the result i get 72ma.
i have even added 33pf capacitor as per the datasheet.
 

Hi,

yes i have done so...
but the result i get 72ma.
So your current meter shows garbage.
We wasted a long time dicussing about "wrong values"!

Klaus
 

Hi,

Just use Ohms law:

If you have a 4.8V voltage (are you sure it truely is 4.8V, or is this the "nominal value"?) and connect a 200 ohms resistor and your current meter in series, then:

R = U / I
-->
I = U / R = 4.8V / 200Ohms = 24mA.

This should be the reading of your measurement tool (with some tolerance).

Klaus

i am sending you the pic of 89S52 connected in my circuit and the amp reading.

- - - Updated - - -



- - - Updated - - -

is it my multimeter showing wrong values...????

- - - Updated - - -

but i have got the new one from eBay one month back....:-:)-:)-:)-(

- - - Updated - - -

if my multimeter is showing a wrong value.... then why my 7.4v 2200mah battery gets drained in 14-15 hours and 4.8v 800mah battery in 4-5 hours.
 

Step 1: Check resistor value with meter, is it 200 ohms? (write down the resistor value)
Step 2: Using battery connect resistor in series with it. (no other loads just the resistor across the battery), measure the voltage across the resistor, it should be around the 4.8 V as it's not loaded that heavily (write down this voltage)
Step 3: Connect the battery, resistor, and meter in series. What does the meter read is it the same as the value of Written_voltage/written_resistor?
If not it's reading the wrong value for the current.

You should be aware that the meter you are using has no protection on the current setting at all (just look that meter up on google). So if it's been subjected to current spikes it may have already been damaged.
 

Hi







24mA is by far not thae same as 72mA.

Something is wrong.

Klaus

Yes KlausST.... you were right.....
my multimeter was showing a wrong value.... so i brought a new one.... now i think am getting a proper value.....
so now i again need a small help from you....
when my microconroller gets to active mode it consumes 7.65mA and when its in IDLE mode it consumes only 1.48mA. so i want to set my microcontroller to idle mode when not in use....
so i wrote the code PCON |=0x01; which makes my 89s52 enter idle mode. but the issue is how to exit idle mode.... i am not aware of it... can you please help me with the code....
i want my micocontroller to exit idle mode when keypress is made. so can you help me in this case
 

Hi,

but the issue is how to exit idle mode.... i am not aware of it... can you please help me with the code....
As said before i´m not familiar with your microcontroller.

To answer your question I need to read the datasheet, but it makes more sense that you read the datasheet.

I´m very sure there is a section about "power down" or "power saving" or "idle mode"...
Use the pdf reader´s search function.
****

Usually you must
* select the wakeup (exit from idle) source
* prepare the idle state
* enter the idle state
... at this time the processing stops; until there is the wakeup condition
* then the program resumes with the next folowing code.
****

You may also use internet search to find code for power down features.
****

Klaus
 

As said before i´m not familiar with your microcontroller.

To answer your question I need to read the datasheet, but it makes more sense that you read the datasheet.

Read the 38 pages of this, don't expect forum members to read it to you.
 

yes am bit aware of idle mode.... in idle mode, the microcontroller turns off the greatest power consumer-CPU unit while peripheral units such as serial port, timers.
as it is written.... to exit idle mode i have to enable or execute any interrupt.... but not aware... what kind of i interrupt.... gone through the datasheet even before.... but nothing helped me....

- - - Updated - - -

what is interrupt..... and how can i do it...

- - - Updated - - -

atleast give me some basic idea... or explanation about it...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top