Shop OBEX P1 Docs P2 Docs Learn Events
Synchronized square wave output — Parallax Forums

Synchronized square wave output

Ching LinChing Lin Posts: 11
edited 2007-03-05 21:02 in Propeller 1
Hi,

I am trying to use Chip's ADC.spin (http://forums.parallax.com/forums/default.aspx?f=25&m=115264) to generate a square wave from a second cog.
1) The square wave will be running at a fix frequency (60 Hz) if the input sine wave is not available or out of 58~62 Hz range.
2) The square wave will synchronize to the input sine wave only to the above frequency range.
3) The response time is not critical, half of a second will be acceptable.
4) The square wave output will be connected to a full bridge driver, 3.3V logic is OK.

Thanks in advance
Ching Lin

Comments

  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-03-04 18:17
    If you take the average value of the sinewave measured you will get the DC bias. Every time the value measured crosses this you have the zero crossing of the sine wave.

    You can use the time between zero crossings to work out the frequency and also use them to generate the square wave directly.

    Graham
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-03-04 22:33
    Hi Ching,

    A second cog probably won't be necessary. The ADC input could use CTRA and the square wave output could use CTRB, with logic in the associated COG linking the two and enforcing the +/-2 Hertz limits. Is there an possible issue with input signal to noise ratio or harmonic content?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Ching LinChing Lin Posts: 11
    edited 2007-03-04 23:38
    Hi Tracy,

    I am planning to use your magicsines2.spin to drive a full bridge to generate the synchronized sine wave, which I think required a dedicated cog.
    There is no issue with signal to noise ratio or harmonic content.

    Thank you so much.
    Ching Lin
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-03-05 18:03
    Would you use the full bridge as two half bridges, driving first one side high and then the other?

    You are probably right about using a separate cog for the ADC, although it would not be out of the question to do it in the same one if need be. There are points in the magicsine program where it could do other tasks without tripping up on the output edge. The task might be simplified somewhat with an external comparator, to turn the sine wave input into a square wave.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Ching LinChing Lin Posts: 11
    edited 2007-03-05 21:02
    Hi Tracy,

    Yes, it is driving first one side high and then the other, only it has two switches on each side. First turn T1 on while modulating T4 for half cycle and then turn T3 on while modulating T2 for another half cycle. Please see attached full Bridge.png. 5 pins (one for the input sine, 4 for the full bridge) are required, but two counters can provide up to 4 pins only.

    I have tried to disable the feedback on the sigma-delta ADC circuit to generate a square wave, but I have not found a way to measure their phase difference yet.

    Zero crossing detector with external comparator is a good idea to consider too.

    Thanks,
    Ching Lin
    350 x 125 - 2K
Sign In or Register to comment.