Synchronized square wave output
Ching Lin
Posts: 11
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
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
You can use the time between zero crossings to work out the frequency and also use them to generate the square wave directly.
Graham
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
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
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
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