Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 19th January 2007, 05:37 PM   (permalink)
Default using 32768 crystal (12F629, 12F683)

I've been having slow startup problems with my 12F629 and 12F683 32.768hz crystal clocked pics. I used the crystal recommended in the Midrange Reference Manual DS33023A (Epson C-001R32.768K) and from the recommend capacitors range (68-100pf) I started with 68pf. It takes several seconds for the oscillator to stabilize. I tried the hign end of the range, and it never starts with a 100pf cap. So reading the Basic PicMicro Oscillator Design document AN849, it indicates to use a 33pf cap, which works much better. In fact I've found it works with caps down to 5pf.

While AN849 is probably the definitive document on this stuff, I found it hard to apply in practice with my limited equipment and experience. I'm curious to know what others have found to be the best value to use with similar setups at 32Khz.
jimg is offline  
Old 20th January 2007, 11:41 AM   (permalink)
Default

Jimg,

I have used 15-33pf (33pf if I have them) and not had a problem. Also, the 12F683 has an internal osc that is in that range. Are you not using the INT OSC because you need very accurate timing?
mramos1 is offline  
Old 20th January 2007, 04:03 PM   (permalink)
Default

mramos1-
In the five 12F683's I have tested there is about a 3 to 4 percent variation in the internal oscillators. I'm also trying to keep the current down as much as possible.
jimg is offline  
Old 20th January 2007, 04:19 PM   (permalink)
Default

AVR's have a calibration byte for the internal oscilator don't pic's as well? I know it's temperature dependant, but manual calibration should get you within 1% at operating temperature. If you're using a low frequency crystal though I'm asuming you're doing some kind of real time clock function on the PIC? For that you would need a crystal, or an external oscilator refrence from a crystal driven source. Why is the stabilization time so important? I'd figure it would take a while for a low frequency oscillator to stabilize because noise is more prevalent in the lower frequency range. If you're just trying to keep current down use a full speed crystal and just utilize the sleep modes. What are your exact timeing and power requirements?
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 20th January 2007, 04:19 PM   (permalink)
Default

What are you doing to require greater accuracy then that?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 20th January 2007, 06:46 PM   (permalink)
Default

Hmm. I must not have said that right. As for accuracy, I was just replying to mramos1. For my purposes, I can work around the accuracy. I'm really only using the crystal to get the lowest possible current draw. Part of what prompted me to ask was that the current draw is higher during startup before the pic is happy with the crystal. The quicker it becomes happy, the smaller the power supply capacitor I need. And several seconds to stabilize when I was using 68pf was definitely annoying. I've also found the startup current to be somewhat higher for the 12F683's than the 12F629's.
It's all pure guesswork on my part if 33pf is better/worse than 15pf, so I thought I would just ask. My oscilloscope is not sensitive enough to hook to the Oscillator out pin without affecting it too much.
jimg is offline  
Old 20th January 2007, 07:00 PM   (permalink)
Default

If you want a short start-up time with a low frequency oscillator, you may choose a 100 kHz crystal (XT oscillator).
Quote:
32 kHz crystals have a typical start-up time
of 1-2 seconds. Crystals >100 kHz have a
typical start-up time of 10-20 ms.
Resonators are typically <1 ms. All these
times are voltage dependent.
The internal low-frequency oscillator of the PIC12F683 is not calibrated and its frequency is 15 kHz min and 45 kHz max.
eng1 is offline  
Old 20th January 2007, 07:16 PM   (permalink)
Default

So calibrate it! It takes nothing but a known program running on the pic to give you a steady state frequency to adjust the calibration against a known external frequency, easily produced and viewed using a Pc sound card. Low clock rates are good for low power but only if you are absolutely required to run the processor the whole time, you could reduce your power requirements by 1/4 1/8 or more using the sleep modes properly rather than trying to tweak your oscillator to death.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 20th January 2007, 07:35 PM   (permalink)
Default

I don't know any method that allows to calibrate the low-frequency internal oscillator of the PIC12F683 in software. You can do that with the PIC12F629.
I'd also reccomend sleep mode with INTOSC @ 4 Mhz, if the application allowed the PIC to sleep.
eng1 is offline  
Old 28th July 2008, 04:13 PM   (permalink)
Question Sleep mode

Curious about sleep mode: I hear MicroChip calling it "nanowatt technology".

There was a comment about using sleep mode to save 1/4 of the power or something, that's not relevant to my comment.

Please validate this logic.

