Jump to content
jheissjr

Getting a sine wave DC level.

Recommended Posts

I was wondering if I could borrow your guys' EE expertise. I have a project where I need to turn a sine wave into a square wave like in the picture. The project I have is to determine the roll position of a spinning projectile using thermopiles. My question I was hoping you electrical engineering guys could help me with is my need to get the sine wave's DC level. I was wondering what kind of circuit can do this?

post-6-1142988781_thumb.jpg

Edited by jheissjr

Share this post


Link to post
Share on other sites

If all you need to know is when the AC waveform crosses the offset voltage then do a search for "zero crossing detector." If that sort of circuit concept satisfies the app, then keep in mind that there are purpose designed IC's that will do all the work for you. Or, you can cobble descrete parts to create one.

Share this post


Link to post
Share on other sites

I have searched for "zero crossing detector" and all the circuits I see are for AC sine waves that are referenced around a positive supply, a negative supply, and a ground. In my situation, I only have 5v and GND, I do not have -5v.

The sine wave I am trying to convert into a square wave is biased at about 2.5v between the 0v and 5v rails . I am still searching, but I have not found a peak detector that works using a single supply. I would think a single supply peak detector exists because I thought they used in RF demodulators or discriminators.

Edited by jheissjr

Share this post


Link to post
Share on other sites

The +/- powered solutions are common for AC mains zero crossing circuits. Since your signal is reference above ground, the neg rail supply solutions are not needed. But, if you cannot find a canned solution, you would have to create your own.

Another way to solve this is to AC couple the incoming sinewave into an Opamp. With sufficient gain (100X would be good), the output would offer a squarewave. An LM358 and a handful of resistors is all it would take. The LM358 data sheet will probably have some examples of amplifier configurations.

Share this post


Link to post
Share on other sites

I was also thinking about AC coupling the signal. So I would feed the sine wave into the +input and hook the -input to ground? If I AC coupled the signal, does my picture look right as to how I am picturing it would work?

post-6-1143007384_thumb.jpg

Share this post


Link to post
Share on other sites

Do you have any PIC microcontroller experience? You can shove the sine wave into an analog to digital converter pretty easily and make a square wave out of it.

That would even let you change the crossover point anywhere from 0 to 5 volts in the program. Just my 2 cents.

Matt

Share this post


Link to post
Share on other sites

Yes, the reason I am trying to convert a sine wave into a square wave is so I can feed it into a PIC. In stead of using the ADC and a software algorithm to find the frequency, I thought it would be easier and less CPU demanding to use a square wave input where a pin change interrupt and a timer could be used to find the waves period/frequency. Do you think this is do-able

Edited by jheissjr

Share this post


Link to post
Share on other sites

Just with a quick thought on it, if u don't want to get too fancy code wise and use PicBasic pro without INTs, you can just use a if.then loop with a set pause in it.

ADC timing is set in Picbasic at the beginning of the program, I usually use 30-50uSec, more then enough. Get into a loop, check the a/d line, when the a/d gets over a certain value, pause, then check it again. When it changes back over, look back at your counter you have been incrementing every pause and you know your pulsewidth.

I'm not an expert programmer and some would call that dirty programming but hey, it works :D

Matt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×