Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Creating a square wave pulse at the peak of a sin wave

  1. Jul 12, 2012 #1
    Hi all,

    I am trying to create a square wave pulse that lasts for a relatively small amnount of time which corresponds (as close as possible) to the peak of a sin wave input of period about 1 second.

    The only way that I can think of doing this is via a programmable device such as an arduino to create the signal. I am sure that there would be a clever electronic way that this can be done but I do not know enough about the subject.

    I hope that that is clear enough. Can someone point me in a good direction?

    Thanks in advanced
  2. jcsd
  3. Jul 12, 2012 #2
    You can use a comparator for level detection. The output will be a pulse that is only high for as long as the sine wave is larger than the reference level you set on the comparator. You can stretch this pulse out or do other things by adding hysteresis or driving a one-shot with the comparator, but the basic idea is to use a comparator. You just need to be careful how you define your pulse width, level detection, and the problem of noise causing false triggers.

    Last edited: Jul 12, 2012
  4. Jul 12, 2012 #3


    User Avatar

    Staff: Mentor

    Welcome to the PF.

    To reliably get as close to the peak as possible, yes, the best solution will be digital. You can either use a uC as you suggest, or you could make a CPLD circuit to do it. In both cases, you would be counting the time between zero crossings, and using half of that (plus knowing the polarity +/- of the sine wave signal) to trigger your square pulse.

    EDIT -- if the sine wave were not so slow (like if it were more like 1kHz), you could do an analog differentiation with an opamp to get a cosine function, and use its zero crossing as your trigger...
  5. Jul 12, 2012 #4

    jim hardy

    User Avatar
    Science Advisor
    Gold Member

    From an old obsolete analog guy -

    if you integrate a sinewave two things happen
    1. you shift it 90 degrees so the zero crossing of your new signal coincides with the peak of your original signal .
    As Berkeman suggested, and wisely, that is a more friendly condition to detect necause it's pretty independent of variations in amplitude of original signal.
    2.You attenuate the high frequency 'noise' that is so troublesome to fast analog comparators.

    I'd hand integrated sinewave to a zero crossing comparator and trigger a monostable from result.

    A differentiated sinewave will have more noise than it did as un-differentiated. Differentiation amplifies noise. It's basically highpass filtering.
    Integrated sinewave will have less noise than un-integrated. Integration attenuates noise. It's basically lowpass filtering.
    Only difficulty with pure integrators is keeping them zeroed but a R-C with long time constant relative to sinewave's period does an admirable job of approximate integration...

    old jim
    Last edited: Jul 12, 2012
  6. Jul 13, 2012 #5
    Thank you all very much for the replies.
    That is a very clever idea and defenitely something that I will look into.

    However, I would like to trigger only on the peak of the sin wave, not twice per period. Unless I am mistaken this will trigger every time the integrated signal crosses zero.
  7. Jul 13, 2012 #6
    Try this circuit. It is designed to work on positive peaks only and is adjustable by the pot.
    The values of the shunt cap and collector resistor may need tweaking.
    The output will require squaring up to the desired length of pulse.

    Attached Files:

    Last edited: Jul 13, 2012
  8. Jul 13, 2012 #7


    User Avatar

    Staff: Mentor

    You said a period of about 1 second. Is this a fixed, known frequency, or will it vary? If variable, what percentage variation from 1 second?

    It may be feasible to generate an additional pulse, one of, say, 0.6 seconds, and use this to block that unwanted pulse at 0.5 secs. Otherwise a "divide-by-two" counter could be used to eliminate one out of every pair of pulses.
  9. Jul 13, 2012 #8

    jim hardy

    User Avatar
    Science Advisor
    Gold Member

    "Edge Triggering" is another option.

    When driven from point A this will trigger on falling edge of comparator output and ignore rising edge. You'd choose a simple DC level comparator then, comparing integrated sinewave to zero.

    Sooo many circuits, so little time !

  10. Jul 13, 2012 #9
    Ah that seems perfect! Thanks a lot jim really helpfull.

    (I just found this and was having a little play with it

    Must say the whole process does seem quite complicated but it does look like it will do the trick. Now just to have a little play around.
  11. Jul 13, 2012 #10
    Build an operational amplifier adder circuit. (sometimes called summing amplifier)
    Apply a sine wave from a function generator to input of adder circuit.
    Apply pulse from a function generator to different input of adder circuit.
    View output of adder circuit on oscilloscope.
    Adjust sine wave and pulse to get whatever you want.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook