From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Daqmx Multichannel read issue, cannot use while loop

I am using my PCI-6251 to monitor an incoming voltage, when a voltage rise begins an output signal is triggered thru the use of a counter output. Also in this VI there is a structure for image acquisition. What I am trying to add is data logging for several analog inputs. I have a line for multiple channel read but it does not capturing any data. Could someone give me some direction where I may be making a mistake. I cannot use a while loop, it uses a lot of processing power and makes the triggering unstable.

0 Kudos
Message 1 of 7
(3,475 Views)

Probe the error wire in the AI loop and see if there's something wrong with the setup.

0 Kudos
Message 2 of 7
(3,469 Views)

Is there some error I should be looking for? There are no errors in the loop showing, and the vi runs without error.

0 Kudos
Message 3 of 7
(3,466 Views)

I have only looked at the picture of your code, but I would say that, if the code is, indeed, being run (set breakpoints to confirm), then you either have an error in/out of the DAQmx Read or you are passing in a bad number into the number of samples (or timeout, whichever you wired up to the DAQmx Read) which might make the timeout too small or the number of samples you desire too few. Try setting the timeout to -1 and set the number of samples to something like 1000 and then probe the array coming out of the Read. If you get samples there then you can assume the error is writing it to the file.

0 Kudos
Message 4 of 7
(3,457 Views)

I had set the timeout to -1 and the samples were set to 1000 per channel. I probed the array and found no data. There must be an error with the task being initiated but I cannot see how. Could the re-triggerable be causing an issue? Can a daqmx read block function outside a while loop?

 

Thanks

0 Kudos
Message 5 of 7
(3,412 Views)

Several things I notice about your VI:

 

1) You have two separate tasks referring to AI channels on Dev 1.   I suspect that the first task will error with a -50103 error.  Since this is the start trigger for your other tasks, I suspect that none of these tasks will run.  You should combine the two AI tasks into one.  If you only want to log channels 1-4, then do this by processing the data read.

 

2) I'm not sure that Start.Retriggerable is supported for AI tasks on M Series devices like the 6251.  This may result in an error.  In any case, since you've set the task up to be continuous, this property doesn't really make sense.

 

3) I'd run with highlight execution on... 'Number of buffers 2' exits the sequence structure then feeds your for loop... I'm not sure that this data will be available until the first frame of your sequence structure is done.  This may imply that your tasks will start long before you attempt to read data.  This can often lead to errors.

 

Can you provide a description of what does happen when you run this?  Which tasks run/return data?  Are you certain that none of these tasks return errors? If you had read in a while loop, and didn't stop on error I can see where this would use a lot of CPU, because essentially the loop would spin as fast as it could, while continually returning the same error.

 

Hope that helps,

Dan

0 Kudos
Message 6 of 7
(3,373 Views)

I removed the IMAQ stuff which I don't have installed, and cleaned up the DAQmx code to get it working with a simulated 6251.  Have a look and see if this works for you.  The things I did were the following:

 

1) Put all channels in same task.  I removed channel 0 because nothing was done with the data read.

2) Stopped loops on error (this is something you'll want to do if you're going to use while loops).

3) Don't use Start.Retriggerable for your AI task (not supported on M Series, and not valid for continuous tasks).

 

Hope that helps,

Dan

0 Kudos
Message 7 of 7
(3,366 Views)