EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: deth502 on January 04, 2014, 11:50:52 pm

Title: need a small accurate 100Hz oscillator
Post by: deth502 on January 04, 2014, 11:50:52 pm
nearly finished with my current project. only thing missing is... well, the most important part. i need a time base for my .01sec timer to trigger on (100Hz triggered on the falling edge)

ive tried various types of r/c circuits, but none have had any kind of reasonable accuracy. i dont think im asking for much, but the best ive managed to build, id tune to 100Hz, and within 5 min was already out by over 10%. i tried letting it run for an hour to "stabilize" and then calibrated it, but the results were practically the same.

ive tried going the crystal route, but any simple, low part xtal osc ive tried i cannot get to work, and any ive got to work have been far too large, especially considering all of the extra circuitry id need to divide the signal down to 100Hz afterwards.

ive got both +9vdc battery and a regulated 5vdc power available as power sources.  itd be super to get it to fit on a piece of perfboard 10 holes x 10 holes, but i can go slightly larger and still fit in the enclosure.

im open to ideas.
Title: Re: need a small accurate 100Hz oscillator
Post by: casper.bang on January 04, 2014, 11:55:44 pm
Too bad you are in the US. In Europe I would've tapped into the DC supply after rectifiers before capacitor.
Title: Re: need a small accurate 100Hz oscillator
Post by: Rerouter on January 04, 2014, 11:56:59 pm
would a real time clock chip be possible? a number of those give outputs of 1000 or 1 pps, there may be one that can do your magic 100,
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 12:01:57 am
With a little micro, you can easily program it to do that.

A more complex solution would be a crystal + counter (HC4060 for example).
Title: Re: need a small accurate 100Hz oscillator
Post by: Frost on January 05, 2014, 12:39:19 am
What's with the Maxim DS3231 together with an HC4017?

The DS3231 delivers a very accurate 1kHz square wave
signal at it's SQW output Pin and with the HC4017
you can divide it by 10
But as a con the DS3231 requires a microcontroller to
handle the I2C setup routine and it's not so small.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 12:57:40 am
for the frequency division, i actually already had this in mind:

http://www.leapsecond.com/pic/picdiv.htm (http://www.leapsecond.com/pic/picdiv.htm)

simple 8 pin dip, no external components. all the hex code is right there so i can cook one myself, or buy one if i choose.

but that still leaves the signal to feed into it...

im absolutely 100% stupid afa micros. i have a cheap programmer that i could never get to work because you could only use the hex code (^^^ above website has hex code files!!!!  :-+ ) and i JUST bought a pikkit 3 (JUST, as in it came in the mail thursday) so as far as the micro solutions go, please feel free to talk down to me like im an idiot. afaik, arduino can run independently after programming with just an xtal and a cap, but the only ones ive seen were huge 20 pin+ packages. if there is some other way to skin this cat, im all ears.
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 01:10:11 am
Quote
but that still leaves the signal to feed into it...

You sure can feed it something but don't need to: the micro can run on either its internal rc oscillator, or an external crystal (+internal oscillator). It can generate a 100Hz signal stand-alone, with the right code: all it needs is to count 1000000/100/2 = 5000 pulses from its interal 4Mhz oscillator, and then flip a pin.

Fairly simple code.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 01:27:21 am
Quote
but that still leaves the signal to feed into it...

You sure can feed it something but don't need to: the micro can run on either its internal rc oscillator, or an external crystal (+internal oscillator). It can generate a 100Hz signal stand-alone, with the right code: all it needs is to count 1000000/100/2 = 5000 pulses from its interal 4Mhz oscillator, and then flip a pin.

Fairly simple code.

so your saying that with a 12f675, and NOTHING ELSE, i can get a stable accurate signal? this would be perfect.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 01:29:32 am
especially if the hex code already existed and was easily available for it.
Title: Re: need a small accurate 100Hz oscillator
Post by: Rufus on January 05, 2014, 01:58:48 am
so your saying that with a 12f675, and NOTHING ELSE, i can get a stable accurate signal? this would be perfect.

You will get about 1% accuracy from a PIC12F675 internal RC oscillator. More like 2% with temperature and supply voltage spread.

The chip can be used with an external crystal or ceramic resonator if you need better.

I would be surprised if you could find exactly the code you need.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 02:02:17 am
so your saying that with a 12f675, and NOTHING ELSE, i can get a stable accurate signal? this would be perfect.

You will get about 1% accuracy from a PIC12F675 internal RC oscillator. More like 2% with temperature and supply voltage spread.

The chip can be used with an external crystal or ceramic resonator if you need better.

I would be surprised if you could find exactly the code you need.

