LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when AI channel scan at two places in one VI

Hi, everyone:
My program  mainly reads Analog data from NI-DAQ board, it reads from 4 analog inputs. I use one loop for queue input, and the other loop for execution.  For data reading, I use "AI configure", "AI scan", "AI clear" in a stacked sequence structure. The program works fine at this point, I can do basic "start, stop, clear, save" functions.
Now I need to add one more function: Scan a control variable at certain data range, and check the data from 2 of the 4 AI inputs. This two AI inputs data will be used as  inputs to a subvi to return a final value of the control variable.
I put this function into the queque, but have problems when executing it:
1. If I use the AI configure structure in the execution loop, the 2 AI inputs data would not change when the subvi was called. (These two data are supposed to change with the control variable, so that I can  get the final value of the control variable)
2. If I use a standalone subvi with high level AI read(AI sample channel.vi), I can get the right control variable value (the two AI input data change with the control variable), but after the subvi finishes, the AI scan give me ridiculous data (I started collecting data first before I hit the button to perform this new function). I have to stop the program, and rerun it to make the data reading correct.
Any advice is appreciated.
 
bj
0 Kudos
Message 1 of 3
(2,284 Views)

Hi BJ,

I noticed that you are using Traditional NI-DAQ (Legacy) for your application. I stronly recommend that you upgrade to DAQmx. It is a free download from the National Instruments website from the following link: NI-DAQmx 8.0.  Also, programming and troubleshooting are much simpler with DAQmx and I am posting some links with more information about this driver.

In the meantime, are you able to successfully run analog input examples? I recommend using an example and then modifying it to fit your specific needs. At this point, it's difficult to say what could be causing the problem with the subVI and the control variable. Are you receiving any errors when you run the code? Also, it sounds like you may be changing settings in your analog input while the task is running: is this correct? Please keep me posted with your progress on this issue.

 

Advantages of NI-DAQmx

Transition from Traditional NI-DAQ to NI-DAQmx

Learn 10 Functions in NI-DAQmx and Solve 80% of Data Acquisition Applications

Regads,

Hal L.




0 Kudos
Message 2 of 3
(2,270 Views)

Hal:

Thanks for you help. I solved the problem.  I made a basic mistake when calling subvi to scan the control variable. I was supposed to put AI scan in the loop so that I can have updated data when my control variable changes. But I somehow put it outside the loop. That's why my AI scan number never changed. haha

bj

0 Kudos
Message 3 of 3
(2,260 Views)