Building a Basic Square Wave Oscillator: A Beginner's Guide

In summary: If you already have a suitable 60 Hz sine wave, you could indeed just pass it through an inverter to obtain a 60 Hz square wave. You could use a very cheap chip, like the 7400, which has six inverters on it.If you want to produce a more customised waveform, you'll need to buy a digital inverter. Schmitt triggers and J-K flip flops can produce square waves, but they are not as customisable as a digital inverter.Thanks for the advice.
  • #1
Adder_Noir
239
0
Hi,

I promise I did search for this before posting what I thought would have been something which had been answered before.

Can anyone tell me how to build a simple square wave oscillator? Do I need a differentiator to get the straight vertical lines? I'd appreciate any help anyone could offer me.

Please also remember I'm a novice, thanks :redface:
 
Engineering news on Phys.org
  • #2
Most people just buy them for a couple cents a piece -- they're called crystal oscillator modules.

Is there a reason why you want to develop your own from scratch? If so, the easiest method is to make a simple resonant circuit that produces a sine wave, and then use that to drive a digital inverter. The output of the inverter will be a square wave.

- Warren
 
  • #3
chroot said:
Most people just buy them for a couple cents a piece -- they're called crystal oscillator modules.

Is there a reason why you want to develop your own from scratch? If so, the easiest method is to make a simple resonant circuit that produces a sine wave, and then use that to drive a digital inverter. The output of the inverter will be a square wave.

- Warren

Ah apologies I did not know they were so cost effective. Thanks for that. Out of curiosity I'm working with AC so the sine profile is already there so would it possible for me to customize it a bit more using a digital inverter, or would I now need to just buy a digital inverter due to my input being a sine wave from the mains?

Sorry for so many questions.
 
  • #4
Hey, we love answering questions! :smile:

If you already have a suitable 60 Hz sine wave, you could indeed just pass it through an inverter to obtain a 60 Hz square wave. You could use a very cheap chip, like the 7400, which has six inverters on it.

Be careful, though -- chips like the 7400 can only tolerate voltages between 0V and 5V, which means you'd need to find some way to scale your sine wave down so it has an average value of 2.5V, and goes no lower than 0V and no higher than 5V. This can be done with a couple of resistors and a single capacitor, so it's pretty easy.

I have to issue the standard boilerplate warning though: why are you working with the mains? You can hurt yourself pretty badly with mains voltages, so be very careful! Circuits that use such high voltages require a lot of expertise to avoid injury or fire. I strongly advise that you use a transformer or some other pre-made device to drop mains voltage down to something safer before playing with it.

- Warren
 
  • #5
If your sinewave is 0-5 volts you may want to use a schmitt trigger or J-K Flip Flop to make a square wave, but with both of the devices there may be some phase change due to how they are being changed from a sine wave to a square wave.
 
  • #6
chroot said:
I have to issue the standard boilerplate warning though: why are you working with the mains? You can hurt yourself pretty badly with mains voltages, so be very careful! Circuits that use such high voltages require a lot of expertise to avoid injury or fire. I strongly advise that you use a transformer or some other pre-made device to drop mains voltage down to something safer before playing with it.

- Warren

Nice one mate thank you :wink: Don't worry about the mains stuff I'm a qualified spark and the application is for a small portable device so there won't be too much potential for danger especially as all the work will be done with the 50Hz 240V supply disconnected :wink:

Great technical advice on the chip :redface:
 
  • #7
chroot said:
Be careful, though -- chips like the 7400 can only tolerate voltages between 0V and 5V, which means you'd need to find some way to scale your sine wave down so it has an average value of 2.5V

I was thinking of a good potential divider using power resistors. The output then being fed into the inverter then being feed into the base of a transistor. Of course due to the motor being there I need a diode to sink the inductive load on permanent switch off.

chroot said:
and goes no lower than 0V and no higher than 5V. This can be done with a couple of resistors and a single capacitor, so it's pretty easy.

What would I need the capacitor for by the way? As a filter perhaps?

Thanks.
 
  • #8
Emicro said:
If your sinewave is 0-5 volts you may want to use a schmitt trigger or J-K Flip Flop to make a square wave, but with both of the devices there may be some phase change due to how they are being changed from a sine wave to a square wave.

Hi that's probably not an issue given the rudimentary nature of the device being worked on.
 
  • #9
Adder_Noir said:
I was thinking of a good potential divider using power resistors. The output then being fed into the inverter then being feed into the base of a transistor. Of course due to the motor being there I need a diode to sink the inductive load on permanent switch off.

You don't need power resistors, since you don't intend for the resistors to actually dissipate any power. You just need two very very large-valued resistors with the right ratio, used as a voltage divider to scale down your sine wave so that it's 5V peak-to-peak. It'll still be centered around 0V, though, which is not going to work.

Next, you need to shift this up 2.5V. You can make another resistor divider between +5V and 0V to get 2.5V. Finally, you can couple the sine wave to this divider with a capacitor. (Capacitors "pass" AC, but "block" DC.) The result is a 5V peak-to-peak sine wave, centered around 2.5V.

- Warren
 
  • #10
Thanks Warren that's great I'll post up a prelimnary sketch later this week. Nice one pal thanks a bundle :wink:
 
  • #11
Keep in mind that all of this circuitry will result in a square wave from 0V to 5V. It also will require a +5V DC power supply. If that's not the kind of square wave you want, let us know.

- Warren
 
  • #12
chroot said:
Keep in mind that all of this circuitry will result in a square wave from 0V to 5V. It also will require a +5V DC power supply. If that's not the kind of square wave you want, let us know.

- Warren

Thanks again. Here's a rough attempt at a design. I haven't drawn in where the +5V bit should go (I think on the second divider as a bias for the sine wave to ride on?). This is also I believe a half wave rectified circuit. Not sure if that's needed but can't see how the transistor bit will work any other way. Also managed to get my protection diode in too!

Have a look please just dont' shoot it down in flames too much lol

http://i207.photobucket.com/albums/bb281/adder6/circuit.jpg"
 
Last edited by a moderator:
  • #13
Well, the capacitor should be between the midpoint of the mains divider and the midpoint of the 5V divider. And both dividers need to be connected to ground at the bottom.

- Warren
 
  • #14
I see, I'll change those for the next go. Thanks.

*Done*

http://i207.photobucket.com/albums/bb281/adder6/circuit-1.jpg"

I assume that if I made the initial signal voltage divider resistors too high then not enough current would flow through the base to turn on the transistor. Can anyone recommend some values? Several hundred k's perhaps?
 
Last edited by a moderator:
  • #15
Adder_Noir said:
I assume that if I made the initial signal voltage divider resistors too high then not enough current would flow through the base to turn on the transistor. Can anyone recommend some values? Several hundred k's perhaps?

You don't need any current to flow into the inverter -- inverters are composed of MOSFETs, and have insulated gates. They respond to voltages, not currents.

- Warren
 
  • #16
Ah super, so I just need high values of R. Brilliant. I'll be in touch and let you know how it goes. Will be assembling something next week. Just before we let the thread go cold can you think of anything about the design that presents a major issue, or do you think from a design (not a safety) perspective I can proceed?
 
  • #17
Hi I've had a look at some power transistors and I was wondering what Vceo means? Really I'd like to simply put 240V across it and play with the current using the variable resistor (control knob) earlier in the circuit rather than have the maximum potential snubbed.

I noticed most had a max Vceo of 60V does this mean that's all I can put on the collector?

Once I've understood this little piece and I've sourced a cheap inverter I'll be building!

*Edit*

Update, just to recap though, given that the unit will be half-wave rectified (thus providing lower speed) and the inverter will only turn on the transistor when the signal voltage acts against the 2.5V to drop it... doesn't that mean that the transistor will only conduct during a negative cycle and that negative cycle can not deliver any power due to the rectifiying diode thus meaning the motor will never run?

If the above is true can I get around it by running two inverter's in series? (the 7416 chip comes with 6 or 8 inverters).
 
Last edited:
  • #18
I've only skimmed the thread, but Adder_Noir, I think there's been a bit of a disconnect here.

BVceo is the breakdown voltage from collector to emitter with the base left open (or with relatively high resistance bias), and yes, it will typically be in the range of 40V to 60V for small signal transistors. If you wanted to have a BVceo high enough to handle 240Vrms (quiz question -- what rectified voltage does that give you?), you are talking about using very high voltage transistors (big) like we use in off-line switching power supplies.

But the others who have been helping you have been talking about a low-power, low-voltage circuit for you to make a square wave of a few volts. And now you are talking about using that small square wave to drive power transistors interfaced to the 240Vrms AC mains?

BTW, you mention that this is for a portable device, and that would normally mean it is battery powered. How does a portable device get access to the AC mains 50/60Hz?
 
  • #19
Hmm... perhaps with that it should be dismissed. There's a pre-existing motor control circuit present which I wanted to modify. It's for an angle grinder/polisher. In the United Kingdom we still refer to plug-in devices as portable in the electrical trade.

I wanted a square wave to operate a transistor's base which would kill and enable the mains supply through the collector. This would half the time the motor was being driven but give me control as to how much juice was sent in during that period, thus potentially beefing up the torque without increasing speed.

That's basically it. Now it's better explained would it still work, perhaps if using the transistor to turn on a relay which could handle the through power/current?
 
Last edited:
  • #20
It sounds like you should be looking into PWM control of the motor drive...see the power applications section of this page, for example:

http://en.wikipedia.org/wiki/Pulse-width_modulation

You can modulate the AC drive to the motor, much the way a light dimmer circuit works with a triac. Are you familiar with those kinds of circuits?
 
  • #21
I'm not no, I'm a decent spark but a tronics noob I'll have a good look at that page thanks berkeman. By the way how long did it take you to read H&H's book it's going to take me well over a year lol :redface:

*Edit*

Just had a a quick look. Clever. Very clever. They've used pulses which vary sinusoidally in width over time to create a desired output. Amazing idea. I assume such things give rise to brilliant motor contol when it comes to choices of speed and torque!
 
Last edited:
  • #22
Just had a good read through and seen how sawtooth waves are used in conjunction with sine waves and a comparator to produce 'digital' pulses which can have varied width depending upon how the sawtooth wave interfaces with the sine wave.

I assume my original idea was just too crude to function correctly? I assume the modulated signal is then sent into the rotor to excite it and make it spin in a permanent magnet on my grinder (it has no electrical connection to the stator). So I must ask were I to pursue this new more advanced avenue what kind of pulse modulation gives higher torque for lower speeds? I know it can be done because ABB drives can do it.

I assume I was wrong thinking that the 240V goes straight into the exciter too. I guess it goes through a resistance first which is why they can be switched using a transistor.
 
  • #23
Well, now that I know more about your application, it's true -- my little inverter idea won't have enough drive strength to turn on an enormous power transistor.

And if you're looking at varying the speed of the motor, then you definitely do want some kind of PWM. Berkeman's got this one.

By the way, it makes things much easier for us if you actually post the complete application in your initial post, rather than asking a vague question like "how do I make a square wave oscillator" without any context.

- Warren
 
  • #24
Adder_Noir said:
By the way how long did it take you to read H&H's book it's going to take me well over a year lol :redface:

I didn't find the book until I was already out working as a new MSEE. A friend of mine had gone to MIT, where H&H was an intro textbook. I was doing something subtly stupid in an opamp bias circuit in a new circuit I was working on, and happened to look in my friend's H&H book to double check something. Right there on the page it warned against the mistake I was making! So I went over to Stanford the next day and bought a copy of the book. I think it took me about 3-4 weeks of reading it evenings and weekends, but I read it cover-to-cover. Of course, it was mostly review, but I still picked up on a number of things that I hadn't learned in my undergrad basic electronics classes, and hadn't stumbled across in my real-life work yet. That read has saved me hundreds of hours of time off in the weeds, I would estimate. :tongue2:
 
  • #25
We're talking about The Art of Electronics, I presume?

- Warren
 
  • #26
Apologies for the lack of explanation regarding purpose :redface:

Yes the art of electronics alright. Bugger me it's hard going 4 weeks and I'm only on page 85! I have an engineering honours degree too! I guess some things were just not meant to be easy for some people lol.
 
  • #27
Hi,

Would this item:

http://www.farnell.com/datasheets/64094.pdf"

be a suitable comparator for building a PWM circuit for the polisher? I think I know how to make a sawtooth wave using a transistor as a current source and make the load a capacitor. If I remember correctly current sources and capacitors make perfect ramp signals? Could I use this comparator for the sine wave cross referenced to a sawtooth to get my pulses?

Is 0.004ms fast enough?

