pic 16f628 internal oscillator question(s)

S

Spehro Pefhany

Jan 1, 1970
0
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...

http://www.microchip.com/download/lit/pline/picmicro/families/16c62x/40300c.pdf

Page 147 (+/- 3 sigma typical temperature dependence) and page 136
(guaranteed oscillator frequency when "calibrated" with OSCCAL).

Best regards,
Spehro Pefhany
 
J

Jan Panteltje

Jan 1, 1970
0
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...
You should go the www.microchip.com and download the data sheets and
application notes for that (series of ) PIC.
For timing that has to be stable over a wide voltage and temp range use xtal.
For non critical cases use the internal oscillator.
 
W

Wouter van Ooijen

Jan 1, 1970
0
What I need to know now is how accurate and stable the internal oscillator

check the datasheet!
Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Maybe, just maybe, after calibration and on constant temperature and
Vcc. But why not use a crystal?


Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
PICmicro chips, programmers, consulting
 
J

jtaylor

Jan 1, 1970
0
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...
 
L

Luhan Monat

Jan 1, 1970
0
Wouter said:
check the datasheet!




Maybe, just maybe, after calibration and on constant temperature and
Vcc. But why not use a crystal?


Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
PICmicro chips, programmers, consulting

The internal oscillator is great for many projects and frees up some
pins for other uses. In this case,however, I would spring 89 cents for
a crystal.
 
R

Roger Gt

Jan 1, 1970
0
X-No-Archive: yes

Luhan Monat said:
The internal oscillator is great for many projects and frees up some
pins for other uses. In this case,however, I would spring 89 cents for
a crystal.

Also an ordinary +-0.01 percent crystal is good
for about +- 8 seconds per day.
 
A

Active8

Jan 1, 1970
0
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

My freq counter read 1.5MHz on CLK OUT - 6MHz. I'd say "crap".
The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...

It do.
 
R

Robert C Monsen

Jan 1, 1970
0
jtaylor said:
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...

Its quite easy to build a little program/circuit to calibrate the internal
4MHz oscillator for many pic chips, assuming there is an OSCCAL word. I
wrote a little program that supports two buttons, and puts out a square
wave. One button tweaks up osccal, and the other tweaks it down. The result
is stored in eeprom. You read it out aftewards and use that as your OSCCAL
value.

One problem with this approach, however, is that the internal oscillator is
quite temperature dependent, so your clock will drift around if the weather
changes.

You can get temperature compensated crystal oscillators; then, you only need
to use one pin as the oscillator input, and the clock will be far more
accurate.

Another possibility is to use the powerline AC as a clock. It drifts some
small percentage, but is usually very accurate overall. There are tech notes
on doing this; basically, you connect a pin up using a 4.7Meg resistor, and
use the pin change interrupt to increment your clock. It'll change 120 times
a second in the US, or 100 times a second in Europe.

Regards,
Bob Monsen
 
T

Tim Shoppa

Jan 1, 1970
0
jtaylor said:
Just got a little programmer kit with pic for $20 CDN. Whoopee.

Anyway, I don't know much about these chips, have been googling a lot.

What I need to know now is how accurate and stable the internal oscillator
is?

The pic will be part of a complicated clock. One of the complications will
be running at some percentages of true time, ranging from about 50% to 800%.

It would be nice if I could use the internal clock, and once each unit is
built, run a calibration on it and set a value somewhere that that unit
would use as the 100% value from then on.

Is this needed - would the internal oscillator be out by more than say 1
part in 3600 (1 sec/hr)?

Definitely much more. See figures 18-7 through 18-9 in the 16F628
datasheet. You'll be lucky to get it to better than a minute per hour.
Would the internal oscillator drift very much? Temperature will be pretty
much constant, if that matters...

A twenty-five cent 32.768kHz crystal will get you much better than
the accuracy you're looking for. The 16F628 has provision for two
oscillators (one high-or-low-speed and potentially internal, the other
low-speed) exactly for this reason, and several of the Microchip
app notes illustrate this usage.

Tim.
 
S

Spehro Pefhany

Jan 1, 1970
0
You should go the www.microchip.com and download the data sheets and
application notes for that (series of ) PIC.
For timing that has to be stable over a wide voltage and temp range use xtal.
For non critical cases use the internal oscillator.

And for inbetween cases (+/-0.5%), such as for serial communications
or many real-world timing tasks that don't involve time-of-day,use a
resonator.

Best regards,
Spehro Pefhany
 
J

jtaylor

Jan 1, 1970
0
Robert C Monsen said:
Its quite easy to build a little program/circuit to calibrate the internal
4MHz oscillator for many pic chips, assuming there is an OSCCAL word. I
wrote a little program that supports two buttons, and puts out a square
wave. One button tweaks up osccal, and the other tweaks it down. The result
is stored in eeprom. You read it out aftewards and use that as your OSCCAL
value.

Previous poster said no OSCAL; oh well..
One problem with this approach, however, is that the internal oscillator is
quite temperature dependent, so your clock will drift around if the weather
changes.

You can get temperature compensated crystal oscillators; then, you only need
to use one pin as the oscillator input, and the clock will be far more
accurate.

I have a few 32768 crystals around, if I can get the code to turn through
it's loops in less than 1/100th second using them that would work.

Temp compensation might be worth it if this thing gets made beyond
prototype/personal use.
Another possibility is to use the powerline AC as a clock. It drifts some
small percentage, but is usually very accurate overall. There are tech notes
on doing this; basically, you connect a pin up using a 4.7Meg resistor, and
use the pin change interrupt to increment your clock. It'll change 120 times
a second in the US, or 100 times a second in Europe.

Gotta be battery operated. Oh well...

Thanks all - especially the fellow who quoted 6 mHz from his chip; that is
_too_ far out.
 
A

Active8

Jan 1, 1970
0
Then why keep that counter ;-)?
Probably because it read 1MHz when using an external 4 MHz XTAL
osc. FYI, clk out is div by 4.
 
A

Active8

Jan 1, 1970
0
Its quite easy to build a little program/circuit to calibrate the internal
4MHz oscillator for many pic chips, assuming there is an OSCCAL word.

The OSCAL word is set at the factory, you know. But if your
programmer doesnt save and rewrite it...
I
wrote a little program that supports two buttons, and puts out a square
wave. One button tweaks up osccal, and the other tweaks it down. The result
is stored in eeprom. You read it out aftewards and use that as your OSCCAL
value.

One problem with this approach, however, is that the internal oscillator is
quite temperature dependent, so your clock will drift around if the weather
changes.

In fact, there's an app note for using the watchdog timer as a
temperature sensor.
You can get temperature compensated crystal oscillators; then, you only need
to use one pin as the oscillator input, and the clock will be far more
accurate.

There's some cool compensation schemes, too. Let's build an oven,
though ;)
 
R

Roger Hamlett

Jan 1, 1970
0
Active8 said:
Probably because it read 1MHz when using an external 4 MHz XTAL
osc. FYI, clk out is div by 4.
There was a large batch of 16F chips, where this behaviour occured if you
ran the supply was at one particular end of the allowable range (5v?). If I
remember correctly, they run perfectly 'on frequency' at a lower supply
rail. Basically the oscillator had a problem. However this was not
'universal'.
I'd suspect you had one of these examples.

Best Wishes
 
R

Robert C Monsen

Jan 1, 1970
0
On a sunny day (Tue, 27 Jan 2004 05:46:09 GMT) it happened Active8
The PIC has a 4 to 1 instruction cycle. The clkout is 1/4 the clock.

They claim that the PIC12F675 is calibrated to 1% using OSCCAL.

Regards,
Bob Monsen
 
R

Robert C Monsen

Jan 1, 1970
0
Active8 said:
The OSCAL word is set at the factory, you know. But if your
programmer doesnt save and rewrite it...

I've found that the OSCCAL set at the factory is off by 5 to 10%, contrary
to expectations. The factory is someplace in indochina, I think, so its
probably a temperature thing :)
 
S

Spehro Pefhany

Jan 1, 1970
0
I've found that the OSCCAL set at the factory is off by 5 to 10%, contrary
to expectations. The factory is someplace in indochina, I think, so its
probably a temperature thing :)

It's also Vdd-dependent.


Best regards,
Spehro Pefhany
 
Top