Hi, is it possible to stream AIN data while changing DAC or FIO outputs? I tried an experiment (see attachment for code) but it looks like the threads don't run simultaneously. I believe that's a Python limitation. I understand two processes cannot access the same device, ruling that option out as well.
My goal is to monitor device waveforms while stimulating it with DAC's and FIO's. I need to start waveform capture before stimulating it, and stop capture some time after.
Thanks,
Dan
Yes, you can set the DACs and FIO lines while streaming.
In your case, the issue is that the DACs are getting set after you stop streaming. If connecting DAC0 to AIN0, you'll see the DAC changes if you increase MAX_REQUESTS.
I ran your code, and noticed the writeRegister calls in your other thread were getting delayed up to one second while the stream thread was running. This occurs since you have a slower scan rate, and by default for 100 Hz each streamData call will read and wait for 4 packets containing 100 samples total. So basically each streamData call can take up to 1 second since it is waiting for 100 samples, and your other threads calls wait until the stream read finishes (and vice versa). USB calls on the U6 cannot happen simultaneously.
Bump MAX_REQUESTS up to 100, and set the streamConfig's SamplesPerPacket parameter to 1 and you should see the DAC changes with less writeRegister delay. When SamplesPerPacket is less than 25, streamData will only try to read one packet of SamplesPerPacket amount of samples. So if this is set to 1, streamData will delay only up to 10 ms (#Samples*1/samplesRate) for the one sample.
Keep in mind that you should only need set SamplesPerPacket less than 25 at slower scan rates. At faster scan rates there are less streamData call delays, and reading more than one packet at a time from the U6 is better for throughput and prevents U6 stream buffer overflows.