06-17-2008 03:22 PM
06-18-2008 01:45 PM
Hello Lee,
As this error message indicates the analog output buffer is not being updated with new samples quickly enough to prevent regenerating samples. In general this means that you either need to run your loop faster or write more samples to the buffer at a time. In order to run your loop faster you would need to make your analysis more efficient or implement threading to make some of your code run in parallel (this may cause significant gains if you have a dual core computer). Inevitably you will reach a speed that is the maximum your computer can handle. On most non-real-time operating systems for basic PID control loops this rate is somewhere on the order of 1 kHz (this varies significantly based on your particular computer).
Are you looking to run your loop at a rate of 5-10 kHz meaning that you need to have a control loop response time at this speed or are you just wanting to update and read values at this rate? The point I'm trying to make is that you can make your code more efficient by reading/writing multiple points. If you read in 10 points at a time at a rate of 10,000 rather than 1 point at a time your loop will run 10 times slower and put much less strain on your CPU. The downside here is that your control loop time also slows down (by control loop time I mean the delay between reading in a value, performing calculations, and outputting values) since you update the output only once per loop iteration.
The bottom line is that you're computer may not be able to handle running the analysis you require at the rate you want. However, if you can still meet your needs by running the loop slower and dealing with larger data chunks then there is a good chance you can get this to work.
If your application requires that your output response time be 0.1-0.2 msec then you may need to consider moving to a real-time operating system. However, if a response on the order of 5 msec is acceptable then you can probably get this to work by making your code more efficient and reducing the loop rate by working with more data each loop iteration.
I hope this helps, and have a good night!
06-18-2008 02:46 PM
06-18-2008 02:52 PM
06-18-2008 10:35 PM
06-19-2008 04:54 PM
06-19-2008 11:04 PM
06-23-2008 10:51 AM
Hello Lee,
Here are a few things to try.
There are DAQmxBase examples that are installed to this directory by default: /usr/local/natinst/nidaqmx/examples
I would suggest looking at the analog output (ao) example folder and running the continuous generation example. This example will call the same DAQmxBaseWriteAnalogF64 function you're using so we can test to make sure your driver install is working correctly.
Secondly, it is possible that this error is being thrown because you aren't writing points to the analog output buffer before you start the task. If you start the task without putting samples in the buffer then I would expect an error to be thrown indicating that the task didn't have anything to write. To fix this you can call a DAQmxBaseWriteAnalogF64 function to put samples in the buffer before the task is started.
The last thing I would do in your program is to add in the DAQmxBaseCfgDigEdgeStartTrig function call to synchronize your two tasks like you've done in you DAQmx code.
Let me know what you find.
Cheers,