05-29-2014 04:57 PM
You made my day Bruce!
I can now create phase steady pulses at even integer multiples of my trigger square wave. But how do I get 1/3 my trigger frequency?
06-16-2014 06:31 PM
06-17-2014 10:49 AM
I think Bruce's suggestion was to down count for the lower frequencies, but you just want to do something in the same loop at 1/3 the rate of the other code, right? The most straightforward way I can think, would be to put the f/3 code in a case structure, and enable it only when the iteration terminal is a multiple of 3 (here's a quick piece of code that should do just that):
06-17-2014 11:08 AM
Matt,
Thanks for your response. With Bruce's code I was able to derive f/n (where n is an even integer) from the output of the "squarewaveDDS.vi" at frequency f (f=25 kHz). I need to derive f/m where m is an odd integer (for instance f/3=8.333 kHz). The SCTL rate is 80 MHz (I set it hight to remove jitter from the square pulses). *Note: I do not need f/m to have the same duty cycle as f.
Because the loop rate does not match f it is unclear how to apply your code to yeild f/m. Can you shed more light on this?
In order to get f/m I think in need to count the rising edges as well as the falling...but I am not sure
Thanks!
06-18-2014 10:53 AM
So I looked at Bruce's code again and I see you're just trying to divide down to create the digital waveform, rather than just execute part of the code at f/3.
I think his code should work for both even and odd integer multiples. You should only need to count one edge, since you're basically counting full periods of the original pulse rate (f). If you set the downcount to 3, the pulse output will transition every 3 periods of the original signal, which should give you f/3 (I drew it out and did some math to convince myself this is the case). If you use an odd downcount, do you not see an odd integer multiple of the original frequency?
06-19-2014 12:24 PM
Matt,
for down count equal to 3 I see f/4. Attached is a drawing I used to convince myself that I need to count the falling edges as well as the rising. attached is another png that helped me.
06-20-2014 11:17 AM
That does make more sense the way you've drawn it, I must have miscounted somewhere.
Have you implemented counting both rising & falling edges? I think all that should be necessary is replacing the compare after the Feedback Node with an XOR function. Then set Downcount to 3 and you should see f/3 as you've drawn.
10-10-2014 09:50 AM
Sorry, I didn't get notified about the new messages for some reason. I suspect you already figured everything out, but here is what I would have said:
Matt is right, you need to count both edges to do an odd downcount. The simplest solution is to change the > comparison to a not equal comparison, which will count both edges instead of just the rising edge. You will have to double your downcount value to get the same results as before.
Bruce