08-07-2023 06:23 AM
During continuous sampling, if there is no delay in the loop and the read number is set to -1, no data will be collected.
Is there no data in the buffer (according to the documentation, all data in the buffer will be returned when the read number is set to -1)???
08-07-2023 06:48 AM - edited 08-07-2023 06:56 AM
nzywlll80@gmail.com wrote:
During continuous sampling, if there is no delay in the loop and the read number is set to -1, no data will be collected.
Is there no data in the buffer (according to the documentation, all data in the buffer will be returned when the read number is set to -1)???
That is expected. Since there is no delay there is no time to collect any samples and place them in the buffer and you return no samples. A totally useless loop unless you simply want to use a CPU core to generate heat.
I can't read the enum and poly selector texts. How is the Task timing set up?
08-07-2023 07:18 AM
number of samples per channel specifies the number of samples to read. If you leave this input unwired or set it to -1, NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples. If the task acquires samples continuously and you set this input to -1, this VI reads all the samples currently available in the buffer. If the task acquires a finite number of samples and you set this input to -1, the VI waits for the task to acquire all requested samples, then reads those samples. If you set the Read All Available Samples property to TRUE, the VI reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples. |
Upon is the original text from the LabVIEW Help file, try to wait 1 second after starting sampling, but before getting into the loop. set a wait funtion in the loop, the wait time should longer than your sampling time.
AnalogInput ----sampling----> Buffer --------DAQmxRead-------> Your Indicator
08-07-2023 09:11 AM
As was stated previously, when in Continuous Acquisition mode reading -1 samples will just immediately return all samples currently in the buffer. So occasionally, you will get a single sample returned.
The proper solution is to set the number of samples to read at the DAQmx Read. Or, if your sample rate is really slow (I see your sample rate is 10S/s = 100ms/sample), use the Single Channel->Single Sample mode of the DAQmx Read and it will then return a value when a sample comes in.