Just as a side note I doubt I'll ever make anything like this I'm just trying to advance my all round electronics knowledge which is why I'm asking some questions which might appear to be jumping the gun a bit, thanks for your understanding :redface:
 
Last edited by a moderator:
  • #28
If I understand correctly you want to make a grinder controller such that by reducing rpm you want to retain more torque under loading conditions and keeping constant rpm.

The problem with this is by reducing current to the grinder, rpm slows down like you want to but also torque is less now.


The best way to solve this is not the easiest. You have to build a controlled feedback loop such that current to the grinder is monitored by the circuit, or rpm is also monitored.

When loading the grinder with torque, rpm slows down, that is sensed by the feedback loop and it automatically raises the current to the grinder until a constant rpm is reached. The feedback loop continuously adjust the output current to keep rpm constant.
 
  • #29
waht said:
If I understand correctly you want to make a grinder controller such that by reducing rpm you want to retain more torque under loading conditions and keeping constant rpm.

The problem with this is by reducing current to the grinder, rpm slows down like you want to but also torque is less now.


The best way to solve this is not the easiest. You have to build a controlled feedback loop such that current to the grinder is monitored by the circuit, or rpm is also monitored.

When loading the grinder with torque, rpm slows down, that is sensed by the feedback loop and it automatically raises the current to the grinder until a constant rpm is reached. The feedback loop continuously adjust the output current to keep rpm constant.

Nice reply thanks mate. I did a bit of control at university. Could the afor mentioned comparator be used as the adder/subtractor at the very start of the feedback loop? Also could one simply use a proportionate gain as the transfer function in such a circuit, or would a complex transfer function be needed?

Again this is all pie-in-the-sky but it's great for my understanding thanks.

*Edit*

Here's a quick rough attempt at a current matching comparator circuit. Note the coil is not meant to mean an inductor it's meant to represent the motor resistance, sorry for bad use of symbols!

http://i207.photobucket.com/albums/bb281/adder6/circuit.jpg"
 
Last edited by a moderator:
  • #30
What you sketched there wouldn't work, it looks like it's just a voltage limiter. This would reduce voltage hence torque to the grinder. Is the grinder AC ?
 
  • #31
waht said:
What you sketched there wouldn't work
Bugger, thought not.

waht said:
Is the grinder AC ?
It is yes.

Thanks for taking an interest :wink:
 
  • #32
I lied I think. Sorry I've looked at it again and it looks like there's a commutator there so it's probably DC I would guess. Not too sure. I think it's best this topic gets retired now while I do some more work. I'll open a new topic when I've got a bit further that's more relevantly titled, thanks to everyone who contributed.
 

1. What is a square wave oscillator?

A square wave oscillator is an electronic circuit that produces a square wave output signal. A square wave is a type of waveform that alternates between two voltage levels, typically a high voltage and a low voltage, in a regular and symmetrical pattern.

2. What are the components needed to build a basic square wave oscillator?

The basic components needed to build a square wave oscillator include a power source (such as a battery or power supply), a resistor, a capacitor, and an operational amplifier (op-amp). Optional components may include a potentiometer and a diode.

3. How does a square wave oscillator work?

A square wave oscillator works by using the feedback loop of an op-amp to generate a continuous oscillating signal. The resistor and capacitor in the circuit create a time delay, which causes the op-amp to switch between its high and low states, producing the square wave output.

4. What are some common applications of square wave oscillators?

Square wave oscillators are commonly used in electronic devices such as clocks, timers, and pulse generators. They are also used in audio equipment, such as synthesizers and sound generators, to produce specific waveforms and tones.

5. Are there any safety precautions to keep in mind when building a square wave oscillator?

Yes, it is important to always follow proper safety precautions when working with electronic circuits. This includes wearing appropriate protective gear, such as safety glasses, and ensuring that the power source is disconnected before making any changes to the circuit. It is also important to double check all connections and components before powering on the oscillator to avoid any potential hazards.

Similar threads

Replies
16
Views
1K
  • Science and Math Textbooks
Replies
7
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
859
  • Electrical Engineering
Replies
8
Views
5K
Replies
78
Views
3K
  • Differential Geometry
Replies
5
Views
4K
  • Electrical Engineering
Replies
4
Views
3K
  • Electrical Engineering
2
Replies
43
Views
11K
Replies
12
Views
2K
  • Electrical Engineering
Replies
33
Views
4K
Back
Top