Multiple inputs and outputs using DAQmx VIs

Hello,
I am fairly new with the LabView programming language.  I have a few training books that I have been reading, and I have been following online tutorials and reading the forums.  However, I have come to a problem where I don’t see a clear solution.  I am using LabView 2009 (9.0f3) and DAQmx VIs.
I am using a NI 9172 chassis PLC, with two 9201 AI cards, 9217 AI RTD card, 9472 DO card, 9263 AO card, and two 9237 AI Bridge cards.
I am reading eight analog inputs with the 9201 cards, two analog RTD inputs with the 9217 card, three digital outputs with the 9472 card, three analog outputs with the 9263, and eight analog inputs with the 9237 cards.
I wrote a simple program to test one digital output task, two of the analog output tasks, and a single analog input task.  I put all of them in the same while loop, and it worked perfectly.  However, when I add analog input tasks to the same loop, I get an error 200022.    So I tested each sensor individually by changing the channel before each run.  I searched error 200022 and found that this is because I cannot start another analog input task until the previous one ends.  With this said, I don’t know how to acquire an analog voltage in the same task as an analog RTD voltage.  Both inputs take different constants in the start task DAQmx icon.
Attached is my test program.  It is titled “Test All”. This is the program I used to test the various sensors.  I tested the input sensors one at a time, and it worked fine.  A few tasks are written just to test functionality, and will be added to later.  The data is only displayed on the screen.  I will add triggers and data write to disk functions later.  This program works now, but if I add more analog inputs, it will generate the 200022 error.
Can someone show me how to correctly write the code for multiple inputs and outputs using DAQmx?  All training materials and tutorials I can find all show a single input or single output, not multiples of each.  Thanks for looking.
-Randy
Attachments:
TestAll-NI.vi ‏32 KB

Hi RandyC,
The Knowledge Base article Using Different Types of DAQmx Global Channels in the Same Task goes into a little more depth of what Bryan is talking about, and it also includes some example code to help show what to do.
Hope that helps,

Similar Messages

  • How do I create an xControl with multiple inputs and outputs?

    Hello,
    i am trying to write a new Xcontrol Element. In the data model I can create data types using the cluster to create compound types, eg an int and an int array. But how do I create an xcontrol which has multiple data inputs and outputs?
    Kind Regards

    Limping_Twerp wrote:
    Alright: I see: An xcontrol is either an input OR an output. How do I achieve an output? Secondly: So you are saying the only Elements that can have multiple inputs and outputs are VIs?
    Can you take a few steps back and explain what you are actually trying to do. SubVIs and Xcontrols have nothing in common and it is not clear why you even try to compare them side by side (e.g. in terms of the number of connectors).
    Your questions about input or output tell us that you seems to have some misconceptions about xcontrols. Xcontrols are like regular controls, except they have some built-in intelligence that you can program. Most front panel object can be either controls or indicators and the same is true for Xcontrol. You create an Xcontrol, and after placing it on the front panel you can decide if it should be a control (where the code reads the value) or an indicator (were the code writes values to it). When you define the xcontrol facade, you also need to program how the visuals change if it is changed from control to indicator or vice versa.
    As a first step, you should opend the example finder and look at some xcontrol examples.
    Again, what are you actually trying to do? 
    LabVIEW Champion . Do more with less code and in less time .

  • Can you perform simultaneous timed digital input and output using a PCI-6120?

    Is it possible to do simultaneous timed digital input and output using a PCI-6120? It seems that timed digital operations require using the group read/write commands, which utilize an entire port. Since the PCI-6120 has only 1 digital I/O port, I would like to be able to use 2 lines as outputs and 1 line as input, and do both in a deterministic fashion. i.e. create a digital signal with known pulse widths and read an input line at a known time after the outputs were set. Is this possible to do with only one digital I/O port?

    Hello,
    This can be done in LabVIEW. There is actually an example that installs with NI-DAQ.
    Below is a link to a Knowledge Base that explains how to find the correlated digital I/O examples.
    http://digital.ni.com/public.nsf/websearch/B849664604EB34B886256D12005B5520?OpenDocument
    Just take a look at the example titled �Continuous CDIO with external clock (E).vi�
    Best regards,
    Justin Tipton
    National Instruments

  • Synchronisation of input and output using myDAQ

    Hello!
    I am currently using the NI myDAQ and use both analoge output. and both analoge inputs. The sampling rate needs to be as high as 200k Hz. (Also within the while loop I do quite a lot of data manipulation and saving into text files.)  My vi works generally fine, but I still have to problems:
    1. How can I ensure that the read and write tasks are synchronised? I found out that it is not possible to use other trigger than the sample clock for write and read tasks using the myDAQ. (Is this right?) So as a workaround for me it is not important that the tasks start at the same time, but I want to ensure that the delay between "Start Write Task" and "Start Read Task" always is the same.  Is this possible? And how can I realise it?
    2. If I want to generate a non periodical signal that is not constant, how do I best generate this? At the moment I use a Sine Waveform.vi with a frequency of 0 and I change the offset input with every loop. I also tried to use the FormulaWaveform.vi but with this my produced waveform seemed to stop after completing the "number of samples in the waveform". But the sampling info must be the same for both AO channels I use, so I cannot simply increase this number.
    Thanks a lot for any help! Jules
    Attachments:
    MyDAQReadWrite.vi ‏72 KB

    hi Jules,
    If you only want to ensure that the delay between "Start Write Task" and "Start Read Task" always is the same, you can realize it with a simple while loop (with Wait Until Next ms Multiple).
    But if you want to synchronize for example both analog input, you can see how it works in different examples. Following Path is shows you how to find these examples:
         In LabVIEW -> Help -> Find Examples... Brows(Brows according to Task): Hardware Input and Output -> DAQmx -> Synchronization -> "Analog Input Synchronizantion.vi"
    To generate a non periodical signal that is not constant, you can change the offset input every loop. If you want to manipulate the offset while running you can also use local variables in the loop.
    In this case you could manipulate for example with a slide control.
    Regards,
    grroesis

  • How to get input and output using math interface toolkit

    Hi,
    I am fairly new to labview and i am trying to convert my labview code
    into matlab mex files using math interface toolkit. I cant see any
    input or output terminals when i try to convert the code to mex files
    even though my vi has plenty of inputs and outputs that should be
    available during conversion.
    just to cross  check i made another vi in which i inputted an
    array of data to an fft and outputted it to an array again. i tried to
    convert this code to mex files but was still not able to see any input
    or output terminals, which makes me believe that i must be doing
    something wrong at the very basic level and inspite of trying really
    hard for some days now i have not been able to figure out that might be.
    So please help.
    I am attaching the basic vi that i created along with the link that i followed for converting labview code to mex files.
    http://zone.ni.com/devzone/conceptd.nsf/webmain/EEFA8F98491D04C586256E490002F100
    I am using labview 7.1
    Thanks
    Attachments:
    test.vi ‏17 KB

    Yes, you've made a very basic mistake. You have front panel controls and indicators but none of them are connected to the VI's connector pane. right click on the VI's icon and select "Show Connector". You use the wiring tool to select a connection there and then select a control or indicator. Use the on-line help and look up the topic "connector panes". There are some sub-topics on how to assign, confirm, delete, etc.

  • Multiple Input and Output from a 6534

    Hello
    I am after some advice regarding my PCI 6543 digital I/O card and the best way to achieve my desired results. I am programming in Visual C++ with Ni-DAQ 7.
    I want to generate a pattern output from one of the ports, Port A, following a software command. This pattern consists of a 10uS pulse on DIOA0, that repeats 200 times with a period of 100uS. I want this DIOA0 output line to initiate an input on ports C and D, possibly through the REQ pin. Consequently the input should acquire 200 times for each call to the pattern output.
    I want this to repeat, so the pattern output goes again (as in a FOR loop), and the input occurs again for an as yet undetermined number of times.
    I have managed to get something worki
    ng for 1 iteration, and I can generate multiple pattern outputs, but the inputs only seem to acquire for the 1st iteration. However, if I step through the code in debug mode I can get the input to work correctly.
    Any ideas would be gratefully appreciated.
    I am still trying to get some earlier problems with this application solved.
    Kind Regards
    Jamie

    Hi Jamie,
    There are a couple different ways you can loop from a buffer. You can either use the onboard memory of the 6534 and loop from there or you can specify as a software configuration that the board loop through the PC memory buffer.
    For the onboard looping you need to specify the following:
    iStatus = Set_DAQ_Device_Info (1, ND_PATTERN_GENERATION_LOOP_ENABLE, ND_ON);
    For software, PC memory looping, the following function specifies this:
    iStatus = DIG_DB_Config (iDevice, iGroup, 1, 0, 1);
    I attached a couple programs that might be of use. Check this post:
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000008BA10000&USEARCHCONTEXT_CATEGORY_0=_31_%24_12_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_31_%24_1
    2_&UCATEGORY_S=0
    Hope that helps. Have a good day.
    Ron

  • CFP-DIO-550 open multiple input and output at the same time

    I am trying to read and write at different times with the cFP-DIO-550.  I cant figure out how to read all the inputs at the same time.
    In the Create Tag.vi, I cant figure what to wire to the Item Name input.  I have tried Input 0, and that works, but it is only one input, I need to read all 8.  I have also tried Input All, All, Input 0:8. input 0-8, input 0: Input 8, Input 0 - Input 8, and I always get an error.
    I cant find anything on it in the manual.
    Thanks,
    Kenny

    Normally I would select 'All' using a FP IO point function instead of create tag ( LV 7.0 and up ).   I have noticed that the 'All' is only available if the module is all inputs or all outputs.  It may be that since your module is an IO, 'All' is not available by default. 
    I think you need to create an item in MAX in the Data Neighborhood under the DIO-550 Module and configure it to use all the IO on the module.

  • Planning Folders with multiple input and output layouts

    Hi,
    I have a planning folder with one input layout and 4 output layouts. The input layout has a GPS assigned to it which will be executed before layout change. Will this function get executed when I open any of the output layouts(out of 4) not necessarily the immediate output layout (next to the input layout) and will the calculated data be displayed accordingly. Can some one please confirm me on how that works.
    Scenario2: I have one input layout and 2 output layouts. The input layout has a GPS assigned which will be executed before layout change and the first output layout has another GPS assigned which is basically a push button. Then how does this work.
    Points will be assigned . Help is greatly appreciated.
    Thanks,
    Vamsi

    GPS will not be executed when you open any of the output layouts but will be executed only when you open the input layout. Yes, the calculated data gets stored in planning buffer so it will the displayed in input/output layouts accordingly.
    Scenario2: The GPS assigned to input layout will be executed when you open the input layout. GPS which is assigned to output layout in the form of a button will be only executed when user will click on that button. Calculated results will be available in all the layouts as the result remains in planning buffer until user explicitly click the 'SAVE' icon in applpication toolbar.

  • Data types used in a sub VI - selecting the correct input and output types?

    data types used in a sub VI - selecting the correct input and output types?
    I can never work out how to choose an input or output format for Subvi's.
    I want to create a SubVI for the code in red. I needs an VI Server Reference compatible input and an output that goes to  a waveform.
    Thanks in advance.
    Attachments:
    data types.PNG ‏11 KB

    GerdW,
    I realise now I have taken us in the wrong direction. apologies for that.
    History, this is not my code and I do not own the process and NOT my preferred method of using it. I was looking for a simple way to make subtle changes.
    What we do - We use these programs to collect data from typically 6 pressures and 6 temperature probes and capture RS232 / USB VISA strings from sensors.
    So every few weeks / months or up to a year we rearrange each sensor location to suit the new process. I did not write the code. I cannot change the procedure too much without resistance.
    So headers in the CSV file have the DaqMX string passed through the code. Great.
    Other data to the CSV file comes from calculations or extracted from the VISA string. Hence why we have headers with "Untitled 1 ()". These values also go to a History Chart.
    So I was looking for a simple way to read the the local variable label as it is always linked to the front page indicator. People can cope with editing the indicator label, save the VI and hit run.
    TL;DR - GerdW is now a psychologist.
    Attachments:
    data to csv and history chart.png ‏1043 KB

  • SSIS: How to use one Variable as Input and Output Parameter in an Execute SQL Task

    Hello,
    i need your help,I'm working on this issue since yesterday and have no idea how to deal with it.
    As I already said in the tilte i want to start a stored procedure via a Execute SQL Task which has around 15 prameters. 10 of these should be used as input AND output value.
    As an example:
    i have three  Variable:
    var1    int        2
    var2    int     100
    var3    int     200
    the stroed procedure:
       sp_test
          @var1 int
          @var2 int output
          @var3 int output
       AS
       BEGIN
            SET @var2 = @var2 * @var1
            SET @var3 = @var3 + @var1
       END
    So in the Execute SQL Task i call the Stored Procedure as follwos:
        Exec sp_test  @var1 = ?, @var2 = ? output, @var3 = ? output
    (I use an OLE DB Connection)
    The parameter mapping is as follows:
    User::Var1        input                   numeric              0                 -1
    User::Var2        input/output         numeric              1                 -1
    User::Var3        input/output         numeric              2                 -1
    Now my problem. If i set  Var2 and Var3 as Input parameter the values are still the same after running the package. If i set them to a output value the are both Null because the procedure doesnt get any values.
    I already tried to list them a second time - like
        User::Var2        input                  numeric              1                 -1
        User::Var2        output                 numeric              1                 -1
    or i use a new variable
        User::Var2                  input                  numeric              1                 -1
        User::Var2Return        output                 numeric              1                 -1
    but i alwas get the error
    "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
    Has anybody an idea how I can solve this problem?
    Thanks a lot.
    Kind Regards,
    Alice

    Hi Alain,
    thx for your answer.
    I have around 15 procedures called one after the other to calculated and modify my values. Each procedure is responsible for an other but overlapping set of variables. So i thought it would be a good idea to call them one after the other with the needed variables via a execute sql task.
    So if i use a result set, how i get my stored procedure to return 10 values? I would have to use a Function instead of a procedure, wouldn't i?
    As if i have 15 procedures this would be a lot of work.
    But thanks a lot for the idea. I think an other idea would be to create one function which calls all stored procedures and returns all the calculated values as a result set, wouldn't it?.
    Kind Regards.
    Alice

  • How can I use a different driver for audio input and output?

    I did a search of course, and came up with something about an aggregate. I have no idea what this is, how to do it, or if it would even work for me.
    What I am trying to do is:
    1) Record into Logic Express using my Tascam US-122.
    2) Have playback come out of my computer sound system, not the Tascam.
    If I go over to the Audio setup window, I can only record when the driver is set to Tascam US-122. Likewise, I can only listen to sound when my Built-In Audio is selected. It gets rather annoying going between the two.
    So, would this aggregate thing solve my problem? If so, how do I do it? Thanks for any help!
    -allen

    Yes it should do what you want.
    Go to "Audio Midi Setup", and go to the Audio menu and click "Open Aggregate Device Editor". The interface is pretty simple but if you do get stuck, just use the help function in Audio Midi Setup, as it has a step by step guide.
    Then when you return to logic, go to the Preferences>Audio>Drivers section and select Aggregate Device as the new driver rather than either the built in sound or the tascam. Then the inputs and outputs will apply to BOTH devices.

  • How to use a bluetooth cellphone for audio input and output

    Hello, I was wondering how to set-up my Mac Book so that I can use my bluetooth cellphone for audio in and audio out. Ideally, I would like to use my handset for talking on iChat and Skype. Has anyone had any luck doing this? When I bond my cellphone these optiosn do not appear. I know that this is easy to do on a Windows machine but I am not sure about how to do it on my Mac Book.
    Thanks!

    Yes it should do what you want.
    Go to "Audio Midi Setup", and go to the Audio menu and click "Open Aggregate Device Editor". The interface is pretty simple but if you do get stuck, just use the help function in Audio Midi Setup, as it has a step by step guide.
    Then when you return to logic, go to the Preferences>Audio>Drivers section and select Aggregate Device as the new driver rather than either the built in sound or the tascam. Then the inputs and outputs will apply to BOTH devices.

  • I have on;y one audio port can i use it for input and output at the same time?

    i have the new macbook pro 13 in and i want to connect aguitar as input and output on an amp but i have only one audio port

    You can't use the jack as an input and output simultaneously. The solution is to look for a USB or Firewire interface to get your guitar sound into the computer.

  • Table name input. and output i need  all rows and columns  using procedures

    hi,
    question: table name input. and output i need all rows and columns by using procedures.
    thanks,
    To All

    An example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • How to control (the input and output) EXE file after I call it using exec?

    Hi,
    I knew that I can use runtime.exec() to call one EXE file, and this works. But this EXE has two characteristics:
    1. After this exe starts, it asks user to input number such as 1 or 2 onto computer screen, then press return. Then the exe will start the calculation.
    2. after it starts calculation, it prints 3 columns of numbers onto the screen.
    My two questions are:
    1. How to use java to input the number such as 1 or 2 automatically? this EXE can not work like this in DOS command line:
    C:> file.exe parameter
    The parameter is the number such as 1 or 2 that I wanna input.
    2. how to redirect the 3 columns of numbers from computer screen to txt file?
    My colleague can solve these two questions using Mathematica. So I know that definitely there is at least one solution for it. I just can not do it using Java. This wierd exe file bothered me a lot and I really wish that I can get help from someone in java community.
    Thank you!
    Tony

    When you call Runtime.exec, you get a Process object. (I presume something similar happens when you use ProcessBuilder.) Process has methods with names getOutput, getInput, and getError. These correspond to the standard input, standard output, and standard error streams of the spawned process.
    You can read and write to the process on the streams corresponding to input and output that the process writes to the console.
    [add]
    In fact, you should be grabbing and reading the output/error streams anyway, because of the points raised by the Traps article. Google "Java Runtime exec traps" and you'll probably get a link to this JavaWorld article, which describes common Runtime.exec problems and how to solve them.
    Edited by: paulcw on Jun 15, 2010 4:09 PM

Maybe you are looking for