an oscillator that would stay between 98 and 102Hz indefinitely would be fine for my purposes. with my r/c trials i was deviating beyond that after less than a minute of operation. 
Title: Re: need a small accurate 100Hz oscillator
Post by: Rufus on January 05, 2014, 02:36:41 am
an oscillator that would stay between 98 and 102Hz indefinitely would be fine for my purposes. with my r/c trials i was deviating beyond that after less than a minute of operation.

You were doing something wrong. You should be able to get 1% stability from a 555 timer oscillator if you use a stable capacitor type. If you are not going to use a crystal a 555 would be a simpler solution than a PIC, however, you would learn less.
Title: Re: need a small accurate 100Hz oscillator
Post by: Rerouter on January 05, 2014, 02:58:37 am
by chance what capacitor where you using? if its a ceramic or electrolytic i can see it drifting like mad,

try a film cap, if you pick a capacitor with a good enough temp and voltage tolerance i could see reaching 0.1% easily,
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 06:04:10 am
by chance what capacitor where you using? if its a ceramic or electrolytic i can see it drifting like mad,

try a film cap, if you pick a capacitor with a good enough temp and voltage tolerance i could see reaching 0.1% easily,

didnt even bother trying a 'lytic, didnt have any polypropylene on hand. other than that, all of them. ceramic, tantalum, polyester, ect.. best results was a dipped metal polyester film and one of those little box caps (they are all metalized polyester too, right?)

i might be mis-remembering how quickly it drifted, but it wasnt an exaggeration. im tempted to board it back up and test again.
Title: Re: need a small accurate 100Hz oscillator
Post by: codeboy2k on January 05, 2014, 07:15:55 am
so your saying that with a 12f675, and NOTHING ELSE, i can get a stable accurate signal? this would be perfect.

You will get about 1% accuracy from a PIC12F675 internal RC oscillator. More like 2% with temperature and supply voltage spread.

The chip can be used with an external crystal or ceramic resonator if you need better.

I would be surprised if you could find exactly the code you need.

I would use a PIC10F200... it's less than 0.60 USD and also has a ±1% accurate internal RC oscillator.

A 555 is generally cheaper, at less than 0.40 to 0.50, but when you consider you need to add a stable cap to it, it is a solution with more components and maybe now exceeds the area and price of a standalone PIC10F200.
Title: Re: need a small accurate 100Hz oscillator
Post by: owiecc on January 05, 2014, 09:02:59 am
by chance what capacitor where you using? if its a ceramic or electrolytic i can see it drifting like mad,

try a film cap, if you pick a capacitor with a good enough temp and voltage tolerance i could see reaching 0.1% easily,
I remember Dave saying in one of his videos that certain types of caps have NTC and other PTC behaviour. Conecting the two in parallel woulc compensate the cap drift.
Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 05, 2014, 09:05:13 am
an oscillator that would stay between 98 and 102Hz indefinitely would be fine for my purposes. with my r/c trials i was deviating beyond that after less than a minute of operation.

You were doing something wrong. You should be able to get 1% stability from a 555 timer oscillator if you use a stable capacitor type. If you are not going to use a crystal a 555 would be a simpler solution than a PIC, however, you would learn less.
I agree, what you are doing wrong is to use a bipolar 555 and not a Cmos 555. (TLC555 for example.)
Title: Re: need a small accurate 100Hz oscillator
Post by: Jon86 on January 05, 2014, 11:14:45 am
Pic with a crystal. If not Pic then almost any other micro should be fine too, but having a crystal in there is going to significantly increase the accuracy.
Title: Re: need a small accurate 100Hz oscillator
Post by: Strada916 on January 05, 2014, 11:35:09 am
Go to youtube and search the channel  w2aew then look at one of his videos called "Build a crystal oscillator from schematic thru prototype construction and testing - DIY" youtube is blocked from where i am typing this.

Then all you need to do is find a suitable crystal and a divide by chip(s).

eg A crystal at 1MHz can be divided down to 100Hz with 4 x 4017 daisy chained.  >:D That might be a high ic count though



Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 11:49:30 am
Quote
with a 12f675, and NOTHING ELSE, i can get a stable accurate signal?

Yes.

Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 11:51:24 am
555: you can also configure a mcu into external rc oscillator (which would be identical to a 555). But why bother if better alternatives exist?
Title: Re: need a small accurate 100Hz oscillator
Post by: plesa on January 05, 2014, 12:17:15 pm
nearly finished with my current project. only thing missing is... well, the most important part. i need a time base for my .01sec timer to trigger on (100Hz triggered on the falling edge)

ive tried various types of r/c circuits, but none have had any kind of reasonable accuracy. i dont think im asking for much, but the best ive managed to build, id tune to 100Hz, and within 5 min was already out by over 10%. i tried letting it run for an hour to "stabilize" and then calibrated it, but the results were practically the same.

ive tried going the crystal route, but any simple, low part xtal osc ive tried i cannot get to work, and any ive got to work have been far too large, especially considering all of the extra circuitry id need to divide the signal down to 100Hz afterwards.