I'd like to make a plant watering monitor. As such, I'd like to wake up (arbitrarily) 40 times a sec, and check the resistance (A-D converter thru a resistor and probes in the plant's soil) and when the resistance (due to low water content) gets too low, start flashing a LED once a sec to say "water me".

I did some calcs.

If the PIC runs at 4MHz, and I need say 400 instructions to wake up from sleep, check an analog signal, and go back to sleep, at 1 instr per clock I figure that's one 10,000th of a second that I'm "awake", thus I might get almost "infinite" battery life while NOT blinking the LED.

I am not being really technical (e.g. the 40 times, the 400 instructions etc) but just thinking out loud and looking for validation - if I sleep that much I really AM barely using the battery, in such an application, "Right"?

Thanks!

Ward Christensen
Inventor of Xmodem & BBSs
WardXmodem is offline  
Old 28th July 2008, 04:28 PM   (permalink)
Default

Quote:
Originally Posted by WardXmodem View Post
Curious about sleep mode: I hear MicroChip calling it "nanowatt technology".

Please validate this logic.

I did some calcs.

If the PIC runs at 4MHz, and I need say 400 instructions to wake up from sleep, check an analog signal, and go back to sleep, at 1 instr per clock I figure that's one 10,000th of a second that I'm "awake"
Hi Ward,
welcome to the forums!

I get 4 ten thousandths (your 4Mhz is being divided by 4, down to 1 instruction per micro second) of a second.

Quote:
Originally Posted by WardXmodem View Post
- if I sleep that much I really AM barely using the battery, in such an application, "Right"?
I would say so. It is common practice too, to put the PIC to sleep when doing the A-D conversion to limit the noise and improve the accuracy.

Last edited by BeeBop; 28th July 2008 at 04:29 PM. Reason: missing bracket
BeeBop is offline  
Old 28th July 2008, 04:31 PM   (permalink)
Default

Well 40 times per second would be pretty pointless, you only need to test it MUCH less often than that - an obvious 'easy way' would be to put the dvice to sleep, and allow the maximum setting on the WDT to wake it up (roughly 3.5 seconds) - this is still far more often than required, but you could either just do it that often, or count the number of 'wake ups' and test every so many wake ups.

As long as you design the circuit correctly, and run at a slow clock rate (no speed is needed) battery life should be extremely long, obviously dependent on how many times it's triggered.

Even when running PIC's use very little power, particularly at low clock speeds.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 28th July 2008, 04:53 PM   (permalink)
Default

There is also a ULPWU (ultra low power wake up module) on some newer devices (12F683 included) which use a capacitor and resistor attached to the ULPWU pin to achieve reasonably precise and extremely low power wake up intervals. There's even an application note that describes how to calibrate the time interval and do temperature compensation. Neat stuff!

Mike
Mike, K8LH is offline  
Old 28th July 2008, 06:04 PM   (permalink)
Default

I doubt you need 4mhz to do a simple sensor reading as well, lowering the main system clock during run mode can dramatically increase battery life. The PDF of your PIC should have a power drain in active mode vs clock frequency chart somewhere.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 28th July 2008, 07:02 PM   (permalink)
Default

Oh, 40 times per second be too many - Sorry, I was thinking about "detecting a button push" for another project. THAT would be 40 times a sec (so you could "tap" the button for less than say 1/20 sec and still catch it).

The plant watcher could clearly wake up hourly or even more, I need to see what the longest sleep time is - I recall the tiny chips don't have a prescaler so need to wake fairly often?

Just to mention (let me know if I should start a new thread), the "pushbutton" idea:

You can buy little 3xAAA "desk lamps" that are about a foot high, and have 14 LEDs in the head.

They have a single on-off pushbutton.

Just as an educational project, but also moderately useful, and possibly for inclusion in a "build your own" session at a sci fi convention, I'd like to do this:

Replace the on-off switch with a single momentary pushbutton.

Have a small PIC running in sleep mode waking up to look at the button (footnote 1)

Button use:
- tap = on or off
- hold: starts (via pulse width modulation) getting dimmer / brighter, in a sine wave sort of way - you release the button when it is at the brightness you want,
- hold AGAIN it reverses direction, so for ex if you wanted dimmer and you hold and it starts getting brighter, just release and press/hold again.

- "advanced" - Not sure how to do this from a user interface, but if say you tap it 4 times, you go into "auto-shut-off" mode, in which you then tap the time you want it to run (x x x x = 4 x 15 minutes = 1 hr?) . . I don't know, just "brainstorming".

Thanks for the tips - I recall ULPWU, and will review my docs, thanks!!!

__________
Background: I learned of a "build a blinky" session at http://www.duckon.org - where they use 12F683 and 16F688 to build little "badge-size" blinkies - from a 6-circle to a 5x7, and use IR so 2 badges sync to the same pattern, etc.

It gives people who maybe never held a soldering iron, or knew that "chips" exist, to build something "fun" for $10. Well, I got hooked on PICs (though I'd bought a UV-erasable set many years ago that I never actually programmed), and enjoy the tools available, the simple USB programmability, etc.

SO other than "blinkies" I'm often on the lookout for "what can we do for Duckon next year".

The 2 d's (Dwayne and Doug) who came up with this stuff and run the blinky session are at http://www.2dkits.com and if anyone reading this wants an inexpensive PIC blinky project, you can get them there. These guys are out to 'break even' tho I'm not even sure they do that, so prices are good.
WardXmodem is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Crystal or Crystal Oscillator? eblc1388 General Electronics Chat 4 21st August 2005 05:43 PM
Crystal questions zachtheterrible General Electronics Chat 7 9th April 2005 03:19 PM
Crystal oscillator questions Johnson777717 Micro Controllers 0 19th August 2004 11:41 PM
Argh...Another Crystal Question Eric Koh Micro Controllers 6 30th May 2004 03:35 AM
Sharing a crystal between 3 ICs DaKandEKid Electronic Projects Design/Ideas/Reviews 3 12th May 2004 03:18 AM



All times are GMT. The time now is 08:08 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker