Methods for converting a sine to sqaure wave

Discussion in 'The Projects Forum' started by cha1n, May 10, 2007.

1. cha1n Thread Starter New Member

May 10, 2007
8
0
Hi,
I require a circuit that can convert a 10mV input signal ranging from 50Hz to 3Khz and create a 3V square wave output (Of the same frequency of the input).

If nobody can give me some simple ideas to play with could you please let me know any methods i can use, like how i could arrange transistors, op-amps etc. Thanks for any help

Ross

Apr 2, 2007
1,211
0
3. mozikluv AAC Fanatic!

Jan 22, 2004
1,437
1
u have to rectify your sinewave signal first but before you can do that you just have to amplify that 6mv up to at least 700mv for you to start rectification. take your choice, either you go opamps or discretes.

moz

4. thingmaker3 Retired Moderator

May 16, 2005
5,072
6
LM339 w/ voltage divider on o/p?

5. cha1n Thread Starter New Member

May 10, 2007
8
0
Well i was thinking about amplifying the input, then using a voltage limiter or zener to limit the output.

Mozikluv; Could you elaborate please? If i (half wave?) rectify the input, i'd then have to amplify and chop the output? Sorry if i'm making no sense.

Ross

6. recca02 Senior Member

Apr 2, 2007
1,211
0
i believe what mr mozikluv meant was to be able to rectify the sinewave signal,
the signal must be at least able to exceed the cut in voltages of diode .
6mv is far too less hence an amplification is needed.

btw: since my electronic knowledge is limited , wud someone tell me if i m wrong when i say that a opamp with open loop gain
considering it is 10^5 for 741 if i remember correctly wud amplify any sinewave signal to saturation and hence a square wave wud be obtained?

7. cha1n Thread Starter New Member

May 10, 2007
8
0
Oh i see, thank you for clearing that up. Well i was expecting to have to amplify the input (10mV) to at least the 3V output required, if not more for the clipping of the output to occur. My only concern is how the range of frequencies (50Hz - 3Khz) would effect transistor and/or op-amp circuits.

In theory i'd like to have at least three possible methods of achieving this and at the moment i'm thinking op-amp/transistor/IC. I'm just not 100% sure how to implement with my limited knowledge of small signal amplification. Any more help will be greatly appreciated. Regards,

Ross

8. recca02 Senior Member

Apr 2, 2007
1,211
0
of course there is that gain bandwidth product that puts a lmimt on the frequency range for a certain gain.
but i think that limitation can be overcome by the use of more than one amplifier.
some of the amplifiers have a good value of gain bandwidth product.
if i remember correctly its 1 MHz for 741 ic

9. CaliusOptimus Well-Known Member

Aug 14, 2005
59
0

you can use one opamp with negative feedback to amplify up to 3v, then another to convert from sine to square wave, as seen in the tutorial. are you using a single or double ended power supply?

10. mozikluv AAC Fanatic!

Jan 22, 2004
1,437
1
as a starter use the a low drop diode (germaniums) in bridge config and use NE5532 for a GBP of 10Mhz and a slew rate of 9V/us and can supplied down to +/-5v or you can also use OPA2134 with a GBP of 8Mhz, slew rate of 15. and use a dual rail supply.

moz

11. gootee Senior Member

Apr 24, 2007
447
50
Hi, recca02.

I don't think this application has anything to do with rectification, by the way, but, with an op amp and one or two diodes, and a resistor or two, simple "ideal diode" and "precision rectifier" circuits can be created, which can also rectify very SMALL signals, very well.

Regarding your opamp question: If an opamp must be used, instead of a proper comparator, there are more-or-less standard ways of doing it, usually with a _positive feedback_ resistor (and maybe a small cap in parallel with it), and a couple of resistors to set the "switching" threshold. That way, it performs better and also has some hysteresis, so you don't get rapid "bouncing" of the output for small input signal variations around the threshold voltage.

For this application, though, thingmaker3 was, in my opinion, exactly correct, in suggesting a real comparator IC with a two-resistor voltage divider after its output.

A comparator is made similarly to an op amp, but is specially designed to make its output ONLY swing rapidly to either extreme, depending on the polarity of its input. If an op amp is used, instead, even with the proper "op amp as comparator" setup mentioned, there still might be performance deficiencies (at least when compared to using a real comparator IC), because of op amps' tendencies to not come out of saturation very gracefully or quickly, IIRC, and probably other reasons.

- Tom Gootee

http://www.fullnet.com/~tomg/index.html

-

12. recca02 Senior Member

Apr 2, 2007
1,211
0
hi mr Gooty,
yeah i was thinking abt that too but i was trying to clarify the doubt of chain there, i thought maybe there was a need .

13. cha1n Thread Starter New Member

May 10, 2007
8
0
Thanks for the replies to date. If there are some methods which aren't 100% that's perfect as this is for a college project it will give me a reason not to use them and put the reasons in my analysis. So sounds like using a comparitor is the answer? Any circuit examples on the internet that i can try in electronics works bench? Thanks

14. gootee Senior Member

Apr 24, 2007
447
50
The comparator manufacturers' websites should be the first obvious place to look. e.g. Go to http://www.national.com and enter LM339 or LM311 in the search box. When your get to the product webpage, download the PDF datasheet, and then any relevant-looking application notes. If there aren't enough example circuits in those, you can either go to the product-selector pages and find other comparators and download their datasheets and appnotes, or go to the appnotes' main page and search or browse all of the application notes, or do a whole-site search for "comparator" or a part number, or search in the KnowledgeBase.

