06-15-2007 11:57 AM
Goal #1 - I am trying to generate an analog frequency burst. It is to be 5Vpp and burst 7 sine waves at 5KHz, then wait until the next 50mS and generate again. The bursting frequency has been accomplished.
Goal #2 - The next problem is that I need to be able to change the 5KHz burst output with 1Hz accuracy to verify a bandpass filter. I am currently using a 6221 as a development card. It appears the 6221 will accept 1Hz input changes but the output does not match the input. (It seems to have 5Hz output resolution – I am running Continuous, 1 Cycle/Buffer, and 100 Samples/Buffer - gives good resolution to the signal.) Can 1Hz increment/decrement (in the 5 KHz range) be achieved with any of the AO lines on any PCA like the 6221, 6224, 6722, 16XE etc. I realize the Function Generator boards will accomplish my goal but I would need to purchase two PCAs since I need 6 AO lines and at that price I would prefer other optional test equipment.
Hello from New Hampshah 😉
Jeff
06-18-2007 12:24 PM
Hey Jeff,
The 6221 should be able to generate waveforms with 1Hz of frequency resolution - as long as you send it the correct waveform. It sounds like you are using on of the example programs, probably the "Cont Gen Voltage Wfm-Int Clk.vi". If you're looking for better frequency generation, I would try the Basic Function Generator.vi, specify a large sample rate, and calculate the number of samples required to generate the signal you want. You should be able to feed the results directly into the Timing and DAQmx Write vi's.
If you still don't see better results, how are you measuring the resulting frequency?
Thanks,
Andrew S
National Instruments
06-18-2007 02:31 PM
Andrew S.
I am glad to hear the 6221 should be able to meet my needs. I did base my devlopment on the "Cont Gen Voltage Wfm-Int Clk.vi". It is interesting to note that the "Basic Function Generator.vi" you recommend is actually in the "Cont Gen Voltage Wfm-Int Clk.vi" so I am not sure how to use it differently from the way it is used in the "Cont Gen Voltage Wfm-Int Clk.vi." I am using two counting sources; A universal counter and I am wiring the 6221 frequency output to a 6221 input after I condition it properly (digital). Both verify my concerns.
I have attached a screen shot of the fronts and blocks of the Vi's. Note that when I input a Desired Frequency of 5001Hz the timing property node (sampleclk.rate) divides it back to 5000Hz (Resulting Frequency) based on the Resulting Sample Clock Rate. This is the root of my problem since it is the Resulting Frequency that is input into the Basic Function Generator.Vi. I tried to bypass the timing node but the freuency output did not change. Any other thoughts and does anyone possibly know the dividing factor of the timing property node (sampleclk.rate)?
06-18-2007 02:58 PM - edited 06-18-2007 02:58 PM
Hi Jeff,
The Basic function generator is used in that vi, but the front end with your settings decreases the frequency resolution. I would take a little more of a low level approach. The current VI calculates the sample rate based on the inputs, finds the closest sample rate that is supported by the daq card (divided down from the 20MHz clock) and sets the generation frequency based off of that. If the calculated sample rate does not match up with what is supported by the card, then the frequency generated will not match up with what you want.
But if you specify the sample rate (for example 800k), the number of samples and the frequency you want generated, you will get the output you want. It sounds like you're looking for a finite generation, so you should not have to worry about phase continuity, but if you do I can post some code to maintain that. Take a look at the modified example I've attached and/or the pic:
Hope this helps, let me know if you have additional questions.
Andrew S
Message Edited by stilly32 on 06-18-2007 02:58 PM
Message Edited by stilly32 on 06-18-2007 03:04 PM
06-18-2007 04:01 PM - edited 06-18-2007 04:01 PM
Andrew S
Thanks so much for your quick response. I thought for sure you had it nailed. When I ran your edited application, even though the result frequency showed exactly what I wanted, when I observed the Universal counter and it showed me that only 4800hz was being output. Looking at a scope revealed that after a few sine waves, the signal was being refreshed in the middle of a sine wave (end of samples?) I tried recalculating the samples by dividing the clock rate/frequency desired. This seems to be the answer but 5003hz does not divide nicely into 800000 (a base clock value I presume). I even tried 833000 as a clock rate. Since the amount of samples has a decimal portion, the output fluctuates +/- a few hz. Can't get it to lock onto 5003hz even though the Resulting Frequency believes it is. Anything else? (It appears it may work for finite samples but not for continuous. I need both options.)
Message Edited by j.masse on 06-18-2007 01:03 PM
06-18-2007 04:30 PM
Hey Jeff,
If you are going to be running continuously, then you have a couple options.
You can run the Cont Gen Wfm Non Regeneration Example.vi - it automatically generates the waveform with phase continuity (no gaps/jumps). This will work out of the box but you may run into buffer underflows if your computer cannot keep up with your generation.
Or you could run the math and figure out how many samples you need to generate in order to ensure that the number of samples you generate at the specified sample rate corresponds to an integer number of periods or you signal. I've actually had to implement this before, so I've attached the code. It's not the prettiest and I'm sure there are other algorithms out there but from my testing it seems to work fine.
Note - LabVIEW has an LCM.vi but it only works for 32 bit integers. I found I needed 64 bits in most of my calculations so I just changed the type.
Also note that this card doesn't have an ultra stable clock (50ppm) but we should be able to get within a Hz. Let me know how this goes.
Andrew
06-18-2007 04:59 PM
06-19-2007 07:15 AM - edited 06-19-2007 07:15 AM
Message Edited by j.masse on 06-19-2007 04:16 AM