Sine to square wave converter

J

Jack// ani

Guest
Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks
 
"Jack// ani" <nospam4u_jack@yahoo.com> wrote in message
news:1111688349.178611.282570@l41g2000cwc.googlegroups.com...
Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks
This will explain how you should proceed:

http://www.web-ee.com/primers/files/AN-140.pdf
 
Whoops, i'm sorry the link is working! Something was wrong here!
 
I read in sci.electronics.design that Jack// ani
<nospam4u_jack@yahoo.com> wrote (in
<1111689339.387719.13490@o13g2000cwo.googlegroups.com>) about 'Sine to
square wave converter', on Thu, 24 Mar 2005:
Thanks for reply Lord. Unfortunately link is dead!

IE6 barfs badly, but Firefox retrieves it OK. I'm having the same
problem with PDFs from other sites, using IE 6 and Acrobat 6.
--
Regards, John Woodgate, OOO - Own Opinions Only.
There are two sides to every question, except
'What is a Moebius strip?'
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk
 
There are trivial ways to do it...it all depends on how "square" square must
be. Do you absolutely HAVE to have 50.000% duty cycle, or are you only
worried about using it as a leading (or falling) edge clock. Do you have
any spare circuits in another multi-circuit chip, or do you have room for a
dedicated chip. Tell us what matters to you and we'll have a shot at making
the sucker go.



Jim



"Jack// ani" <nospam4u_jack@yahoo.com> wrote in message
news:1111688349.178611.282570@l41g2000cwc.googlegroups.com...
Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks
 
If a 50% duty cycle is important, a zero-cross detector into a D
flip-flop as divide by 2 would get pretty close.
GG
 
Jack// ani wrote:
Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks
One simple way is to use a large value resistor, like 1MEG, into the
base of an NPN transistor. The emitter should be grounded, and the
collector tied to your +5V power supply rail through a 100k resistor.
Take the output from the collector of the transistor. Note that for this
to work, your power supply should have it's ground someplace near earth
ground.

One problem with this is that the base goes very negative. This can be a
problem. Thus, if you use a diode from ground to base, if the input goes
very negative (which it will, of course) the diode will keep it within
about 7/10 of a volt of the ground.

So

VCC
|
.-.
| | 100k
| |
'-'
|
o------ PIC Input
|
1MEG |
___ |/
AC IN -|___|----o----|
| |>
| |
- |
^ |
| |
| |
GND ------------o------'
(must be near neutral)
(created by AACircuit v1.28.5 beta 02/06/05 www.tech-chat.de)

This is probably going to be fast enough so that the PIC will only see
one transition for each transition of the AC line. However, if it isn't,
you can build a simple schmitt trigger out of two transistor that will
prevent false triggering.

That would be like this (which is swiped out of Art of Electronics,
Volume 2)

.--------------o--------- VCC
| |
.-. .-.
| | 1.5k | |1k
| | | |
'-' '-'
| ___ |
o---|___|--. o------Output to PIC
| 10k | |
1MEG | | |
___ |/ | |/
AC IN -|___|----o----| '-|
| |> |>
| | |
- '------o-------'
^ |
| 100R |
| ___ |
GND ------------o----|___|----'
(must be near neutral)

(created by AACircuit v1.28.5 beta 02/06/05 www.tech-chat.de)

However, I think the first circuit is probably ok.

--
Regards,
Robert Monsen

"Your Highness, I have no need of this hypothesis."
- Pierre Laplace (1749-1827), to Napoleon,
on why his works on celestial mechanics make no mention of God.
 
Jack// ani wrote:
Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks
It depends on what powers your logic circuit and what it needs the 50Hz
square wave for. You can't just couple a voltage off the line into a GND
referenced circuit and expect it to work trouble free. Also, most
circuits are looking for zero-crossing on the AC- waveform and this is
difficult to get with the massive attenuation required of a line voltage
in conjunction with the fairly large uncertainties of typical Schmitt
trigger thresholds and hysteresis. You will get a square wave, but it
may not be of much use.
 
Robert Monsen wrote:
Jack// ani wrote:

Hi all,

How can I convert 50Hz AC to a square wave so that I can feed it to a
microcontroller? Will CD4093 work here? I will steps down the ac to
5volts then use a diode in series before hooking it to CD4093?

Thanks


One simple way is to use a large value resistor, like 1MEG, into the
base of an NPN transistor. The emitter should be grounded, and the
collector tied to your +5V power supply rail through a 100k resistor.
Take the output from the collector of the transistor. Note that for this
to work, your power supply should have it's ground someplace near earth
ground.

One problem with this is that the base goes very negative. This can be a
problem. Thus, if you use a diode from ground to base, if the input goes
very negative (which it will, of course) the diode will keep it within
about 7/10 of a volt of the ground.

So

VCC
|
.-.
| | 100k
| |
'-'
|
o------ PIC Input
|
1MEG |
___ |/
AC IN -|___|----o----|
| |
| |
- |
^ |
| |
| |
GND ------------o------'
(must be near neutral)
(created by AACircuit v1.28.5 beta 02/06/05 www.tech-chat.de)

This is probably going to be fast enough so that the PIC will only see
one transition for each transition of the AC line. However, if it isn't,
you can build a simple schmitt trigger out of two transistor that will
prevent false triggering.

That would be like this (which is swiped out of Art of Electronics,
Volume 2)

.--------------o--------- VCC
| |
.-. .-.
| | 1.5k | |1k
| | | |
'-' '-'
| ___ |
o---|___|--. o------Output to PIC
| 10k | |
1MEG | | |
___ |/ | |/
AC IN -|___|----o----| '-|
| |> |
| | |
- '------o-------'
^ |
| 100R |
| ___ |
GND ------------o----|___|----'
(must be near neutral)

(created by AACircuit v1.28.5 beta 02/06/05 www.tech-chat.de)

However, I think the first circuit is probably ok.
All depends on what you're trying to do.
If all you need is line synchronization...
On PIC16F877A, I've used a voltage divider directly into the input.
The inputs are clamped. As long as you have enough series resistance to
limit the current, it should work ok. External clamps are even safer.
Transistor is better. You can spend as much as you like.
Use SW to mitigate noise.
Assume you have mains isolation.
mike

--
Return address is VALID but some sites block emails
with links. Delete this sig when replying.
..
Wanted, PCMCIA SCSI Card for HP m820 CDRW.
FS 500MHz Tek DSOscilloscope TDS540 Make Offer
Wanted, 12.1" LCD for Gateway Solo 5300. Samsung LT121SU-121
Wanted 13" LCD for Mitac 6133 Samsung HT13X13-201
Bunch of stuff For Sale and Wanted at the link below.
MAKE THE OBVIOUS CHANGES TO THE LINK
ht<removethis>tp://www.geocities.com/SiliconValley/Monitor/4710/
 

Welcome to EDABoard.com

Sponsor

Back
Top