CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

disabling enabling ADC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

disabling enabling ADC
PostPosted: Tue May 17, 2005 7:38 am     Reply with quote

Hi..

it is true that the PIC comsumes less power when the ADC is disabled.

By stating this:

setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel( 0 );

Are you enabling the ADC (and consuming more power)?
Is it better ONLY to enable the ADC pheripheral when needed and disable when you've done using it?

About output impedance:

Vbat (0 - 5V)
|
100k
|
*--------------- AN0
|
150k
|
GND

What is the output impedance? And what should the adc setup be? (time necessary for C to be loaded with voltage is important)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 17, 2005 1:39 pm     Reply with quote

It depends upon what PIC you're using.

If you use a modern "Nanowatt" technology PIC, the A/D uses almost
nothing when it's turned on (but not converting).

Example:
The 16F88 running at 5v, uses a typical 3 nA when it's on, but not
converting. This number is from section 18.2 of the data sheet.

That's practically nothing.
cmdrdan



Joined: 08 Apr 2005
Posts: 25
Location: Washington

View user's profile Send private message

PostPosted: Tue May 17, 2005 6:00 pm     Reply with quote

Christophe --

Your source impedance is the Thevenin equivalent resistance of the voltage divider, in this case 60k ohms. Unless you're running the part from less than 5 volts, the voltage divider isn't necessary....
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Wed May 18, 2005 1:13 am     Reply with quote

Well I am using PIC16LF877A @3V (Vdd)
So is that using nanowatt technology?

PIC16LF87XA — 90 — μA

How can you turn the interface on and off?

do_adc {

put_on (adc) //how?

...

put_off (adc) // how?

return (..)

}


My settings are:

setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_INTERNAL);

I only use AN0 and AN1 as analog inputs; with these settings AN3 is also an analog input; and I want to use it as a digital input..


Last edited by Christophe on Wed May 18, 2005 1:39 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 18, 2005 1:38 am     Reply with quote

Quote:
Well I am using PIC16LF877A @3V (Vdd)
So is that using nanowatt technology?

No. If it's nanowatt, it will say so on the first page of the data sheet.
Like this:
Quote:
PIC16F87/88
Data Sheet
18/20/28-Pin Enhanced Flash
Microcontrollers with
nanoWatt Technology


Quote:
How can you turn the interface on and off?

Look in the CCS manual. The section on the setup_adc() function
says this:
Quote:
Some typical options include:
• ADC_OFF
• ADC_CLOCK_INTERNAL
• ADC_CLOCK_DIV_32


So, to turn it on, you do this:
Code:
setup_adc(ADC_CLOCK_DIV_32);

To turn it off you do this:
Code:
setup_adc(ADC_OFF);
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Wed May 18, 2005 1:40 am     Reply with quote

Thank you very much,

so when it's off, I can use the pins again as digital i/o ?

edit:

by stating this:

setup_adc_ports(AN0_AN1_AN3);

and the ADC is off, can I use A0 A1 and A3 as digital i/o ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 18, 2005 2:04 am     Reply with quote

Quote:

so when it's off, I can use the pins again as digital i/o ?
setup_adc_ports(AN0_AN1_AN3);

No. That statement configures AN0, 1, and 3 as analog.

You have to configure them as digital with this statement:
setup_adc_ports(NO_ANALOGS);
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Wed May 18, 2005 2:36 am     Reply with quote

PCM,

can you confirm the following code:

Code:


//****************************************************************************//
//Meten Adapterspanning
//Vadap = (82+150)/150*waarde*3/255
int8 meet_Vadap()
{
   int8 waarde = 0;
   if (!input(POWER_GOOD))
   {
      setup_adc_ports(AN0_AN1_AN3);
      setup_adc(ADC_CLOCK_DIV_32);
      set_adc_channel( 1 );
      delay_us(5);
      waarde = read_adc();
      setup_adc(ADC_OFF);
      setup_adc_ports(NO_ANALOGS);
      return waarde;
   }

   else
      {
      waarde = 0;
      return waarde;
      }
}



thank you

edit: seems to be not working;
after setup_adc_ports(NO_ANALOGS);
How is the A-port set up? (by means the power-good pin)

edit: I solved the problem; after setup_adc_ports(NO_ANALOGS); you HAVE to reset your pins as inputs..
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group