![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
Anyone used a PIC24F running at 32KHz? |
Posted: Mon Sep 04, 2017 7:31 pm |
|
|
Hi,
I am working on a project that has turned out to be far more challenging than I ever thought. I am using a PIC24F16KL402. This thing has to run from a 3V lithium 170 mA/hour button cell and has to last 45-60 days operating continuously which means that I have to average ~100 to 200 uA max.
I have been running it both in sleep mode and at 32KHz and i can average ~ 40-60uA so that is pretty good except that when I need to use my ADC module in the low power mode (32KHz), it just crashes most of the time. Basically the ADC goes into dark hole while trying to do a conversion. Normally this device will run for short periods of time at 8MHz and everything works flawlessly except it draws ~3mA but when I go into the low power mode (32KHz).
I seem to run into a lot problems whenever I try using the ADC module. I have heard that you can do ADC conversions even while asleep on very low power on this particular PIC. So I was wondering if anyone out here has done any data acquisition using extremely low power with a PIC24F? Any hints or suggestions will be greatly appreciated. ![Confused](images/smiles/icon_confused.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Sep 05, 2017 1:38 am |
|
|
Generally it will use less power, to clock at a reasonable rate (perhaps 1+MHz), and then turn everything off as much as possible. There are static power 'costs' associated with each module (like the ADC), and the longer this is left turned on, the bigger the effect of this on your battery life.
Consumption of the chip 'core' rises nearly linearly with frequency, then rising a little sharper at very high frequencies. So the most 'efficient' speed, is actually to clock near the top of the linear region, and have everything turned off as much as possible.
Get AN1416A, which graphs the total power cost (including start up time etc.), versus frequency for a smaller PIC. The amazing thing here, is that for a PSU with low internal resistance, the most efficient speed in terms of total power consumption versus work done, is actually right up at around 25MHz!.... However a battery with significant internal resistance reduces this significantly, which is why a frequency like 1MHz, is likely to be a better compromise for you.
Now your ADC will perform less well at low frequencies. Remember the ADC is a successive approximation sample and hold device. The input charges a capacitor inside the chip, which is then disconnected from the input to actually take the reading. So the whole time the chip is reading it is dependant on the voltage remaining near to constant on this internal capacitor.... At very low speeds the ADC will actually go non linear (though it shouldn't crash), but significantly before this it can start to under-read. You are very close to the minimum clock speed recommended for the ADC (remember it is being clocked off Fosc/2) - I'm assuming you do not have a divisor selected for the ADC. Also note that TAD_MUL_0 is not recommended. Honestly, it'd be more efficient to turn on the ADC, use ADC_CLOCK_INTERNAL (remember the PIC24's don't have any reason not to use this), TAD_MUL_2, and sample. Then turn off straight away. The same really applies to the whole chip.... |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9170 Location: Greensville,Ontario
|
|
Posted: Tue Sep 05, 2017 4:42 am |
|
|
While I don't use that PIC, I'm always curious about battery operated PIC projects so.
..OK, I have to 'play the devil' and ask
what else does the PIC have to do ? Does an LED come on by chance?
Perhaps the VDD has dipped, aka 'brownout' and not resetting?
Can a bigger battery be used ? Battery specs are LOUSY when cold or old.
Have you bench tested that coin cell ? Will it provide VDD and current for 45 days ?
I've added a 'super cap' across battery devices to keep a steady supply of electrons available. It could be that another peripheral (internal or external) is turning on/off during the ADC usage. Maybe a storage scope could 'see' what's happening ?
Switching clock speed takes a wee bit of time and consumes power, perhaps add a delay to ensure full speed before accessing the ADC ?
Maybe bypass the ADC code, put in a dummy delay loop equal to ADC operation, just to confirm it is the ADC peripheral causing the crash?
Just points to ponder.
Jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Sep 05, 2017 5:45 am |
|
|
There is very critical part in Temtronic's comment here.
A 170mAh battery will give this only at room temperature, and with a battery that is inside it's rated date. For designs that have to work in a wider temperature range, we use date stamped batteries supplied directly from the manufacturer, and still de-rate what we expect to get by 30%, from the official value, to allow for low temperature performance.... |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Tue Sep 05, 2017 7:08 am |
|
|
I have to ask what peripherals you have running? I'm working with a PIC18LF24K40 and I measured 46nA sleep, ~135uA run @1MHz internal clock. I was impressed that the currents given in the data sheet were very close to what I measured, but that PIC has the PMD (peripheral module disable) functionality so you can effectively kill every peripheral that is not needed in order to minimize current draw. The A/D on the PICs I've been studying of late are spec'd to draw ~250-300uA. I should also note that I had to be careful with the fuse selection in order to ensure that everything that I did not need was actually turned off/powered down. |
|
![](templates/subSilver/images/spacer.gif) |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
|
Posted: Tue Sep 05, 2017 8:29 am |
|
|
Thank you guys for your comments and suggestions which are greatly appreciated. Ttelmah is correct that sometimes it is better to use a reasonable low frequency clocking rather than going to 32KHz where you may find diminishing returns in various other ways. To answer temtronic's question; unfortunately, I am locked-in with the size of the battery by my client who has already created a product around this battery size. In reality I have done designs for this same client in the past using this same PIC and running at average currents of ~ 100uA but that was achieved by alternating between full-sleep and ON mode, also I was not taking any measurements during low power modes. This particular new design has a lot of bells and whistles in normal operation but during the low power mode I only need to take an ADC reading from one channel to see if there is activity, if there is I then wake-up to full operational mode (where I now have everything working) besides that channel I also have to monitor the battery voltage through another ADC input channel, I do this periodically where I measure the activity channel once per second and the battery channel once every 10 seconds and then blink either a red or green led to show battery status.
So, to summarize it, the real problem I am finding is that the ADC does not appear to work correctly as you get down in the very low clocking frequencies. Actually, what I am observing is that the ADC locks-up where it starts a conversion but never and never gets out of that mode. I know for a fact that this PIC is a XLP device which can perform ADC conversions while at sleep using the internal 32KHz oscillator. I have read the data sheet on the ADC over and over but perhaps I am missing the point. |
|
![](templates/subSilver/images/spacer.gif) |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
|
Posted: Tue Sep 05, 2017 8:52 am |
|
|
newguy, to answer your question regarding peripherals, I am using PWM, capture& compare, timer1 and timer2 and of course the ADC module which is the only one I use while in the low power mode, all other modules and interrupts are shut down upon entering low power mode. For this particular PIC it appears that the ADC module current while active is between 240 to 300 uA which is a lot of current for my application, therefore I have to turn the ADC ON and OFF to keep my current consumption low. I have been using the ADON bit to shut it down or activate the module, but I have had some weird results doing it this way. I have also tried PMD1bits.ADC1MD bit from the PMD module to do the same although I found that when I used this method I had to re-initialize the ADC configuration every time. I think what I need to find is a good application note on using this ADC module in very low power mode. |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Tue Sep 05, 2017 9:00 am |
|
|
If you kill the power to a peripheral with the PMD bit, then a full re-initialization must be performed every time you reapply power. Are you ensuring that there is at least one cycle's delay between reapplying power and any initialization attempt? Is there any note regarding the A/D in that chip's errata?
Does that PIC have a clock distribution network that can be disabled via a PMD bit? If so, do you set it to be on when the A/D is active? Do you explicitly route the low power oscillator to the clock distribution network prior to attempting to use the A/D? If the A/D lacks a clock, it will appear to lock up.
Edit: As others have said, you'll have to confirm "real world" current draw of your application, but the "sweet spot" in terms of lowest consumption is very likely a mix of high speed operations for short times with low speed operations for longer times. Your overall consumption might be lowest if you put the PIC to sleep with the A/D off, then wake up and switch to a faster clock, configure the A/D, trigger a conversion, then put the PIC into idle mode (processor not clocked - if your PIC features that mode) while you wait for the conversion to complete. Kill the A/D when the conversion is done and go back to sleep until the next event needs to be performed. What I'm getting at is that a slowly clocked A/D's power consumption in sleep mode might be higher than if you just "bit the bullet" and ran it faster while idle/awake, and left it off otherwise. |
|
![](templates/subSilver/images/spacer.gif) |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
|
Posted: Tue Sep 05, 2017 9:09 am |
|
|
Yes, actually I am doing two NOP's from the time I activate it and re-initialze it. I am not sure about the clock distribution network, I will have to look that up.
Quote: | Do you explicitly route the low power oscillator to the clock distribution network prior to attempting to use the A/D? If the A/D lacks a clock, it will appear to lock up. |
This may be a key to my problem, I take it this is done when I re-initialize the ADC by giving it what clock it will be using? |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Tue Sep 05, 2017 9:17 am |
|
|
That's only half of what needs to be done. You tell the peripheral (the A/D) what clock to use, but you also need to explicitly "connect" the low power internal clock to the network as well. Look at/for the oscillator manual enable register (oscillator module chapter of the data sheet). |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|