Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

square wave in FPGA Module

I am having real problems generating square wave(s) in LabVIEW FPGA Module. FPGA vi's are set to compile for the 40MHz onboard clock. Now if I place a "square wave generator" inside a while loop in an fpga vi for 10MHz or above, the actual output, as measured on an oscilloscope does not correspond to that set in the vi (10MHz will result in a 2MHz wave). If sq. wave generator is set to 1 MHz, that works fine and frequencies of 200 and 100 kHz also work fine. However, if I place a second square wave generator inside the same while loop, problems arise. Two traces will be observed on the oscilloscope, but both will be at the same frequency, which is the lower of the two square wave frequencies. This is consistent even when the generator's frequencies are 'swapped'.
 
Any help or pointers would be most appreciated!
 
Many thanks,
Craig.
0 Kudos
Message 1 of 7
(4,495 Views)
Hi Craig,
 
Could you post your FPGA code and some screenshots of what your seeing please?
And I will look into this further for you.
 
All the best,
Applications Engineer
0 Kudos
Message 2 of 7
(4,478 Views)
 
Sorry about the size of the picture...In terms of screenshots of what I actually see, I cannot currently take them from the oscilloscope, but it's simply two identical square waves at the lower (of the two sq. wave generators) frequency, and then only if the set frequency os equal or less than 1MHz. Thanks, Craig.
0 Kudos
Message 3 of 7
(4,475 Views)
Hey Craig,
 
I'm afraid I can't see the picture, could you upload it along with your code in a zip file please? I will open it locally here on the PC and look into it for you.
 
Thanks in advance,
Applications Engineer
0 Kudos
Message 4 of 7
(4,469 Views)
Please find attached,
 
Thanks for your time,
Craig.
Download All
0 Kudos
Message 5 of 7
(4,464 Views)

Hi Craig,

Sorry for the late reply, the office has been on easter holidays - have you tried using the example VI for this at all? Under LabVIEW > Help > Find Examples you can search for "square" and you should be able to see a project called "Square Wave Generator cRIO". If you could run this to see if you see the same behaviour I'd be appreciative.

Let me know how it goes,

All the best,

Applications Engineer
0 Kudos
Message 6 of 7
(4,419 Views)

Hi Rob,

Thanks a lot for the reply. I found the example VI "square wave..." you referred to. Although the VI did not work (error code-63040 "a connection could not be established to the specified remote device..."), the notes on the block diagram did reveal the problem. You cannot have two square wave generators inside a single while loop. I have since put the generators in their own loops and this seems to work in as much as separate frequencies being generated simultaneously. However, I still have problems in getting high frequencies. Up to 2 MHz is ok, but 10 MHz and 15 MHz settings give rise to 333.33kHz and 2.857MHz respectively on the oscilloscope.

Also, is there a way of getting two separate while loops (containing sq. wave gens) to start when the user presses a control on the front panel? I have wired a boolean control (outside the loops) to 2 such while loops and nothing happens when it is run.

Thanks,

Craig.

0 Kudos
Message 7 of 7
(4,391 Views)