04-08-2009 05:55 PM
Hi Stephanie-
The problem is not with the way that you generate your voltage array; it is actually an issue inherent to the way the example is layed out.
We define PointsPerBuffer at the top to be 2047. However, we use this constant throughout the code for the number of total samples to be generated between all channels. Since 2047 does not evenly divide two channels, one extra sample is generated on one of the AO channels. This throws the waveforms for both channels off once the output pointer wraps to the second run of the buffer.
As a quick fix for this, you can simply change PointsPerBuffer to an even number for two channel output.. say 2046. However, this will quickly break down if you change the number of channels in your generation to four or five.
A better approach would be to calculate numberOfSamples as numChans multiplied by numSamplesPerChan. This variable should be used in place of the PointsPerBuffer constant when determining how many times to call FIFOData.write(). PointsPerBuffer can be used in error checking to determine if the number of samples you're trying to generate across all samples is larger than the FIFO size of your device (2047 samples).
I hope this helps. By changing the number of samples you're writing to the FIFO to a number that evenly divides the number of channels, you should see these problems go away.
Thanks-
Ed
04-09-2009 01:59 AM
Thanks you very much Ed !
I have a other question. Can I write some channel with waveform for example on channel 0, 1,5,8 and write other channel directly with board->DirectData_xx.write(value); ?
Best Regards,
Stephanie
04-09-2009 09:48 AM
Hi Stephanie-
That is actually not possible with these devices. You can switch between waveform mode and immediate mode through the update mode field of the AO_Misc register. This is not set on a per channel basis - the setting holds true for all channels on the device. The analog outputs are multiplexed and so they must all be receiving their data from a common place - either directly or through the FIFO.
Thanks-
Ed
06-12-2009 09:39 AM