ive got both +9vdc battery and a regulated 5vdc power available as power sources.  itd be super to get it to fit on a piece of perfboard 10 holes x 10 holes, but i can go slightly larger and still fit in the enclosure.

im open to ideas.

Make a modification of this for example.
http://www.leapsecond.com/pic/picdiv.htm (http://www.leapsecond.com/pic/picdiv.htm)
Title: Re: need a small accurate 100Hz oscillator
Post by: grumpydoc on January 05, 2014, 12:31:03 pm
Quote
eg A crystal at 1MHz can be divided down to 100Hz with 4 x 4017 daisy chained.  >:D That might be a high ic count though

Does seem a little high, but a PIC seems to be overkill somewhat, though being able to do it all in an 8 pin package does seem attractive.

A 1.6384MHz crystal and a CD4020 would do the trick. The only snag is that 1.6384MHz crystals aren't especially common - though a Google did turn up a couple of small suppliers in the UK. 3.2768MHz is much easier to find but the 4020 is only 14 stages so can divide by 16384 max.

A 3.2768MHz crystal, a 4020 and the d-type of your choice would fit the bill nicely.
Title: Re: need a small accurate 100Hz oscillator
Post by: jolshefsky on January 05, 2014, 01:09:13 pm
ive tried various types of r/c circuits, but none have had any kind of reasonable accuracy. i dont think im asking for much, but the best ive managed to build, id tune to 100Hz, and within 5 min was already out by over 10%. i tried letting it run for an hour to "stabilize" and then calibrated it, but the results were practically the same.

