-1

Have you noticed the lack of availability and prices of RTC chips lately? A simple DS1307 RTC is simply not available right now. Last year I purchased DS1307s for less than a buck. Now they are $4+ and on backorder. So I am looking into implementing my own RTC in an interrupt handler using AC line input to provide 60 Hz synchronization. I remember my office mate back in the dinosaur ages before RTCs were available coming up with a simple circuit which sampled 120 VAC line input and generated 8.33 ms DC pulses output. He borrowed this circuit from an old Intel 8048 app note. This output was fed into an 8051 interrupt where an interrupt handler implemented a firmware RTC. Evidently power generation stations must keep an average of 60 Hz over time so this provided an excellent accurate long term choice for a digital clock.

I remember his circuit used only simple passive components (resistors & capacitors) to produce this 5 VDC 8.33 ms pulse train. I remember an input capacitor isolating the AC input, but cannot remember how the 5 VDC pulses were generated.

Google has been of no help this afternoon. Does anyone have any suggestions on reviving this circuit? TIA.

winny
  • 13,064
  • 6
  • 46
  • 63
Doug12745
  • 319
  • 3
  • 9
  • Why do you want an obsolete inaccurate clock? https://www.digikey.ca/en/products/detail/nxp-usa-inc/PCF85063BTL-1-118/4020496 – Tony Stewart EE75 Mar 10 '22 at 05:10
  • 1
    If your system will have a microcontroller anyway, many MCUs already have the RTC built in. Some with battery backup feature. It just needs the crystal with two caps, and many MCU eval boards come with the 32768 kHz RTC crystal circuit present. Even if they don't, the main crystal would still usually be accurate enough to keep time and allow for software to easily adjust timekeeping in parts per billion if necessary. – Justme Mar 10 '22 at 06:01
  • This is an older product (PIC18F-based-no RTC) which is still selling very well. It is price sensitive and the DS1307 is difficult to get. We're are in the process of porting this product to an ARM-based MCU which does have an embedded RTC. Upper mgmt wants me to investigate methods to keep the old unit in production until the ARM PCB is ready to sell. – Doug12745 Mar 10 '22 at 17:12
  • Tony Stewart: THANKS for the lead on the PCF85063BTL device. Our purchasing person overlooked or did not find your device in their search the past few days. We ordered 2,500 of these units this morning, so this should tide us over until our ARM-bassed Beta. – Doug12745 Mar 10 '22 at 17:32

3 Answers3

1

Don't connect directly to the AC line. Use a low voltage transformer's AC output. If you have a 9 VAC output, you can drive a 4.7V zener diode via a 1 kΩ resistor, and with 1 uF in parallel with it. That will generate a 5 V square-ish wave. Use your software to avoid multiple counts per cycle by blanking subsequent transitions for ~ 9 ms after each detected edge.

jp314
  • 18,395
  • 17
  • 46
  • THanks. Our power suppy can tap into 9VAC. Good idea. Don't want the full 120VAC near the PCB for numerous reasons. – Doug12745 Mar 10 '22 at 17:16
  • p.s. Don't connect the zener V above directly to the MCU -- use a 10k series R and 1 nF filter cap – jp314 Mar 10 '22 at 23:07
1

An inexpensive way is to use a zero crossing optocoupler. You will need two resistors, one for the LED part of the coupler to control the current and the second as a pull up resistor for the output device. These couplers come in several varieties and are generally less than a buck. If the voltage gets to high for your circuit construction you can use a simple transformer to lower the voltage.

Gil
  • 4,951
  • 2
  • 12
  • 14
1

I agree with some commentators that finding away to still use a 32.768 kHz RTC clock would be recommended. If you still want to do it you basically need a zero-crossing detector circuit. There are many examples available. Although commonly it is used for detecting presence of a live wire (for example in case of 3-phase system), you can use it for getting the 8.33ms period. You can find some links with example circuits below.

1: AC Optocoupler for 230V line detection
2: https://www.electroschematics.com/220v-power-line-interface/
3: https://www.researchgate.net/figure/Zero-crossing-detection-circuit-The-voltage-zero-crossing-signal-is-sent-to-MCU-port-RB0_fig6_323004890