How to use a discrete time VCO to generate a synchronised square wave? (simulink question)
7 views (last 30 days)
Show older comments
Hi all. In Simulink, I tried to pass the output of a discrete-time VCO through a zero-crossing detector block. My aim is to produce a squarewave, and the squarewave needs to have its rising edges AND its falling edges synchronised with the ideal zero-crossings of the discrete sinewave of the VCO.
My problem is that the zero-crossing detector output has rising edges occurring at 0.5005, 1.0005, 1.5005 seconds etc. (instead of being exactly at 0.5, 1, and 1.5 seconds). The falling edges are also offset by a small amount of time.
To try get around the issue, I created a function block that basically detects values that are 'relatively' close-to-zero, such as ABSOLUTE VALUE of the discrete time VCO output being <= 1e-8. Relatively close to zero will just mean cases where the discrete sinewave instantaneous value becomes very close to a zero. Every time this 'close-to-zero' condition is detected, I flip the output of my detector.
I notice that computer rounding leads to issues where the discrete VCO output is not EXACTLY 0.0 (at the hypothetical zero crossing point). This means that zero-crossing values could be values like 1E-12 or -5E-13 (instead of being exactly ZERO at the zero crossing). This means that a 'zero crossing' detector is not going to be able to generate a perfectly synchronised square wave - since we don't get perfectly 'zero' values at the zero crossings.
So my function block has the purpose of rounding-off any relatively tiny values to zero. The rounding helps with generating the correct square wave output (ie. with rising edges occurring at the correct times). However, I don't think my rounding method will be completely reliable. Reason: due to simulink/matlab accumlating the rounding error (as time progresses), the thresh-hold value (such as <= 1e-8) will eventually not work. So my method work will work, but only up to a certain point in time.
I have attached my simulink file (from matlab 2013) that shows a square wave output (from the output of a general simulink zero-crossing detector...ie a compare-with-zero block) that doesn't rise and fall at the desired time; and it also shows the desired output (ie. output of my function block method). These outputs can be seen in the simulink SCOPES.
Is there a better method that I could use for generate synchronised square waves from a discrete VCO? I would like to find a method where I know (for sure) that every rising edge is properly aligned with the zero-crossing of the VCO? I'm looking for a method that will have correctly aligned rising edges (regardless of the length of simulation time).
Thanks for any help in advance!!
0 Comments
Answers (0)
See Also
Categories
Find more on Clocks and Timers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!