Dual clock speeds on a PIC


Closed Thread
Results 1 to 8 of 8
  1. #1

    Default Dual clock speeds on a PIC

    I need to have the lowest power possible while logging data for up to a year on a small 3.6 volt lithium battery but I also want a fast download to dump the very large data file of 128 MBytes after the data logger has been retrieved many months after deployment. Can I have a PIC running on a 100 KHz crystal while in data gathering mode and just force an external 20 MHz clock into CLKI/OSC1 for the data dump phase. I want to leave the 100 KHz crystal in place between OSC1 and OSC2 and just force a 1 volt peak to peak 20 MHz signal in for the data unload phase.

    Has anyone tried this dual clock speed approach before? Any problems I should look out for?

    BrianT

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    Can I have a PIC running on a 100 KHz crystal while in data gathering mode and just force an external 20 MHz clock into CLKI/OSC1 for the data dump phase. I want to leave the 100 KHz crystal in place between OSC1 and OSC2 and just force a 1 volt peak to peak 20 MHz signal in for the data unload phase.

    Has anyone tried this dual clock speed approach before? Any problems I should look out for?

    BrianT
    I don't think you can use the dual crystal idea because a low speed crystal uses XT config setting (low drive current), whereas a 20Mhz crystal would use HS. High drive current which low speed crystals don't like, might work, but might drift a bit. Conversely, you might get lucky and be able to get a 20Mhz crystal to run off the XT setting.

    Now, if you used 2 separate external DIP oscillators...that's a different story...
    A couple of 2 input AND gates...a 7408 or a couple of those SOT-23 package single gate logic chips, I think Fairchild calls them 'Tiny Logic'.
    One AND gate uses input A as an enable along with input B from 100khz clock
    2nd AND gate uses input A as the enable for the other clock (as well as power for the oscillator maybe?) along with input B from the 20Mhz clock.
    If you're using a PIC with a built-in clock fail oscillator (usually runs at 37-40khz), you could switch to that while switching main clock speeds, which would basically solve the problem of start up.
    Or maybe skip the AND gates all together and just power on a 20Mhz DIP oscillator and force it over the top of the 100khz clock. Might look a bit ugly on a 'scope though.

    I do that on my '4620. External 10Mhz, using 4xPLL, internal @ 40Mhz. When I don't need the processing power, I go to the internal 8Mhz. When I really don't need the power, I go to the internal ~37Khz.

    Don't know what kind of PIC you're going to use, so we don't know what kind of options are available...
    Last edited by skimask; - 23rd January 2008 at 02:41.

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    I need to have the lowest power possible while logging data for up to a year on a small 3.6 volt lithium battery but I also want a fast download to dump the very large data file of 128 MBytes after the data logger has been retrieved many months after deployment. Can I have a PIC running on a 100 KHz crystal while in data gathering mode and just force an external 20 MHz clock into CLKI/OSC1 for the data dump phase. I want to leave the 100 KHz crystal in place between OSC1 and OSC2 and just force a 1 volt peak to peak 20 MHz signal in for the data unload phase.

    Has anyone tried this dual clock speed approach before? Any problems I should look out for?

    BrianT
    The easy answer is to use a PIC with an internal oscillator. You can run most of them at eight different speeds from 31.25khz or 125khz & doubling on up to 8MHz. Run it as slow as you want for gathering mode, and 8mhz for downloading--you can change the clock speed on the fly by changing the OSCCON register.

    For even more power saving, put the PIC to sleep, and wake up periodically. A PIC and a 32khz watch crystal works well as an RTC, and is even documented on the microchip site.
    Last edited by tenaja; - 23rd January 2008 at 02:41. Reason: added osccon info

  4. #4


    Did you find this post helpful? Yes | No

    Default More details

    Thanks Tenaja and Skimask. Some more details might clarify.

    The processor is an 18LF4620 TQFP. It spends most of its time asleep where it draws 2.6 uA with a 4 MHz xtal. It runs at about 4 mA plus the external signal conditioners on a 4 MHz xtal. I am hoping to reduce the 'on' current to much below 1 mA with the slower clock.

    I have to accurately measure the frequency/rate of some events so RC oscillators are out of the question during the measure phase.

    I will have ICSP programming brought out to a 6 pin header. I can load different code for the logging phase and for the data dump phase. The ICSP has access to the configuration fuses so the XT/HS changeover should be possible. I figure to push a high level (~1 Vpp)20 MHz clock over the top of the 100 KHz xtal through this header. Real estate is ultra cramped so extra gates for a clean clock changeover are out.

    BrianT

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Brian T,
    Section 2.7 of the data sheet says you can do it, but I have had far too many beers right now to discover how . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    The processor is an 18LF4620 TQFP. It spends most of its time asleep where it draws 2.6 uA with a 4 MHz xtal. It runs at about 4 mA plus the external signal conditioners on a 4 MHz xtal. I am hoping to reduce the 'on' current to much below 1 mA with the slower clock.

    I have to accurately measure the frequency/rate of some events so RC oscillators are out of the question during the measure phase.

    I will have ICSP programming brought out to a 6 pin header. I can load different code for the logging phase and for the data dump phase. The ICSP has access to the configuration fuses so the XT/HS changeover should be possible. I figure to push a high level (~1 Vpp)20 MHz clock over the top of the 100 KHz xtal through this header. Real estate is ultra cramped so extra gates for a clean clock changeover are out.
    Well there ya go. Add a jumper on the header to swap OSC1 between the crystal and an external X Mhz signal source (or whatever......you've got the 4xPLL to play with) and reprogram the unit to dump the data. Done dumping, reprogram for recording. At 100khz, a bit of sloppiness on the OSC lines shouldn't hurt (I've had much uglier on a 10Mhz crystal mounted roughly 2 inches from an '877A on lines that weren't so straight, still worked).

    But, in the end, I like using the internal oscillator better. 31.25khz at the slowest and you can feed the 8Mhz intosc into the 4xPLL for some high speed data dumping.

  7. #7
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by BrianT View Post
    I have to accurately measure the frequency/rate of some events so RC oscillators are out of the question during the measure phase.
    Another Approach? - The 18F4620 can be clocked by switching from an external XTAL on OSC1 and OSC2 to a 32kHz XTAL on TMR1. See section 3.3.2 of the data sheet for details (from the data sheet “This gives users the option of lower power consumption while still using a high-accuracy clock source.)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  8. #8
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    An even faster way to save battery power--without even changing the bulk of your code--is to use a different PIC! The 18F4620 was NOT designed for long battery life. At 4MHz with INTOSC, it takes 1.3mA at 3.0v. There are PIC's that will do the same speed with only .58mA draw--well under 1/2 the power draw. With careful data sheet scrutiny, you should be able to find one that runs 1MHz with even less power.

    You will almost double your battery life by going from 5.0 to 2.7v.

    I have a friend who runs their systems for years on one battery... he has 8 or 9 voltage regulators in the system so each circuit is individually powered, and totally shut down when not in use. Yes, it is expensive, but it is very efficient.

    You are trying to cram a V8 engine into a Toyota Echo so you can enter a stock car race... but there are much easier and better ways to do it. Your multiple oscillators just seems like more work than it'd be worth, considering all of the other options available. Especially when 18F's already allow you to run an external crystal or the internal osc.

Similar Threads

  1. Talking Clock (Pic Based)
    By Art in forum General
    Replies: 2
    Last Post: - 20th January 2012, 14:45
  2. Digital clock thermometer Calendar PIC 16F628
    By valdirdf in forum Code Examples
    Replies: 0
    Last Post: - 31st May 2009, 01:52
  3. Can a PIC PIC a PIC?
    By afbecker in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd January 2008, 19:55
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts