MAINS CLOCKING A MICROCONTROLLER


[Lujji] is playing around with the STM8 microcontroller. In examining the official documentation for this chip, he checked out the outside clock can be a sine wave, a triangle wave, or a square wave with a 50% task cycle. The minimum CPU frequency is 0 Hz. [Lujji] doesn’t have a signal generator, as well as presumably, he’s all out of crystals. He does have mains AC, though, so why not clock a microcontroller with wall power?

Using mains power as a frequency basic is a idea a hundred years old. Synchronous motors turn at a rate proportional to the mains frequency, as well as this has been utilized in clocks for decades. If you’re truly clever, you can clock digital circuits with mains AC, however we’ve never seen somebody replace a small crystal in a microcontroller circuit with mains power.

After an experiment to verify the concept, [Lujji] went on to build a circuit that wasn’t as dumb as linking the microcontroller directly to a wall socket. The direct technique didn’t work that well anyway — the STM8 didn’t like low frequency clocks with sluggish edges. [Lujji] needed a clock with cleaner edges, as well as a 555 configured as a comparator in shape the bill.

The completed circuit sends mains power with an optocoupler to drive a 555 configured as a comparator. The output is a clean 50Hz clock that is linked to the OSCIN pin on an STM8. This is now a chip running at 50Hz, as well as yes, it works. [Lujji] set up a circuit to compose ‘Hello World’ on an old Nokia LCD. That took about three minutes. It works, though, even though it’s totally useless. perhaps this can be used to some book timekeeping similar to that one-instruction-per-day clock we looked earlier in the year.

Leave a Reply

Your email address will not be published. Required fields are marked *