Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
Thread Tools Display Modes
Old 24th April 2008, 04:09 PM   (permalink)
New Member
mrrmot is on a distinguished road
Post Need Help! Sine Wave To Square with Comparator

Hey everyone!

I am doing a project with a pic microcontroller.

Now I just need to convert the input sine signals (frequency: 50/60 Hz) to really really good squares. When the sine signal is positive the output has to be 5V, when the sine signal is negative the output has to be 0V. I want to use a comparator (maybe lm393, lm339, lm311) but I can't figure out how to connect a comparator for my purpose. The datasheets are no help. If someone has a scheme, I'd really appreciate it, or any other help!

Thanks a lot, guys!
__________________
Dazed&Confused

Last edited by mrrmot; 24th April 2008 at 04:26 PM.
mrrmot is offline   Reply With Quote
Old 24th April 2008, 04:42 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by mrrmot
Hey everyone!

I am doing a project with a pic microcontroller.

Now I just need to convert the input sine signals (frequency: 50/60 Hz) to really really good squares. When the sine signal is positive the output has to be 5V, when the sine signal is negative the output has to be 0V. I want to use a comparator (maybe lm393, lm339, lm311) but I can't figure out how to connect a comparator for my purpose. The datasheets are no help. If someone has a scheme, I'd really appreciate it, or any other help!

Thanks a lot, guys!
hi,
Where are going to connect your 50/60Hz source in order to drive the comparator input.?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Nigel's: www.winpicprog.co.uk/
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline   Reply With Quote
Old 24th April 2008, 04:46 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

If you're asking about where to connect the sine signals, well that's exactly my problem. I don't know it.

I have those 2 sine signals and want to use a comparator, but don't know how to do the connection. Btw: I have a 5V and 12V DC voltage source in my system
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 04:58 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by mrrmot
If you're asking about where to connect the sine signals, well that's exactly my problem. I don't know it.
No thats not it.

I have those 2 sine signals and want to use a comparator, but don't know how to do the connection. Btw: I have a 5V and 12V DC voltage source in my system
hi,
Its the 2 sine wave signals, ie: source and amplitude I am asking.

EDIT:
When a posting says 50/60Hz its possible its a mains application.
Is the source the local mains supply, if YES, how are you planning to reduce it to a safe level before its input to the comparator.?
If NO, is the signal in millivolts or volts..?

Its not possible to suggest a comparator circuit until we know this detail.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Nigel's: www.winpicprog.co.uk/
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 24th April 2008 at 05:17 PM.
ericgibbs is offline   Reply With Quote
Old 24th April 2008, 05:12 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

Those 2 sine signals are generated by a voltage generator. My project is supposed to work with sine singnals of any given amplitude that's smaller than 220V.
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 05:22 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by mrrmot
Those 2 sine signals are generated by a voltage generator. My project is supposed to work with sine singnals of any given amplitude that's smaller than 220V.
Quote:
When a posting says 50/60Hz its possible its a mains application.
Is the source the local mains supply, if YES, how are you planning to reduce it to a safe level before its input to the comparator.?
hi,
How are you planning to reduce the 220Vac to a safe level before its input to the comparator.?
Can you give more details of the project, whats it going to do.?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Nigel's: www.winpicprog.co.uk/
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline   Reply With Quote
Old 24th April 2008, 05:42 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

The sine signals need to be converted to (as ideal as possible) squares. The square signals are the inputs of a XOR IC. The output of that XOR IC is connected to the pic microcontroller, which is supposed to measur the phase shift angle of the original sine signals. I've already figured out the algorithm and the software. I just need those squares now.
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 05:55 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by mrrmot
The sine signals need to be converted to (as ideal as possible) squares. The square signals are the inputs of a XOR IC. The output of that XOR IC is connected to the pic microcontroller, which is supposed to measur the phase shift angle of the original sine signals. I've already figured out the algorithm and the software. I just need those squares now.
hi mrrmot,
I am trying to help, but you are not answering my questions.

How are you planning to reduce the 220Vac to a safe level before its input to the comparator.?

Do you have a mains step down transformer from 220Vac down to, say 6 or 12Vac.?

The processing of the square wave output has been solved by you OK.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Nigel's: www.winpicprog.co.uk/
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline   Reply With Quote
Old 24th April 2008, 06:28 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

I am very thankful for your help. Sorry, I forgot to answer yor question. Yes, I'll be using a transformator, but my teacher hasn't told me to what voltage yet. I guess it'll be 220Vac-5Vac or 220Vac-12Vac. So how to do the comparator part?
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 06:36 PM   (permalink)
Experienced Member
 
ericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to beholdericgibbs is a splendid one to behold
Default

Quote:
Originally Posted by mrrmot
I am very thankful for your help. Sorry, I forgot to answer yor question. Yes, I'll be using a transformator, but my teacher hasn't told me to what voltage yet. I guess it'll be 220Vac-5Vac or 220Vac-12Vac. So how to do the comparator part?
No problem,

I'll draw up a LM393 comparator circuit and post it.
If you are using TTL or LS, a +5v output from the comparator would be compatable, this 5V level would also make it suitable for the PIC.

Its late evening in the UK, so I'll post tomorrow.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Nigel's: www.winpicprog.co.uk/
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline   Reply With Quote
Old 24th April 2008, 06:44 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

I know that it is evening, I'm from Europe as well Thanks a lot for the help, I really appreciate it. Btw: Do you know where I can simulate the comparator circuit? I usually work with Proteus, but it doesn't have the LM393 simulation model

Thanks for everything
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 07:17 PM   (permalink)
Experienced Member
on1aag is a jewel in the roughon1aag is a jewel in the rough
Default

Hi Mrrmot,

Here is something you can work with, it was only a simulation
but it's close to the real thing.

http://www.edaboard.com/files-eboard...ector_1511.gif

on1aag.
Attached Images
File Type: png Zero crossing circuit.PNG (19.9 KB, 24 views)
File Type: png Waveforms.PNG (17.4 KB, 12 views)
on1aag is offline   Reply With Quote
Old 24th April 2008, 08:04 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

Tnx for the tip, on1aag! Which programm is this?
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Old 24th April 2008, 08:43 PM   (permalink)
Experienced Member
on1aag is a jewel in the roughon1aag is a jewel in the rough
Default

Hi Mrrmot,

It's LTspice/switchercad from Linear Technology.
You can download it here:

http://www.linear.com/

And it's a free ride !

on1aag.
on1aag is offline   Reply With Quote
Old 24th April 2008, 09:57 PM   (permalink)
New Member
mrrmot is on a distinguished road
Default

Tnx for the tip. I'll check it out right now!
__________________
Dazed&Confused
mrrmot is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Square wave to sine wave converter ghauri Electronic Projects Design/Ideas/Reviews 18 20th May 2008 07:15 PM
sine wave to square wave jay543_uk Micro Controllers 17 1st February 2008 06:24 PM
square wave to sine wave tony Ben Electronic Projects Design/Ideas/Reviews 2 26th January 2005 04:04 AM
LC filter- filtering a square wave to sine wave kken6248 General Electronics Chat 3 22nd April 2004 04:31 AM
How can I convert a square wave to sine wave?? kken6248 General Electronics Chat 6 1st April 2004 03:27 PM



All times are GMT. The time now is 10:52 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.