‎08-18-2010 10:41 AM
Hi,
I am new to using NI and its interfaces. I am using the USB-6221, with its C API.
I need to create several Continuous Digital Output channels with frequency and duty cycle.
I first used DAQmxCreateCOPulseChanFreq for crt0 and crt1 channels and it works fine, but I need a few more DO lines.
Can I use the PFI channels (PFI0-4 for example) for this purpose?
Using the DAQmxCreateDOChan I can define the desired PFI channels as DO, but how can I create the desired signal on these channels?
Best Regards,
Danny.
Solved! Go to Solution.
‎08-19-2010 05:49 PM
Howdy Danny!
If you are trying to generate a digital pulse train with a specified frequency and duty cycle then using the USB-6221's onboard counters is definitely the way to go. Unfortunately, as you have discovered there are only two hardware counters available on the USB-6221 (Ctr0 and Ctr1).
Fortunately, you can also use the digital output lines to effectively create a pulse train with a specified frequency and duty cycle. You will need to create an array of samples that, when output at the specified sampling rate, will resemble a period of your waveform. For example, if my sampling rate is 1MHz and I want to create a 100KHz square wave with a duty cycle of 20% high/80% low I would generate the following samples:
{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Please let me know if this description is clear or if there is anything I need to explain in more detail.
Regards,
‎08-20-2010 08:47 AM
Hi Barron,
Thank you very much for your help.
I will be able to check it in 2 days only, but meanwhile, let's see if I got it right:
To continue tour example, I assume I need to create a clock of 1 MHz first. To do so I need to create a seperate task, than use DAQmxCreateAIVoltageChan and DAQmxCfgSampClkTiming with a rate set to 1000000 and NULL as the source channel.
Now I create a second task for the 4 DO channels I need, and again use the DAQmxCfgSampClkTiming command, this time with the DO channels task, same rate (1MHz) and source field set to "ai/SampleClock".
Now I create the
A few questions:
Best Regards,
Danny.
‎08-20-2010 10:38 AM
OOppssss,
Ignore question number 4 ...
‎08-22-2010 11:58 AM
Thanks. The output channels work perfectly.
‎08-22-2010 02:11 PM
You should mark Red Barron's answer as the solution - not your thank you. You can click on 'Options' to change the marked solution.
‎08-22-2010 02:57 PM
OK. I have corrected my mistake. Thanks.