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 support@ccsinfo.com

Low energy consumption

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







Low energy consumption
PostPosted: Tue Oct 16, 2007 3:26 am     Reply with quote

Hi:

I'm new in programing with C, and I need to program a clock with timers. I read about this in the forum and I'm ok. With #INT_TIMER1 I have a clock. But I have a problem: I need to power the application with battery, then I need a very low energy consumption. I think to Sleep the Pic, but then TMR1 is stopped. How I can do it??

MkAd
Ttelmah
Guest







PostPosted: Tue Oct 16, 2007 4:36 am     Reply with quote

The fine details, depend on what chip is involved. However in general, Timer1, can be run from the system clock, or another source. What you do, is set the timer up, to run from a slow external crystal (typically 32768Hz, which is a standard 'watch' crystal). This can then stay running while the processor switches off. At this low frequency, the power consumption is tiny. Typically under 3uA, for the processor 'asleep', and the timer oscillator running - actual numbers will depend on the chip involved, but this is a 'real' figure for a fairly typical 'mid range' 18F chip at 3v.
You need to spend quite a bit of care, to ensure that consumption of other parts is as low as possible (which way lines should be left, ensure 'inputs', are not allowed to 'float' etc.).
Then at this sort of consumption, if you wake up (say) half a dozen times a minute, for a couple of hundred machine instructions, drawing perhaps 2mA, for 40uSec, the 'average' consumption becomes:
3uA + 0.002*40E-6*6 = 3.48uA.
Off (say), a typical lithium cell (CR2032, nominally 180mA/Hr), you then have a battery life, of over 50000Hrs. Typically in excess of 5 years.
The key is, keeping the consumption as low as possible in the 'off' periods, and ensuring these are as long as possible relative to the 'on' periods.

Best Wishes
MkAd
Guest







PostPosted: Tue Oct 16, 2007 8:51 am     Reply with quote

Thanks Ttelmah:

I'm working with a 16F946. I see the datasheet, and the tmr1 must be in asynchronous counter mode. This is T1CON.2=1 and T1CON.1=1. But I don't know where the external oscillator is. I can put this oscillator of 32k in RA6/OSC2-RA7/OSC1??

MkAd
Ttelmah
Guest







PostPosted: Tue Oct 16, 2007 9:32 am     Reply with quote

The pins used are OSC1, and OSC2. RA6, and RA7.
SETUP_TIMER1(T1_EXTERNAL | T1_CLK_OUT);
Just use a 32KHz watch crystal between the pins, with a suitable pair of capacitors (normally about 27pF will depend on the crystal specs, but these should work), to ground from the two pins.

Best Wishes
MkAd
Guest







PostPosted: Tue Oct 16, 2007 9:51 am     Reply with quote

thank you very much.

Now is running very fine.

Razz Razz Razz Razz
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