# Creating a squar-ish wave from 240V 50Hz single phase mains a.c. voltage

I'm intersted in creating a square-ish wave from mains a.c. voltage. That is to say on the 240V 50Hz sine waveform, I would like to switch the voltage on at 45 degrees on the wave, switch it off at 135 degrees, switch it on at 225 degrees and off at 315 degrees.

Is there any non-mechanical device which can do this and still cope with mains power/current? Thanks for any pointers.

-
What is the required output voltage and current? What do you want to use it for? – jippie Nov 21 '12 at 20:47
It's a lot easier to have the square wave turn on at 0, off at 180, and back on at 360. Can you adapt your application to work with a 50Hz square wave that is zero crossing sync'd with the powerline? – Adam Davis Nov 22 '12 at 3:16

You need a zero-crossing detector; if you know when the voltage crosses zero and the frequency, you can figure out when the other spots are.

Here's a simple way to build one: 1) Connect a transformer to the mains - one that gives you about 5VAC works fine. 2) Put a full-wave rectifier on it. This gives you rectified AC voltage. 3) Hook the output to the base of an NPN transistor through an appropriate resistor (10K or so). The transistor will be off when the voltage is below about 0.7V, and on the rest of the time. This gives you a pretty good square wave, centered around the zero cross. 4) Hook it to the interrupt of a microcontroller, and set it to edge trigger on high to low. This gets you an interrupt a bit before zero crossing, and then you can use the timer on the microcontroller to generate the rest.

Okay, perhaps it's not quite so simple...

-
Thanks for the pointers and follow up questions. What I'm trying to understand is can normal household mains equipment still function when the mains current is off for 50% of the time - thereby saving power/electricity costs. I suspect the main problem will be equipment plugged into the mains which steps down the voltage and converts the current back to d.c. the expanding and collapsing magnetic field will just tend to "smear" any power saving into a lower output voltage. I'm not entirely sure if this idea is the electrical equivalent of a perpertual motion machine! – tim heyes Nov 22 '12 at 21:01

Which do you need? A switched power source or a logic level?

The Logic level signal cna be generated in several ways. Since it is a symmetrical 100Hz square wave but shifted 45deg or 2.5mS a one shot delay circuit can be used to trigger from an XOR frequency doubler.

Alternatively you can use a 1st order 50Hz LPF filter with 45 deg phase shift and square up then double the frequncy with XOR gate and delay cct.

-