I was just thinking your RC oscillator may get so much drift from the type of capacitor. I was looking for a good cap to use for a rather tight filter application, and did some reading and found you can get very stable capacitors that use the NP0 ceramic with a C0G rating. According to the Wikipedia article (http://en.wikipedia.org/wiki/EIA_Class_1_dielectric#Class_1_ceramic_capacitors), "an 'NP0' capacitor with EIA code 'C0G' will have 0 drift, with a tolerance of ±30 ppm/K". The NP0 ceramic also doesn't change with age:
(http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Delta-Cap-versus-Zeit-engl.png/320px-Delta-Cap-versus-Zeit-engl.png)

Using a CMOS inverter RC ring oscillator, you can get the capacitor pretty small since the input impedance is so high. For instance, a 0.1µF and 1M? resistor, trimmed as needed, will get you 10Hz.
(http://i.stack.imgur.com/XVbyH.gif)
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 01:30:28 pm
Rc oscillators are not very stable, particularly in terms of phase.

if you are not pressured for time, I can write a short piece for 12f675 to generate the pulse, plus allows voltage running - making the chip a vcxo.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 01:47:05 pm
so your saying that with a 12f675, and NOTHING ELSE, i can get a stable accurate signal? this would be perfect.

You will get about 1% accuracy from a PIC12F675 internal RC oscillator. More like 2% with temperature and supply voltage spread.

The chip can be used with an external crystal or ceramic resonator if you need better.

I would be surprised if you could find exactly the code you need.

I would use a PIC10F200... it's less than 0.60 USD and also has a ±1% accurate internal RC oscillator.

A 555 is generally cheaper, at less than 0.40 to 0.50, but when you consider you need to add a stable cap to it, it is a solution with more components and maybe now exceeds the area and price of a standalone PIC10F200.

reason i mention the 12f675 is because i actually have them on hand. ive got no problem picking up a few 10f200's if they are going to work better.
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 02:03:14 pm
If you are doing it on a mcu, you probably want the following:

- out frequencies: 1000/100/1hz.
- enable/disable pin.
- volt controlled running.

that means 3iutput puns, 1 digital input and 1 analog input.

12f675 seems perfect for this, especially if you already have them.
Title: Re: need a small accurate 100Hz oscillator
Post by: codeboy2k on January 05, 2014, 02:50:42 pm
Yeah, 12f675's are better if you already have them on hand, and this gives you more pins anyways vs. a 6-pin 10f200.  With more pins you can get the extra features that dannyf describes.

Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 05, 2014, 02:51:30 pm
Using a pic for making a simple 100 Hz oscillator ? |O
You are kidding  :-DD
Here is a simple 100Hz oscillator as stable as a Xtal.
NB: TLC555 = Cmos version of the 555.
C1 : low temperature coefficient condensator.
For highest stability, trimpot R2 (22K) may be substituted by adjusted resistor. (ajusted for 100 Hz)
Title: Re: need a small accurate 100Hz oscillator
Post by: Jon86 on January 05, 2014, 03:09:11 pm
Using a pic for making a simple 100 Hz oscillator ? |O
You are kidding  :-DD
Here is a simple 100Hz oscillator as stable as a Xtal.
NB: TLC555 = Cmos version of the 555.
C1 : low temperature coefficient condensator.
For highest stability, trimpot R2 (22K) may be substituted by adjusted resistor. (ajusted for 100 Hz)

Why not? The circuit you showed uses many more components and is less accurate. I don't see how a single 8-pin micro by itself is a bad idea?
Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 05, 2014, 03:29:41 pm
Using a pic for making a simple 100 Hz oscillator ? |O
You are kidding  :-DD
Here is a simple 100Hz oscillator as stable as a Xtal.
NB: TLC555 = Cmos version of the 555.
C1 : low temperature coefficient condensator.
For highest stability, trimpot R2 (22K) may be substituted by adjusted resistor. (ajusted for 100 Hz)

Why not? The circuit you showed uses many more components and is less accurate. I don't see how a single 8-pin micro by itself is a bad idea?
More components?
01 x TLC555 or equivalent
01 x 4049B
01 x 0.1µF condensator (c2 is not essential)
03 x resistors (if trimpot is not used and replace with ajusted resistors)
Title: Re: need a small accurate 100Hz oscillator
Post by: fcb on January 05, 2014, 03:30:31 pm
Watch out for feature creep with a microcontroller.

My favorite fit&forget solution would be 3.2768MHz xtal driving (and driven by) a 74HC4020, then feeding the output from this into another 74HC4020.

You need a 15 stage divider for 3.2768MHz, so you can play with the different taps (7 stage feeding an 8 stage, 9 stage feeding a 6 stage etc...)

The 74HC4020 is very cheap and using two doesn't complicate the BOM - no programming also.  There is also a schematic of the xtal oscillator rigging in the NXP datasheet.
Title: Re: need a small accurate 100Hz oscillator
Post by: Jay_Diddy_B on January 05, 2014, 03:30:52 pm
Hi,

Here is a solution that will get you a very small solution size. The accuracy is <1.5% over the full temperature range. The solution size:

1x SOT23
2x 0402


This is a silicon oscillator based timer. The duty cycle is 50% from built in divider.

(https://www.eevblog.com/forum/projects/need-a-small-accurate-100hz-oscillator/?action=dlattach;attach=74940;image)




Link to the datasheet: http://www.linear.com/product/LTC6991 (http://www.linear.com/product/LTC6991)

I have attached the LTspice model.

No programing required  :-+

Regards,

Jay_Diddy_B
Title: Re: need a small accurate 100Hz oscillator
Post by: Rufus on January 05, 2014, 03:48:55 pm
More components?
01 x TLC555 or equivalent
01 x 4049B
01 x 0.1µF condensator (c2 is not essential)
03 x resistors (if trimpot is not used and replace with ajusted resistors)
Yes more components. A PIC needs no other components except a supply decoupling capacitor if you don't already have some.

Link to the datasheet: http://www.linear.com/product/LTC6991 (http://www.linear.com/product/LTC6991)
$3 100 off from Digikey is the problem with that suggestion and it is barely more accurate than a PIC10F200 which is also in SOT-23 and costs $0.34 100 off from Digikey.
Title: Re: need a small accurate 100Hz oscillator
Post by: codeboy2k on January 05, 2014, 03:50:45 pm
Using a pic for making a simple 100 Hz oscillator ? |O

...because OP has them on hand, they have a built-in, factory-trimmed RC oscillator stable to 1%, and OP already tried to use a 555 (albeit not the TLC555) and it was unstable, again using the parts OP had on hand.

Yes, your solution uses more parts and requires quality caps, and even then may not be better than a few percent accurate.  And it won't be as stable as a crystal, like you claim. Plus an analog input of the PIC can be used to make a temperature compensated oscillator, if needed.

More components?
01 x TLC555 or equivalent
01 x 4049B
01 x 0.1µF condensator (c2 is not essential)
03 x resistors (if trimpot is not used and replace with ajusted resistors)
PIC:
01 x PIC12F675
01 x 0.1u bypass cap

RE: LTC6991 - nice part, but $3.80???
The PIC12F675 is $1.26.  I wouldn't use that part in a design but OP has it on hand.  I would use the cheaper 10F200 at $0.68 for an oscillator like this.

The TLC555 is $0.87,  the cd4049  $0.51, the 60ppm precision thin-film cap might be $0.50 to $0.70

[ edit: I always quote 1 off prices here rather than 100 or 1k because often the OP is making less than 100 anyways, and the relative pricing is still clear using 1 offs ]

Title: Re: need a small accurate 100Hz oscillator
Post by: vk6zgo on January 05, 2014, 04:28:20 pm
You could use a watch crystal---less division.

Another way is to use a 100Hz oscillator which is triggered every 10 cycles from a 10Hz pulse derived by dividing the 60Hz mains  by 6.     

Messy?--I know,but it's how it would have been done back in the day!

Or you could heterodyne two stable low frequency crystal oscillators.
Title: Re: need a small accurate 100Hz oscillator
Post by: Rufus on January 05, 2014, 04:31:43 pm
You could use a watch crystal---less division.

Dividing by 327.68 to get 100Hz isn't so simple.
Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 05, 2014, 04:40:30 pm
I pay 6€ for 40 x TS555 (same as TLC555) smd. (0.15€ each) (ebay.de)
For 4049b smd, waiting for good deal, i pay only 0.1€ each.
Title: Re: need a small accurate 100Hz oscillator
Post by: vk6zgo on January 05, 2014, 04:51:39 pm
You could use a watch crystal---less division.

Dividing by 327.68 to get 100Hz isn't so simple.

Yep!
But you could probably "pull" the crystal to an integral number.
Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 05, 2014, 05:22:53 pm
As condensator, a 0.1µF WIMA MKS-3 seems to be good enough to reach the stability request for the temperature range. (98-102Hz)
Output frequency is not voltage dependent: no variation for power supply between 4V to 6V.
Title: Re: need a small accurate 100Hz oscillator
Post by: Jay_Diddy_B on January 05, 2014, 05:25:52 pm
[RE: LTC6991 - nice part, but $3.80???

$3.80 is the Digikey price for 1 piece.

The price on the Linear website is $1.88:

(https://www.eevblog.com/forum/projects/need-a-small-accurate-100hz-oscillator/?action=dlattach;attach=74961;image)

When you consider that you don't need a precision capacitor or a crystal this is quite good.

If the original post needs 1 or 2 parts, he can get samples from Linear free.

Jay_Diddy_B

Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 05:37:11 pm

...because OP has them on hand, they have a built-in, factory-trimmed RC oscillator stable to 1%, and OP already tried to use a 555 (albeit not the TLC555) and it was unstable, again using the parts OP had on hand.

Yes, your solution uses more parts and requires quality caps, and even then may not be better than a few percent accurate.  And it won't be as stable as a crystal, like you claim. Plus an analog input of the PIC can be used to make a temperature compensated oscillator, if needed.


this pretty much hits the nail on the head.

ok, so about the xtal, afa i know, to get my 12f675 to mate to an xtal, it needs a driver circuit for it. i also know that there are other micros that exist that are made to made up with a crystal directly, no drivers required. is there another small 8 pin dip micro that could mate directly to a crystal that would be a better candidate, or is the xtal really not that necessary? like i said, i dont need world clock accuracy, but the best metalized poly film caps i could muster deviated >10% within minutes. the more accurate the better, obviously, but im not launching space shuttles.
Title: Re: need a small accurate 100Hz oscillator
Post by: Rufus on January 05, 2014, 05:46:46 pm
ok, so about the xtal, afa i know, to get my 12f675 to mate to an xtal, it needs a driver circuit for it.

It has a built in oscillator (like almost all PICs) which needs an external crystal and two small capacitors.
Title: Re: need a small accurate 100Hz oscillator
Post by: codeboy2k on January 05, 2014, 07:01:49 pm
The good thing about using the PIC is you can start without a crystal and use the internal oscillator. It might be good enough. If you are making a PC board, you can place the pads for a crystal and 2 caps to add later, should you need better accuracy than the internal RC oscillator can deliver.

Title: Re: need a small accurate 100Hz oscillator
Post by: Zero999 on January 05, 2014, 08:18:47 pm
Watch out for feature creep with a microcontroller.

My favorite fit&forget solution would be 3.2768MHz xtal driving (and driven by) a 74HC4020, then feeding the output from this into another 74HC4020.

You need a 15 stage divider for 3.2768MHz, so you can play with the different taps (7 stage feeding an 8 stage, 9 stage feeding a 6 stage etc...)

The 74HC4020 is very cheap and using two doesn't complicate the BOM - no programming also.  There is also a schematic of the xtal oscillator rigging in the NXP datasheet.
Yes, though I think the 74HC4060 would be better as it has a built-on oscillator.
Title: Re: need a small accurate 100Hz oscillator
Post by: fcb on January 05, 2014, 08:27:43 pm
Watch out for feature creep with a microcontroller.

My favorite fit&forget solution would be 3.2768MHz xtal driving (and driven by) a 74HC4020, then feeding the output from this into another 74HC4020.

You need a 15 stage divider for 3.2768MHz, so you can play with the different taps (7 stage feeding an 8 stage, 9 stage feeding a 6 stage etc...)

The 74HC4020 is very cheap and using two doesn't complicate the BOM - no programming also.  There is also a schematic of the xtal oscillator rigging in the NXP datasheet.
Yes, though I think the 74HC4060 would be better as it has a built-on oscillator.

Quite right... that's the one I meant to write & the data sheet I was reading.

...The OP now has a number of well thought-out options with most of the pros/cons discussed - a most satisfying thread I think.
Title: Re: need a small accurate 100Hz oscillator
Post by: codeboy2k on January 05, 2014, 08:35:04 pm
...The OP now has a number of well thought-out options with most of the pros/cons discussed - a most satisfying thread I think.

Agreed.  There's more than one way to skin a clock :)
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 08:42:11 pm
Quote
is the xtal really not that necessary?

For what you do, no.

I put this together quickly but it will generate 3 frequencies, 1khz/100hz/1hz, on a 12F675's 7/6/5 pins, respectively. In addition to the pic, no other part is required, though a decoupling cap (.1uf) + 3 resistors (220ohm each on the output, for protection) would be nice.

Code: [Select]
:020000002C28AA
:10000800A00003088301AA000B1101308312A30783
:100018002302F43003192202031C26280130850626
:100028000C30A2070318A30AFE30A307A60B262844
:10003800023085060A30A600A70B2628043085065C
:100048006430A70083122A088300A00E200E09003E
:1000580021308400263040200030A9006130A800FB
:1000680026308400283045208316FF239000830122
:10007800052904068001840A0406031D3D2864003E
:100088000034DC0050208000840A04085C06031950
:10009800003446288312A800A91B592829088A0079
:1000A8002808A80A0319A90A8200831329188317A4
:1000B8002808A80A8400000808000A346434831257
:1000C800A4008A28F3309F0583169F111F119F10E3
:1000D8001F14A3281F08F33904389F0083169F11A3
:1000E8001F119F1487281F08F33908389F008316AB
:1000F8009F111F1586281F08F3390C389F00831697
:100108009F151F119F101F10A328892883122408E8
:100118000C39DE00DF019E285E08003A03196628C4
:10012800043A03196E280C3A03197728043A03197C
:100138007F2889285F08003A031990288928000039
:1001480000000000000000000000000083129F145F
:100158009F18AC281E08DD00DC0183161E08DC048D
:1001680083120800831224088312FE202508A400A5
:10017800A501C028FF30FE2024080319A503A40305
:10018800240A0319250A03190800BE28D028C830F4
:10019800A400A5018312B620831224080319A5031D
:1001A800A403240A0319250A03190800CB28831677
:1001B8001F139F161F1683129F111F119F171F13BE
:1001C8000C1383160C1383121F140800F8308312C3
:1001D80085058316850581128115831281010B110E
:1001E8008B16080007308312990083169F0181132C
:1001F800831208008312A4008312A403240F002989
:0C02080008008312F620EA208B17092959
:02400E00843FED
:00000001FF

Save the above in a hex file and burn to a pic12f675. It will start generate the output frequencies right away.

I will implement enable/disable + voltage tuning of the output later on.
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 08:46:13 pm
Quote
which needs an external crystal and two small capacitors.

Even those two small capacitors can be ignored - crystal's pullability is very low, especially if you pick a crystal with ~6pf of load capacitance (which is roughly the parasitic capacitance on a pin).
Title: Re: need a small accurate 100Hz oscillator
Post by: mrkev on January 05, 2014, 08:47:45 pm
Well, to my mind came more than one solution...

- Using 555. I would use simple current source to charge that capacitor, as the low value cap is better for this, but high value resistor isn't; plus you would get rid of slight voltage dependability. You can actually get very close to 0,2% with 555 and right components...

- I would personaly use 32,768kHz basic watch xtal, with 9 bit (8+1) counter that would reset on 328th pulse. That way you would get very precise 99,9Hz...

- Back in the day, they would use something like 300Hz - 3kHz VCO, that would be divided by 3 (output) and 5 (for sync. with the 120V/60Hz wall...).

- there are IO with complete solution, you just add a timing resistor (i think something like that mentioned someone above)...
Title: Re: need a small accurate 100Hz oscillator
Post by: FrankBuss on January 05, 2014, 09:38:32 pm
I put this together quickly but it will generate 3 frequencies, 1khz/100hz/1hz, on a 12F675's 7/6/5 pins, respectively. In addition to the pic, no other part is required, though a decoupling cap (.1uf) + 3 resistors (220ohm each on the output, for protection) would be nice.
Nice, I just did the same, but only 100 Hz output:

http://www.frank-buss.de/PIC100/index.html (http://www.frank-buss.de/PIC100/index.html)

Do you want to share your source code? My version doesn't use a timer, which makes it easer to implement zero jitter (except from the RC oscillator itself).

I hope it works for the PIC12F675, I could test it for my PIC12F509 only, and simulated the PIC12F675 with the MPLAB-X simulator.
Title: Re: need a small accurate 100Hz oscillator
Post by: FrankBuss on January 05, 2014, 09:54:06 pm
I will implement enable/disable + voltage tuning of the output later on.
Another interesting idea would be to implement a calibration function. The PIC12F675 has an EEPROM, which can be used to store the OSCCAL value and this can be trimmed with two external switches.

But looks like the factory calibration is already very stable. I can measure 99.6 Hz and even with freezer spray it is still 99.3 Hz and it goes to 100 Hz when heating it with a soldering iron. I guess the 555 circuit is not that precise.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 05, 2014, 10:37:44 pm
very nice. i cant thank you enough, guys. especially danny and frank for helping with the code!!  :-+

now im going to have to remember where i stuck that programmer........
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 05, 2014, 10:57:32 pm
I tried on a fresh 12F675 (never programmed before). With literally nothing else, I got 100.46hz on the 100Hz line. I recaliberated it in pickit2 and it ended with the same osccal value.

Yes, I used timer 0: used it to generate 1Khz, and then divided it down from there to get 100hz and then divided that down to 1hz. 13 lines of code to generate those outputs. All in, flash is 25% utilized.

Pin 2/3 not used - it can be further utilized, if you want, to implement other frequencies - like 2hz, or sub 1hz. Or to be used with a crystal for better stability. You can also use GP4 for voltage-controlled output: put a pot on it and adc the pot's position to alter the output. In case rc oscillators are utilized, you can implement a range of +/-2%; In the case of crystal oscillators, +/- 50ppm would be more than sufficient.

Pin 4 not yet used - it can be used to implement enable / disable via MCLR or as an gpio pin (for instant start-up).

Title: Re: need a small accurate 100Hz oscillator
Post by: FrankBuss on January 05, 2014, 11:23:25 pm
very nice. i cant thank you enough, guys. especially danny and frank for helping with the code!!  :-+

My pleasure. Another nice usage for cheap PICs, even without a DAC, is to create analog signals, for example a low frequency sine wave:

http://www.frank-buss.de/blinker/index.html (http://www.frank-buss.de/blinker/index.html)

You should try to code in PIC assembler. PICs are byzantine, sometimes the registers are not intuitive and not easy to use (e.g. for your microcontroller, if you want to use the other GPIOs, don't forget to disable the analog function, see the ANSEL register), the assembler instruction set is a nightmare, compared to e.g. a nice 68k CPU, but they are still very useful for such simple tasks, and it is some kind of geeky fun to wrap your head around it. And you can get the chips forever, even the old ones, unlike some other vendors like Atmel, who sometimes discontinue chips or where it is difficult to get some chips.
Title: Re: need a small accurate 100Hz oscillator
Post by: FrankBuss on January 05, 2014, 11:33:49 pm
Yes, I used timer 0: used it to generate 1Khz, and then divided it down from there to get 100hz and then divided that down to 1hz. 13 lines of code to generate those outputs. All in, flash is 25% utilized.
Nice, that's short. And depending on the application, the jitter is no problem for the 100 Hz signal, would be only a few us.
Title: Re: need a small accurate 100Hz oscillator
Post by: mrkev on January 05, 2014, 11:49:26 pm
My pleasure. Another nice usage for cheap PICs, even without a DAC, is to create analog signals,...
Well it's always nice to see non-uC solution, but it's not a surprise that people won't do it  :P the price of those microcontrolers is just crazy, as some are cheaper than basic passive parts, can't even buy one small beer for that price (and I am tallking here, in CZ where the beer is cheaper than water)...
It still feels like using bombs to kill flies tho  :D
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 06, 2014, 12:32:23 am
Quote
the jitter is no problem for the 100 Hz signal, would be only a few us.

The way I implemented it, the jitter does show up on the 1khz signal -> no impact on long-term frequency stability, however. The benefit of this particular approach is the ease to implement calibration down to ppm levels.

If that's not important, you can implement it by loading offset (or use a chip with auto reloading) and no jitter - 16f684 for example could be used for that. The calibration, however, can only be done in 1/256 increments, which I think may be too coarse for crystal oscillators.
Title: Re: need a small accurate 100Hz oscillator
Post by: oldway on January 06, 2014, 06:48:25 am
Quote
But looks like the factory calibration is already very stable. I can measure 99.6 Hz and even with freezer spray it is still 99.3 Hz and it goes to 100 Hz when heating it with a soldering iron. I guess the 555 circuit is not that precise.
Schematic I have proposed is designed to not depend of the supply voltage ( the 4049B ensures that the voltages for charging and discharging the capacitor are exactly 0V and the voltage of the power supply) , nor influenced by the impedance of the 555 input . ( this is the reason for choosing the cmos 555 version) .
Therefore, the oscillation frequency depends essentially of the R x C value.

For this frequency to be stable , it is necessary that this value does vary as little as possible with the temperature .
Two approaches are possible:
- Or to choose components with low temperature coefficient ( capacitor Metallized Polyphenylene - Sulphide (PPS) )
- Or to choose components with temperature coefficients which compensate each other. (resistance with positive temperature coefficient (TCR) and capacitor with negative coefficient )
Given the high variation of frequency allowed (from 98 to 102 Hz) , there is no problem at all getting the required frequency stability in a reasonable range of temperature.
Title: Re: need a small accurate 100Hz oscillator
Post by: plesa on January 06, 2014, 04:33:13 pm
very nice. i cant thank you enough, guys. especially danny and frank for helping with the code!!  :-+

My pleasure. Another nice usage for cheap PICs, even without a DAC, is to create analog signals, for example a low frequency sine wave:

http://www.frank-buss.de/blinker/index.html (http://www.frank-buss.de/blinker/index.html)

You should try to code in PIC assembler. PICs are byzantine, sometimes the registers are not intuitive and not easy to use (e.g. for your microcontroller, if you want to use the other GPIOs, don't forget to disable the analog function, see the ANSEL register), the assembler instruction set is a nightmare, compared to e.g. a nice 68k CPU, but they are still very useful for such simple tasks, and it is some kind of geeky fun to wrap your head around it. And you can get the chips forever, even the old ones, unlike some other vendors like Atmel, who sometimes discontinue chips or where it is difficult to get some chips.

I found strange behavioral. The OSCAL value does not affect the frequency and switching on and off can change the frequency ( tested with Pickit2 and two brand new 12F675 )
Manytimes the output frequency is set to 92.05.. but after several on/off cycles frequency is changes to 122Hz or other frequency which is quiet odd.
Title: Re: need a small accurate 100Hz oscillator
Post by: dannyf on January 07, 2014, 12:28:04 am
I can confirm that frank's code does generate a 100hz signal.

If it didn't work for me, the issue may be somewhere else.
Title: Re: need a small accurate 100Hz oscillator
Post by: FrankBuss on January 07, 2014, 06:31:36 am
I found strange behavioral. The OSCAL value does not affect the frequency and switching on and off can change the frequency ( tested with Pickit2 and two brand new 12F675 )
Manytimes the output frequency is set to 92.05.. but after several on/off cycles frequency is changes to 122Hz or other frequency which is quiet odd.
That's interesting. Maybe it is related to the _BODEN_OFF setting and slow falling/rising supply voltage and then some registers are not initialized correctly? I can turn it on and off as often as I want and it is always 99.6 Hz, but it is a PIC12F509. I will buy a PIC12F675 with my next order for my DIY bitcoin miner and then test it again.
Title: Re: need a small accurate 100Hz oscillator
Post by: deth502 on January 18, 2014, 11:03:14 pm
very nice. i cant thank you enough, guys. especially danny and frank for helping with the code!!  :-+

My pleasure. Another nice usage for cheap PICs, even without a DAC, is to create analog signals, for example a low frequency sine wave:

http://www.frank-buss.de/blinker/index.html (http://www.frank-buss.de/blinker/index.html)

You should try to code in PIC assembler. PICs are byzantine, sometimes the registers are not intuitive and not easy to use (e.g. for your microcontroller, if you want to use the other GPIOs, don't forget to disable the analog function, see the ANSEL register), the assembler instruction set is a nightmare, compared to e.g. a nice 68k CPU, but they are still very useful for such simple tasks, and it is some kind of geeky fun to wrap your head around it. And you can get the chips forever, even the old ones, unlike some other vendors like Atmel, who sometimes discontinue chips or where it is difficult to get some chips.

I found strange behavioral. The OSCAL value does not affect the frequency and switching on and off can change the frequency ( tested with Pickit2 and two brand new 12F675 )
Manytimes the output frequency is set to 92.05.. but after several on/off cycles frequency is changes to 122Hz or other frequency which is quiet odd.


finally found the programmer and hooked it up. ended up using franks program. i loaded up danys and it was soooooo small on teh chip, i thought i was missing something, lol. so then i tried franks and it was also very small, so i just went ahead and burned it, i guess it was easier than i thought.

anyway, imo, works great. i tried it and also had some fluctuations when turning it on and off. mine only varied between 99-104.5Hz though, close enough for me, but the important part for me, is that it STAYS at that. the r/c and 555 circuit drifted so terribly under operation, in the order of more than a few Hz a minute. this one is rock stable once running. and as far as the -1/+4.5 tolerance, again, as long as the error is repeatable, which it is, then it is perfect for my needs.

thanks again to dan and frank!!
Title: Re: need a small accurate 100Hz oscillator
Post by: arnold on April 29, 2018, 08:24:20 pm
sorry about the delay, however you can use MM5369EST with 3.58 MHz crystal to produce very accurate 100 Hz signal.
If you use MM5369AA, it's 60 Hz output.

http://www.seekic.com/circuit_diagram/Automotive_Circuit/The_60Hz_time_based_generator_composed_of_MM5369.html (http://www.seekic.com/circuit_diagram/Automotive_Circuit/The_60Hz_time_based_generator_composed_of_MM5369.html)