Simple Square Wave Oscillator

  1. 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:
     
  2. jcsd
  3. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  4. Ah apologies I did not know they were so cost effective. Thanks for that. Out of curiousity 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.
     
  5. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  6. 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.
     
  7. 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:
     
  8. 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.

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

    Thanks.
     
  9. Hi that's probably not an issue given the rudimentary nature of the device being worked on.
     
  10. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  11. Thanks Warren that's great I'll post up a prelimnary sketch later this week. Nice one pal thanks a bundle :wink:
     
  12. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  13. 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
     
  14. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  15. 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: May 16, 2007
  16. chroot

    chroot 10,427
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  17. 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?
     
  18. 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: May 17, 2007
  19. berkeman

    Staff: Mentor

    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?
     
  20. 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: May 17, 2007
  21. berkeman

    Staff: Mentor

    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?
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook