View previous topic :: View next topic |
Author |
Message |
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
PIC XTAL and CPU clock reduction |
Posted: Mon Jan 11, 2016 7:57 am |
|
|
Dear board
I've 16F72 PIC connected to 4Mhz XTAL, and i saw datasheet that says the uC can operate much less currents, 20uA at 32Khz.
Now I'm wondering if i can do something to bring down the clock to 32Khz without touching the HW.
Can someone suggest me if i can do this, or can someone say power saving tips?
--------------------------
Actual project is wireless overhead water tank level monitoring.
I use 16F72 + NRF24l01 (12mA typical operation) (sleep current uA) powered by CR2032....
I keep NRF in sleep when no update required so no power consumption. Periodically every 5 sec I've to send the water level status. So, i run a timer continuously in PIC (today my uC is taking 50mA which is too much). I need to see all possible ways to reduce the power.
Thank you |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon Jan 11, 2016 8:18 am |
|
|
some points...
#1 Use the L version! The F version is NOT rated for 3 volt operation according to page 88, figure 14-1.
#2 set every I/O pin as output, do not 'float' them.
#3 disable any peripherals on all I/O pins, some are default ON (like ADC).
#4 use high value pullups/pulldown.
Now, while 32KHz can possibly reduce power consumption you should read the Microchip application note about it. Only 8-10 pages but FULL of real analysis of 'how-to-do-it'!
You need to know that running at 32Khz might actually cost you more energy. If left in 32KHz ALL operations are 125 times longer! Power is consumed on the hi-lo transitions, and there's the time to switch from 32KhZ to 4 MHz, doing 'stuff', then powering down. All factor into overall power use.
Frankly it's a whole lot simpler and much more reliable to use a BIGGER battery. Coin cells are NOT great at cold weather operation, life gets cut in 1/2 to 1/3rd! Anything battery powered needs big, reliable power.
I'm sure others will add to 'the list'.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Jan 11, 2016 8:52 am |
|
|
Some other comments:
The F72, is a very old chip (about 10 years old...). Most more modern equivalents, have lower current at the same speed, and the newer versions will almost all (I can't think of one that doesn't), offer an internal low accuracy slower clock available to 'switch to' if needed.
A chip like the 1782, is cheaper, has several extra peripherals (USART, op-amps, an internal 32K clock etc.).
However 90% of your power is being drawn by something else. The PIC at 4Mhz, only draws typically less than 1mA. If you are seeing 12mA being drawn then something else is involved. Points 2, 3 & 4 above, but also have you got any form of voltage regulator involved?. If so look carefully at this.... |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
dears thanks for the reply |
Posted: Mon Jan 11, 2016 9:43 am |
|
|
dears thanks for the kind replies
#1 But my PIC is working good with 2.8V without using L version
#2 i did not set all as Output.. instead i have directly connected unused few to GND and few pins to +V directly. (will there be some problem)??
#3 can u suggest me what is disabling all IO pins?
#4 i dont use pull ups instead i connected all directly to power supplies same as point 2
ok... then i will not use 32Khz... and i will upgrade to 2AA batteries... beyond i cant go because my NRF chip will not withstand more than 3.6V (if i plan for 3AA then i have to use zener for regulating for my wireless chip 12mA typical.. this will also dissipate more current again i think)
and regarding 16F1782 i will check for the availability.. and No i dont have any voltage regulator involved...
thank you both for the suggestions |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
Re: dears thanks for the reply |
Posted: Mon Jan 11, 2016 10:11 am |
|
|
mutthunaveen wrote: | dears thanks for the kind replies
#1 But my PIC is working good with 2.8V without using L version
#2 i did not set all as Output.. instead i have directly connected unused few to GND and few pins to +V directly. (will there be some problem)??
#3 can u suggest me what is disabling all IO pins?
#4 i dont use pull ups instead i connected all directly to power supplies same as point 2
ok... then i will not use 32Khz... and i will upgrade to 2AA batteries... beyond i cant go because my NRF chip will not withstand more than 3.6V (if i plan for 3AA then i have to use zener for regulating for my wireless chip 12mA typical.. this will also dissipate more current again i think)
and regarding 16F1782 i will check for the availability.. and No i dont have any voltage regulator involved...
thank you both for the suggestions |
1) Luck.....
Remember the manufacturers specified voltages are for the specified temperature range. Don't be surprised if the chip suddenly stops working if you move away from 'room temperature'. They'll often work well below their rating at temperatures like 20C, but not when you get nearer to the limits. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon Jan 11, 2016 11:15 am |
|
|
1) luck... REAL LUCKY!!!
2) Would have to read the datasheet but I'd probably configure tham as inputs and tie to ground. Reading the manual should explain which will give lowest quiescent curent draw...
3) these days an I/O pin can have several peripherals 'attached' to it. A single pin may have 5-6 'options' for it's use.Most PICs with ADC peripheral will default those pins for ADC use not digital I/O use.PICs have UARTS,Comparators, ADC, CCP,etc. the list gets longer every day ! You need to disable( disconnect) all peripherals to get the lowest power.
4) this should be OK.....
5) You could use a Li-MH battery. 3 volts, putting 2 in PARALLEL will give unit extended operatiing time.
6) Orginally you said you're reading a water sensor every 5 seconds. Is this really necessary? without knowing details of the project , maybe reading every 10 seconds is safe? What abouut once per minute? Do some testing...if once per 30 seconds is 'safe' then you've eliminated5 wakeup-read-transmit-goto sleep cycles. That WILL save energy !!
7) PIC selection. I like to use a 'bigger' PIC than necessary. Often the version with more Flash, RAM, peripherals is CHEAPER than the first choice! Also you can reuse the PIC for future projects,have a 'libray' of code that works and well...you always need for pins, ram, etc. !
Jay |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
yes... |
Posted: Tue Jan 12, 2016 2:25 am |
|
|
yes.. for point 1 it might be a luck... i should not rely on it.
i will consider the interval also.. i prefer to have 5 for the moment and try to concentrate on possible power saving methods...
now im planning to goto nanowatt PICs that could take very very lesspower.. i will check for the availability in my area and if possible i will replace my PIC...
i need one answer.. and i dont know how to do it with ccs compiler....
how can i disable the pheriperals (UART, I2C, SPI ADC etc etc) to reduce further more power.?? is there any ccs c code to disable them or how to approach to it??
thank you board |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Jan 12, 2016 2:57 am |
|
|
Some are disabled by default. Data sheet tells you this.
However all the setup lines have disables available.
So (for example - for a whole suite of peripherals):
Code: |
setup_spi(FALSE); //disables the SPI
setup_timer_1(T1_DISABLED); //disables timer1
setup_ccp1(CCP_OFF); //disables CCP1
setup_pwm3(PWM_DISABLED); //for chips with ECCP PWM3
setup_uart(FALSE); //disables UART1
setup_vref(VREF_OFF); //disables a chip's VREF
setup_DAC(DAC_OFF); //disables an internal DAC
setup_adc(ADC_OFF); //disables the ADC
|
etc..
Look in the include file for the processor. Each has the 'off' define for each peripheral, or a note (so for the UART for example):
Code: |
// Constants used in setup_uart() are:
// FALSE - Turn UART off
// TRUE - Turn UART on
#define UART_ADDRESS 2
#define UART_DATA 4
#define UART_AUTODETECT 8
#define UART_AUTODETECT_NOWAIT 9
#define UART_WAKEUP_ON_RDA 10
#define UART_SEND_BREAK 13
|
This for a more complex UART than most. See the note about using TRUE/FALSE.
Read data sheet, and then the processor include file (this is always vital). |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
after all..... great help from you kind hearts |
Posted: Tue Jan 12, 2016 11:40 am |
|
|
Thanks for your great support.
I never used this kind of disabling codes.... as i never looked for power saving methods...
With all your guidance i think now in a right shape to figure out and cut the power consuming elements and make my project more efficient...
Thank you again.. do post here if there are some more efficient methods of power reduction... this could help all our board members in future.
Thank you dears. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Tue Jan 12, 2016 1:02 pm |
|
|
Interesting post, I'm in something similar.
Does somebody know if a floating ADC input consumes power even if it is not read?
I'm getting about 190µA with only timer 1 running at 32.768KHz in a PIC18F67J50. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Tue Jan 12, 2016 1:36 pm |
|
|
How is it 'floating'?. If it''s connected to something, this even if switched 'off' will normally pull the signal up or down. To be floating. it'd have to be physically disconnected.
Problem is that a floating input always has the danger of acting as a radio receiver. The internal FET in the input multiplexer (or any CMOS input), and the capacitor in the ADC will tend to integrate radio signals, and hence voltage will get generated The first problem this brings the risk of damage. It is far better/safer to ensure signals are always controlled.
Second problem this brings, is that voltages induced like this can result in circuitry inside the chip actually starting to turn on. This can then draw power. Depends what peripherals are actually on the pin involved. Again implies it is always better to control the signal. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Jan 12, 2016 4:32 pm |
|
|
Without seeing your code and schematic it's hard to say if 190ua is good or bad. That chip has a LOT of features/peripherals/etc. so how you've configured it will determine how much power it's using.
Given the OP of 'water level sensor->PIC->wireless' it's probably way to powerful. Like USB isn't needed, 40+I/O aren't needed, etc.
As much as I like to go 'bigger' your project scope is small so choose a smaller PIC.
Jay |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Wed Jan 13, 2016 12:05 pm |
|
|
To Ttelmah:
Yes, completely disconnected.
I have a software that runs on to different boards(PCB), both have GSM GPS and USB hardware but one have a TC1047 sensor and one doesn't.
To Temtronic:
It is bit more complex device than a water sensor, with "In something similar" I mean trying to reduce power consumption, in my case when the device is "off".
My device is never really off while the battery is connected and charged, the device must to be able to switch to on mode when USB or external power is applied and that's why I have a 32.768KHz OSC running to check time to time USB and external power supply. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Jan 13, 2016 12:14 pm |
|
|
You should test for the presence of the TC1047, and if it is not present, reprogram the pins as outputs. Asking for trouble otherwise.
You don't need an oscillator running. Connect a sense resistor from the USB and the external power, to an interrupt input, and use the interrupt to wake. |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Wed Jan 13, 2016 1:58 pm |
|
|
I can't change the hardware at this very moment because the PCBs are in production but I'll take in account your advices if my boss decide to make changes in the boards.
I'm using VDD(3.3V) as Vref for the A/D but the PIC brownout triggers below 2.45V, I'm thinking to use the VddCore as Vref for A/D but in the page 456 of PDF 39775c says the minimum Vref is 3V while VDD >= 3.0V
Does you know any work around to know when Vref is below 3.3V? _________________ Electric Blue |
|
|
|