Author Topic: need a small accurate 100Hz oscillator  (Read 27719 times)

0 Members and 1 Guest are viewing this topic.

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2368
  • Country: de
    • Frank Buss
Re: need a small accurate 100Hz oscillator
« Reply #50 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

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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2368
  • Country: de
    • Frank Buss
Re: need a small accurate 100Hz oscillator
« Reply #51 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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline deth502Topic starter

  • Frequent Contributor
  • **
  • Posts: 418
  • Country: us
Re: need a small accurate 100Hz oscillator
« Reply #52 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........
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: need a small accurate 100Hz oscillator
« Reply #53 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).

================================
https://dannyelectronics.wordpress.com/
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2368
  • Country: de
    • Frank Buss
Re: need a small accurate 100Hz oscillator
« Reply #54 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

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.
« Last Edit: January 05, 2014, 11:55:38 pm by FrankBuss »
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2368
  • Country: de
    • Frank Buss
Re: need a small accurate 100Hz oscillator
« Reply #55 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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline mrkev

  • Regular Contributor
  • *
  • Posts: 225
  • Country: cz
Re: need a small accurate 100Hz oscillator
« Reply #56 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
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: need a small accurate 100Hz oscillator
« Reply #57 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline oldway

  • Super Contributor
  • ***
  • !
  • Posts: 2172
Re: need a small accurate 100Hz oscillator
« Reply #58 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.
« Last Edit: January 06, 2014, 07:07:19 am by oldway »
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: need a small accurate 100Hz oscillator
« Reply #59 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

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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: need a small accurate 100Hz oscillator
« Reply #60 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline FrankBuss

  • Supporter
  • ****
  • Posts: 2368
  • Country: de
    • Frank Buss
Re: need a small accurate 100Hz oscillator
« Reply #61 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.
So Long, and Thanks for All the Fish
Electronics, hiking, retro-computing, electronic music etc.: https://www.youtube.com/c/FrankBussProgrammer
 

Offline deth502Topic starter

  • Frequent Contributor
  • **
  • Posts: 418
  • Country: us
Re: need a small accurate 100Hz oscillator
« Reply #62 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

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!!
 

Offline arnold

  • Newbie
  • Posts: 1
  • Country: au
Re: need a small accurate 100Hz oscillator
« Reply #63 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
 
The following users thanked this post: jbb


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf