From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA (PXI-7852R) Phase Locked Square Wave DIO

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?

0 Kudos
Message 11 of 18
(748 Views)
Anyone know how to derive f/3 in a single cycle timed loop?
0 Kudos
Message 12 of 18
(729 Views)

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):

 

Every3rd.PNG

0 Kudos
Message 13 of 18
(713 Views)

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! 

 

 

0 Kudos
Message 14 of 18
(709 Views)

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?

0 Kudos
Message 15 of 18
(689 Views)

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.

 

Download All
0 Kudos
Message 16 of 18
(674 Views)

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.

0 Kudos
Message 17 of 18
(666 Views)

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

Bruce Ammons
Ammons Engineering
0 Kudos
Message 18 of 18
(645 Views)