Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using 32768 crystal (12F629, 12F683)

Status
Not open for further replies.

jimg

Member
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,

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-
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.
 
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?
 
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.
 
If you want a short start-up time with a low frequency oscillator, you may choose a 100 kHz crystal (XT oscillator).
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.
 
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.
 
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.
 
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
 
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.

- 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:
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.
 
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
 
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.
 
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 **broken link removed** - 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.
 
Just a note to your push button project, if you debounce in hardware (using a carefully chosen capacitor and a resistor as a low pass) you can run the switch directly to an I/O pin set to wake up the UC without having to pole so frequently.
 
Oh, good point - like on the lamp, where if it is off, I'm doing nothing else, a pushbutton wake up beats a poll any time!

I guess it could be used even on say the plant watering tester, where it wakes up every hour to check the resistance of the electrodes - a pushbutton could wake it up (if I needed such a function - I'm thinking a 5 second button press would say "this is my definition of dry enough to start blinking the LED to ask for water")

I am SO oriented toward thinking of pushbutton debounce in software, I "forgot" about the early days where we had to do it in HW.

Let's see - you put a cap across the switch, then a pull-up resistor. The resistor-cap switch is the input - normally high, but pulled to ground by the pushbutton, and debounced by the cap charging should the switch bounce, and won't return to high until the cap has been un-shorted long enough to charge up by the resistor?

From an RC site I found, 100K and a 1 uF cap would be 100ms time - or 10K and a 10uF.

I guess it depends upon what I have in the parts box.

Do you happen to know the impedance of the input of a PIC, i.e. how large a resistor can be used to bring it to see a + voltage / level?

Thanks!
 
Input pin impedance will be in the PDF file for your PIC.
 
I seem to recall running into the impedance of an AVR or PIC I/O pin impedance figure a ways back; might have been for the ADC though. In the range of 40-60kohms.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top