There are also many other IC manufacturers, all with datasheets and appnotes, many with lots of example circuits. You can try analog.com, ti.com, linear.com, st.com, and many others.

Another good way to find datasheets is to go to someplace like http://www.mouser.com and do a search for "comparator", or for a particular part number. The products in the resulting list will usually have a datasheet link, with them, as well as a link to a link to the manufacturer's website. Digikey.com has them, too, but you have to click through a couple more pages, for each part, to get to the datasheet link.

There are lots of other types of websites that have schematics, etc, for many different types of circuits. Google should find many of them, for you.

Good luck.

- Tom Gootee

http://www.fullnet.com/~tomg/index.html

-

15. cha1n Thread Starter New Member

May 10, 2007
8
0
Thanks for the extra help. I've searched the site and datasheets and i've got to admit, i have no idea which circuits are suitable and what ones aren't. You see i have no idea how these comparators work so i don't understand the names of the circuits they are referring to in the datasheets.

I'm going to try and find how they work etc from the internet, see if that helps..

16. hgmjr Moderator

Jan 28, 2005
9,030
214
Take a look at this experiment description showing an opamp used as a comparator located on the All About Circuits ebook section.

The use of an op-amp as an comparator is not normally done since there ample comparator devices available. I offer this link as a way of getting acquainted with the behaviour of a comparator.

hgmjr

17. cha1n Thread Starter New Member

May 10, 2007
8
0
I sort of managed to make a circuit with a LM311, but to be honest there's not anything to the circuit and the square waves edges are a bit slanted. Also i have no idea how to calculate what size supply to use i just did trail and error until i got what i wanted..

18. cha1n Thread Starter New Member

May 10, 2007
8
0
Would someone be able to help me out with design please? At the moment (in my simulation on EWB) i've got the vref going straight to ground, i've got no resistors in the circuit at all and it's sort of working. I'm just wondering how important the resistors are if i haven't got them in and it seems to be working ok. If you can give me the equations for working out suitable resistor values could you explain to me why they are needed in the below circuits, thank you

19. hgmjr Moderator

Jan 28, 2005
9,030
214
In the upper circuit diagram, R2 and R1 form a simple resistor voltage divider. This voltage divider is used to set the voltage to which the input signal is compared within the comparator to determine when the comparator's output swings from the positive to the negative power supply potential and conversely negative to positive depending on which of the two inputs the input signal is connected. R3 is not that critical to the operation of the comparator. At least at low frequency signals less than a few 100 KHz.

The lower comparator is most likely the type of comparator whose output is an open collector. These types of comparators require a pull-up to produce an output signal. That is why R3 is provided. Again, R1 and R2 form the voltage divider that set the switching voltage threshold.

hgmjr

20. gootee Senior Member

Apr 24, 2007
447
50
OK. Here's a specific circuit that should work for your original specs. (I'm assuming that you have a +/-10mV sine input and want a +/-3V square output.)

Using an LM311-type of comparator (i.e. open-collector type of output [See the LM311 datasheet, at national.com]), and +/-15v supply voltages:

Connect your +/-10 mV sine to either the + or - comparator input and then ground the other input.

Connect something like 22k Ohms from comparator's output pin to positive supply. (i.e. Use a high-enough R value to avoid dissipating too much power.)

Connect "1 Meg in series with 270K" from comparator's output pin to ground. (The values just need to be much larger than the 22k R.)

Connect a 2.2pF capacitor from comparator's output pin to ground. (Forms a low-pass filter with the R's, to clean up the output. Try it with and without it. Vary the C value and see what happens, for different frequencies.)

[Note that, in a real circuit, you would also want something like 0.1uF, and maybe more, from each power pin to ground, or .01uF or so and some larger size in parallel from each power pin to ground, probably using a different ground trace than your output divider uses, with both of those using different ground traces than your grounded input uses. You can simulate those effects by inserting small R and L values in series in each ground connection, and then try tying them together in different ways, i.e. either sharing a common R and L of the trace, or not.]

Take your output from between the 1 Meg and 270k resistors. (The comparator output swings nearly to each supply rail. This is just a voltage divider, to get only a portion of it as your final output.)

Adjust the 1 Meg and/or 270k until you get the final-output amplitude desired.

1 Meg and 255.5k gets very close to 3V 0-peak out, for a 10 mV 0-peak sine input, with +/-15v supplies. In place of the 270K R, you could use a standard 249K value with a 10K trimmer potentiometer in series with it, or maybe just use standard 255K and 499 Ohms values in series, if you're sure-enough of everything else that might affect the output level.

You'll probably need to follow the output of the voltage divider with an opamp or other voltage-follower buffer, depending on what you're trying to drive with it.

That is just an example. You wouldn't really need to use such large supply voltages, unless they're already available. You could probably use +/-5V, or even less. You only really need large-enough supply voltages to enable the output to swing to at least the amplitude you need (and a comparator can make the output swing fairly close to the supply voltages' levels). But you'd need to check the datasheet for the comparator you planned to use, to make sure it could operate as needed with the voltages you wanted to use, etc etc.

With +/-5V supplies, for example, the resistor from the comparator output to +5V could be 9.1k and the divider for the output could be approximately 51k with 91k to ground. (Note that, in this case, adjusting any of the three resistors' values might cause a noticeable offset-voltage change in your output, which might require tweaking the other R values, or using AC coupling on the final output, if it matters.)

Good luck.

- Tom Gootee

http://www.fullnet.com/~tomg/index.html

-