60 Hz Mains Timebase


This exercise is a demonstration of how to extract a timebase from the power mains. As the project stands now, the circuit is expecting to detect a 60 Hz signal, so my friends in Europe will need to make some appropriate changes to the code to deal with 50 Hz power.

The demo is simple. An LED is toggled on or off every minute. As a rule, while the AC voltage of the power mains may fluctuate considerably from moment to moment, in general the long term frequency is usually quite good in most parts of this country. This circuit, then, besides providing the necessary +5V DC for the PIC, also monitors the AC frequency. Here's the schematic:


First things first:

The 110V AC power mains provides dangerous levels of both voltage and current, which can be extremely hazardous to your health or life! If you are unfamiliar with its workings, seek the professional help of a skilled electrician.

While this circuit is perfectly safe to both the PIC and to you when correctly constructed, neither I nor the people at PIC Micro Pascal are responsible for any mishaps on your end. I have tested it successfully myself, but this exercise is provided for information only.

There, got that out of the way. But do be attentive and watch what you're doing around 110V AC.

Here's what's going on in the schem. The AC is stepped down by the transformer, then rectified by the bridge full-wave rectifier. After filtering, the DC is applied to the voltage regulator which yields a stable +5V for the PIC.

The stepped-down AC is also applied to a dropping/rectifying network before hitting the transistor. What comes out at the collector, then, is a rectangular +5V wave suitable for the PIC. This is applied to the external interrupt pin (pin 6, Port B.0).

Thus, interrupts are generated once every 1/60th of a second. The PIC Micro Pascal code counts these and toggles the LED appropriately. The software is quite short and to the point.

And that's it!

Click to get the source code.
Click to get the schematic PDF.

Next Project:

No comments:

Post a Comment