‎09-04-2007 04:51 AM
‎09-05-2007 10:56 PM
Hey Peder,
This is a great post - the pictures are a huge help. I've worked with encoding
schemes like this before (AM modulation for IRIG-B, simulating RFID) and for me
the easiest has always been to just use software to generate your waveforms and
then just output it. I usually end up writing a VI/function that generates the
analog waveform based on whatever bit pattern I need and writing that with the
DAQmxWrite. You pretty much already have the foundation for that with your
building block.
That being said, you could generate it by manipulating the clock, though I
think it will be more haste and tie up more resources. Let me address a couple
of you comments:
" I don't think the NI USB-6251 has a pause
trigger?" - The 6251 (USB and PCI are essentially the same) does support a
pause trigger. You could use it to gate your AO sample clock - if you can
generate the digital signal required. This digital signal would essentially be
the bit pattern in your post.
To implement the pause trigger, you'd want to start with
the "ContGen-IntClk.prj" example and set the properties needed to
implement a pause trigger:
...
DAQmxErrChk
(DAQmxCfgSampClkTiming(gTaskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
// configure pause
trigger
DAQmxErrChk
(DAQmxSetTrigAttribute (gTaskHandle, DAQmx_PauseTrig_Type, DAQmx_Val_DigLvl));
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,
DAQmx_DigLvl_PauseTrig_Src, "PFI0"));
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,
DAQmx_DigLvl_PauseTrig_When, DAQmx_Val_High));
DAQmxErrChk
(DAQmxRegisterDoneEvent(gTaskHandle,0,DoneCallback,NULL));
...
"I think the idea was to set up the counter as clock
for the sin wave and write the bit pattern to the counters gate." You
could do this with a counter, our you could just pause trigger the AO sample
clock (which is essentially a counter reserved for AO).
The question becomes, where does the bit pattern come from?
If you already have it externally, then you're pretty much set and it would be
a clean solution. If not, the only HW timed way to do it onboard would be
to use the clocked DIO on the 6251. This would require one of the onboard
counters for the clock, and physically connecting the digital output signal to
a PFI pin. You would need to ensure that the AO generation is synched with the
bit pattern too, but you should be able to do that with a start trigger. You
would also have to construct the digital pattern in SW, which for me if you
going to go that far you might as well go the extra step and turn that into an
analog signal. Let me know if you think you want to pursue that route and need
some tips - it would require 3 tasks.
Hope this helps, feel free to post your code when you get
it up and running.
Andrew S
National Instruments
‎09-05-2007 10:57 PM
Hey Peder,
This is a great post - the pictures are a huge help. I've worked with encoding
schemes like this before (AM modulation for IRIG-B, simulating RFID) and for me
the easiest has always been to just use software to generate your waveforms and
then just output it. I usually end up writing a VI/function that generates the
analog waveform based on whatever bit pattern I need and writing that with the
DAQmxWrite. You pretty much already have the foundation for that with your
building block.
That being said, you could generate it by manipulating the clock, though I
think it will be more haste and tie up more resources. Let me address a couple
of you comments:
" I don't think the NI USB-6251 has a pause
trigger?" - The 6251 (USB and PCI are essentially the same) does support a
pause trigger. You could use it to gate your AO sample clock - if you can
generate the digital signal required. This digital signal would essentially be
the bit pattern in your post.
To implement the pause trigger, you'd want to start with
the "ContGen-IntClk.prj" example and set the properties needed to
implement a pause trigger:
...
DAQmxErrChk
(DAQmxCfgSampClkTiming(gTaskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
// configure pause
trigger
DAQmxErrChk
(DAQmxSetTrigAttribute (gTaskHandle, DAQmx_PauseTrig_Type, DAQmx_Val_DigLvl));
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,
DAQmx_DigLvl_PauseTrig_Src, "PFI0"));
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,
DAQmx_DigLvl_PauseTrig_When, DAQmx_Val_High));
DAQmxErrChk
(DAQmxRegisterDoneEvent(gTaskHandle,0,DoneCallback,NULL));
...
"I think the idea was to set up the counter as clock
for the sin wave and write the bit pattern to the counters gate." You
could do this with a counter, our you could just pause trigger the AO sample
clock (which is essentially a counter reserved for AO).
The question becomes, where does the bit pattern come from?
If you already have it externally, then you're pretty much set and it would be
a clean solution. If not, the only HW timed way to do it onboard would be
to use the clocked DIO on the 6251. This would require one of the onboard
counters for the clock, and physically connecting the digital output signal to
a PFI pin. You would need to ensure that the AO generation is synched with the
bit pattern too, but you should be able to do that with a start trigger. You
would also have to construct the digital pattern in SW, which for me if you
going to go that far you might as well go the extra step and turn that into an
analog signal. Let me know if you think you want to pursue that route and need
some tips - it would require 3 tasks.
Hope this helps, feel free to post your code when you get
it up and running.
Andrew S
National Instruments
‎09-06-2007 08:00 AM
‎09-06-2007 10:05 AM
Hey Peder,
The real limit on your resolution is going to be the max sample rate of the analog output- which is ~2.8MS/s. That warning (200040) is referring to the Settling time spec in the specs. For a full scale step (going from -10 to 10) it would take 2us to fully settle. If I recall right, DAQmx won't throw a warning at 500k because error caused by the settling time doesn't factor in much when compared to the AO accuracy untill >1MS/s (don't quote me on that
). This is for a full scale swing - for a continuous sine wave you can pretty much ignore that error.
The theoretical max resolution that you'll be able to generate a 125k sine wave would be 2.8M/125k = 22.4 - so 22 samples per cycle at 2.75M. The issue you'll run into there is that the AO sample clock is a divide down of the 20MHz sample clock - and 2.75M is an not an integer divide down. You can work with this though. If you want a closer frequency, you can use a counter (which divides from the 80Mhz clock) as the clock for your AO - that will give you a 4 times the clock resolution and a clock rate closer to 2.75M. There's more you can do, such as finding the attainable samples rates and working backword from there, but you should be able to get close enough just using the AO sample clock or a counter.
Hope this helps,
Andrew S