Ken Kundert
|
I don't believe that making the modulus a function of the input is what you want to do. Remember that the output is a phase, which is a point on a circle. You already have the argument (inst_freq) being a function of the input, this controls the rate at which the point moves around the circle. Now if you also make the modulus of a function of the input, you are effectively varying the circumference of the circle as well. Meaning that the period of the sawtooth will be constant as a function of the input because, as the input increases the rate, it also increases by the circumference by an equal amount. So the period of the sawtooth is independent of the input, but its amplitude will increase with the input. This is problematic, because with low input levels, the output amplitude will not be large enough to trigger the cross statement.
There are two ways to generate a pulse with a controlled width. The easiest is to put in two thresholds, say at 0.25 and 0.75 (assuming modulus is 1), and have one set the output high and the other reset the output low. This will give you a controlled 50% duty cycle. The other thing to do is to use timer event to produce a fixed width pulse (in the body of the cross event you set the output and then save the time you would like to trigger the timer, and in the body of the timer you reset the output). In this case, you must assure that the pulse width is not longer than the minimum period.
-Ken
|