06-15-2007 12:42 PM - edited 06-15-2007 12:42 PM
myTask.Stream.WriteRegenerationMode =
WriteRegenerationMode.DoNotAllowRegenerationI'm using a background thread to keep the buffer filled... this thread writes about 1/4 seconds worth of samples, then sleeps for about 1/4 second.
The problem is that this results in a good waveform, but 100% CPU usage. I've attached a very stripped down version of this program. Please just look at the code, specifically the button1_Click method, and everything will be clear. The code does not appear to be doing very much, so I don't see why this should hose the CPU.
Waveforms with WriteRegenerationMode.AllowRegeneration don't use any CPU.
Thanks for your help!
~Suneet Upadhyay
UCB Physics 111 Advanced Electrical Laboratory
thrawn at berkeley .edu
Message Edited by SuneetU on 06-15-2007 12:46 PM
Message Edited by SuneetU on 06-15-2007 12:54 PM
06-15-2007 01:20 PM
writer.BeginWriteMultiSample(
false, data, null, null);}
Application.DoEvents();System.Threading.
Thread.Sleep(200);}
}
06-23-2007 05:10 AM
06-23-2007 05:25 AM
Hi Sun
I have read your code, I do not think it is a good way you put a very long process in button1_Click event, if a process is up to 20 ms, you are supposed to put it into a threading,
03-10-2011 03:12 PM
When I use the original program in the ZIP file, I do not get a continuous signal (~50ms sines, ~200ms 0V). I guess this is not intended???
When I comment out the line
System.Threading.Thread.Sleep(250);
then I get a continuous signal (CPU usage about 17%).
When I try to use your modification, I get the following error:
You cannot get the specified property, because the task is not a buffered output task.
Property: NationalInstruments.DAQmx.DaqStream.OutputBufferSpaceAvailable
Task Name: _unnamedTask<0>
This site is the only site in the whole internet where I can find anything about "OutputBufferSpaceAvailable".
How do I use this correctly?
03-12-2011 11:06 PM
Hi Camell,
You may want to post as a new topic for this specific question, since this particular forum is rather old.
You're right--it doesn't appear this property is widely used. I understand this property represents the amount of space that is remaining in the PC buffer for AO samples written out. You can find the .NET or C reference help for various functions in:
Start>>All Programs>>National Instruments>>NI-DAQ>>Text-based Code Support
In other words, if you wished to programmatically determine what to do based on how much data you still have to be written out to your AO channel, I believe this is the property you would use. Unfortunately, like you, I wasn't able to immediately find any examples. You could probably try including this property in one of the pre-existing examples (in the directory I mentioned above) and place an indicator on your front panel to watch how it varies.
To learn more on the topic of buffer allocation, you might see this KB about How Buffer Size is Allocated for Acquisitions. The specific NI-DAQmx Help topic: How is Buffer Size Determined? mentions the principles used to guide AO buffer allocation. Like AI, there is a property for manually allocating buffer size for AO called DaqBuffer.OutputBufferSize.
DAQmx Timing and Sample Rates - Good general resource
Hope this helps,
Andrew