Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. National Instruments USB 6002 read data in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

National Instruments USB 6002 read data in Qt Creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
39 Posts 8 Posters 13.0k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sneubertS Offline
    sneubertS Offline
    sneubert
    wrote on last edited by
    #14

    NI has a lot of tutorials on how to use the DAQmx drivers.
    For example look at http://www.ni.com/tutorial/5409/en/#toc3

    1 Reply Last reply
    1
    • R rockon209

      ok.

      Can you give me a small example just to check the that DAQ lib is working in Mingw. Its important for me. I am not doubting your intelligence but i want to know how i can use it in a code, i havnt work on this kind of project earlier and have to idea how to do that. Pleas help.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #15

      @rockon209 said in National Instruments USB 6002 read data in Qt Creator:

      Can you give me a small example just to check the that DAQ lib is working in Mingw

      To use a 3rd party library in a Qt-based project, you need to tell your *.pro file where to find the library's headers, and where to find the library's binaries.

      The simplest way is to add the paths straight into your *.pro file:

      INCLUDEPATH += "C:/Program Files (x86)/National Instruments/NI-DAQ/DAQmx ANSI C Dev/include"
      LIBS += "C:/Program Files (x86)/National Instruments/NI-DAQ/DAQmx ANSI C Dev/lib/msvc/NIDAQmx.lib"
      

      Then, in your *.cpp file, just include the library header and call its functions:

      // main.cpp
      #include <QApplication>
      #include <QWidget>
      #include <QDebug>
      
      #include <NIDAQmx.h>
      
      int main(int argc, char **argv)
      {
          // Initialize a usual Qt application
          QApplication app(argc, argv);
          QWidget w;
      
          // Initialize DAQmx and read analog input (Copied and simplified from
          // http://www.ni.com/tutorial/5409/en/#toc3 )
          TaskHandle taskHandle = 0;
          int32 samplesReceived = 0;
          float64 data[1000];
      
          DAQmxCreateTask("MyTask", &taskHandle);
          DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL);
          DAQmxCfgSampClkTiming(taskHandle, "", 10000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);
          DAQmxStartTask(taskHandle);
          DAQmxReadAnalogF64(taskHandle, 1000, 10.0, DAQmx_Val_GroupByChannel, data, 1000, &samplesReceived, NULL);
          DAQmxStopTask(taskHandle);
          DAQmxClearTask(taskHandle);
      
          // Print results
          qDebug() << "Received" << samplesReceived << "points";
          for (int i = 0; i < samplesReceived; ++i)
              qDebug() << data[i];
      
          // Run Qt event loop
          w.show();
          return app.exec();
      }
      

      The example code above does not contain any error handling. You must add it yourself.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      5
      • R Offline
        R Offline
        rockon209
        wrote on last edited by rockon209
        #16

        thanks @sneubert

        @JKSH Thanks. I ran the code you have mentioned above, it ran successfully and got output as "Received 0 points."
        Does it means its working? I dont understand.
        I mean to say what should be the output of the code?

        JKSHJ 2 Replies Last reply
        0
        • R rockon209

          thanks @sneubert

          @JKSH Thanks. I ran the code you have mentioned above, it ran successfully and got output as "Received 0 points."
          Does it means its working? I dont understand.
          I mean to say what should be the output of the code?

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #17

          @rockon209 said in National Instruments USB 6002 read data in Qt Creator:

          I ran the code you have mentioned above, it ran successfully

          OK, that means your Qt application successfully linked to the NI DAQmx library.

          and got output as "Received 0 points."

          That means you didn't manage to acquire any data from the device.

          Modify the code to print the return value of every DAQmx* function call. The return value will be 0 if the call succeeded, or non-zero if there was an error.

          qDebug() << "Error code for DAQmxCreateTask():" << DAQmxCreateTask("MyTask", &taskHandle);
          qDebug() << "Error code for DAQmxCreateAIVoltageChan():" << DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, -10.0, 10.0, DAQmx_Val_Volts, NULL);
          ...
          

          (For example, maybe your device is not called "Dev1", so the call to DAQmxCreateAIVoltageChan failed.)

          Anyway, you now need to learn how to use the NI DAQmx library to interact with your device. That is beyond the scope of the Qt forum. I suggest you continue at the National Instruments forum: https://forums.ni.com/t5/Multifunction-DAQ/bd-p/250 Introduce yourself and say that you are trying to program DAQmx in C/C++.

          Good luck!

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          2
          • R Offline
            R Offline
            rockon209
            wrote on last edited by
            #18

            @JKSH Thank you so much for your help, it means a lot. One final question if the Qt application did not get linked to the NI DAQmx library then, i would have got the errors because of the use of various function like DAQmxCreateTask.... is it correct?

            JKSHJ 1 Reply Last reply
            0
            • R rockon209

              @JKSH Thank you so much for your help, it means a lot. One final question if the Qt application did not get linked to the NI DAQmx library then, i would have got the errors because of the use of various function like DAQmxCreateTask.... is it correct?

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #19

              @rockon209 said in National Instruments USB 6002 read data in Qt Creator:

              @JKSH Thank you so much for your help, it means a lot.

              You're welcome :)

              After you create a thread in the other forum, do post a link here, so that anyone else who wants to use Qt to drive NI devices can follow your discussions.

              One final question if the Qt application did not get linked to the NI DAQmx library then, i would have got the errors because of the use of various function like DAQmxCreateTask.... is it correct?

              Correct. If your code can't link to the library, then your *.exe won't be created. MinGW will complain something like "Undefined reference to 'DAQmxCreateTask' "

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2
              • R rockon209

                thanks @sneubert

                @JKSH Thanks. I ran the code you have mentioned above, it ran successfully and got output as "Received 0 points."
                Does it means its working? I dont understand.
                I mean to say what should be the output of the code?

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #20

                @rockon209 said in National Instruments USB 6002 read data in Qt Creator:

                I ran the code you have mentioned above, it ran successfully and got output as "Received 0 points."
                Does it means its working? I dont understand.
                I mean to say what should be the output of the code?

                I just had a thought: Was your USB-6002 plugged into your computer when you ran the program?

                I tried it with Qt 5.6.2 (MinGW 4.9.2) + a USB-6003, and this is what I got:

                Received 1000 points
                -0.0971611
                -0.0978048
                -0.0984484
                -0.0987703
                -0.0994139
                -0.0994139
                -0.100058
                -0.100701
                -0.100701
                -0.100701
                -0.101023
                -0.101023
                -0.101345
                -0.101345
                -0.101667
                -0.101667
                -0.101989
                -0.101667
                -0.101989
                -0.101989
                -0.102632
                -0.102632
                -0.102632
                -0.102632
                -0.102954
                -0.102632
                -0.102954
                -0.102632
                -0.102954
                -0.102954
                -0.102954
                -0.103276
                -0.102632
                -0.103276
                -0.103276
                -0.103276
                -0.103276
                -0.103276
                -0.103276
                -0.10392
                -0.103598
                -0.103276
                -0.103276
                -0.103276
                -0.10392
                -0.103598
                -0.104241
                -0.103276
                -0.103276
                -0.10392
                -0.103598
                -0.103598
                -0.10392
                -0.103276
                -0.103276
                -0.103276
                -0.103276
                -0.102954
                -0.103276
                -0.102954
                -0.102632
                -0.102954
                -0.102954
                -0.102632
                -0.101989
                -0.10231
                -0.102632
                -0.101989
                -0.101667
                -0.101667
                -0.101667
                -0.101667
                -0.101667
                -0.101023
                -0.101023
                -0.101023
                -0.101023
                -0.100701
                -0.100701
                -0.100379
                -0.100701
                -0.100701
                -0.101023
                -0.100701
                -0.100701
                -0.100379
                -0.100701
                -0.100379
                -0.100701
                -0.100379
                -0.100701
                -0.100701
                -0.100701
                -0.100701
                -0.100701
                -0.100701
                -0.100379
                -0.100701
                -0.100701
                -0.100701
                -0.100701
                -0.100701
                -0.101023
                -0.100701
                -0.100379
                -0.101667
                -0.100379
                -0.100701
                -0.101023
                -0.100701
                -0.101023
                -0.101667
                -0.101345
                -0.101667
                -0.101667
                -0.101345
                -0.101989
                -0.101989
                -0.101989
                -0.10231
                -0.101989
                -0.10231
                -0.102954
                -0.102954
                -0.102954
                -0.102954
                -0.103276
                -0.102954
                -0.102954
                -0.103276
                -0.103276
                -0.10392
                -0.10392
                -0.104563
                -0.104563
                -0.104241
                -0.104563
                -0.10392
                -0.10392
                -0.104563
                -0.104563
                -0.104885
                -0.104885
                -0.104885
                -0.105207
                -0.105529
                -0.105207
                -0.104885
                -0.105529
                -0.105207
                -0.105851
                -0.105529
                -0.105851
                -0.105529
                -0.105851
                -0.106494
                -0.106494
                -0.106494
                -0.106494
                -0.106816
                -0.106816
                -0.10746
                -0.107781
                -0.107138
                -0.108103
                -0.108425
                -0.108425
                -0.108425
                -0.109069
                -0.109069
                -0.109391
                -0.109712
                -0.110034
                -0.110034
                -0.109712
                -0.110678
                -0.110678
                -0.110678
                -0.111
                -0.111322
                -0.111
                -0.111322
                -0.111322
                -0.111322
                -0.111322
                -0.111643
                -0.111965
                -0.112287
                -0.111965
                -0.111965
                -0.111965
                -0.112287
                -0.111643
                -0.111965
                -0.112287
                -0.112609
                -0.112609
                -0.112287
                -0.112609
                -0.112931
                -0.112931
                -0.112931
                -0.112931
                -0.112931
                -0.113896
                -0.112931
                -0.112931
                -0.112931
                -0.112609
                -0.112931
                -0.113253
                -0.112931
                -0.112931
                -0.112931
                -0.112609
                -0.112931
                -0.113253
                -0.113253
                -0.113574
                -0.113253
                -0.113253
                -0.113253
                -0.113896
                -0.113574
                -0.113253
                -0.113574
                -0.113253
                -0.113253
                -0.113253
                -0.113253
                -0.113574
                -0.113896
                -0.112931
                -0.113253
                -0.113253
                -0.113574
                -0.113574
                -0.113253
                -0.113574
                -0.113574
                -0.113253
                -0.113253
                -0.113574
                -0.112609
                -0.112931
                -0.113253
                -0.113253
                -0.112609
                -0.112931
                -0.112609
                -0.113253
                -0.112931
                -0.112287
                -0.112931
                -0.112609
                -0.111965
                -0.111643
                -0.111643
                -0.111965
                -0.111643
                -0.111322
                -0.111643
                -0.111
                -0.111322
                -0.111
                -0.110678
                -0.111
                -0.110678
                -0.110034
                -0.110034
                -0.109712
                -0.109712
                -0.109712
                -0.109069
                -0.109069
                -0.109069
                -0.108747
                -0.108747
                -0.108747
                -0.108103
                -0.108103
                -0.108103
                -0.107781
                -0.108103
                -0.108103
                -0.10746
                -0.107781
                -0.10746
                -0.108425
                -0.10746
                -0.108103
                -0.108103
                -0.107781
                -0.108103
                -0.107781
                -0.108103
                -0.108425
                -0.108103
                -0.108103
                -0.108103
                -0.10746
                -0.10746
                -0.107781
                -0.108103
                -0.108103
                -0.107781
                -0.10746
                -0.108425
                -0.108425
                -0.108103
                -0.108103
                -0.108425
                -0.108425
                -0.108747
                -0.108103
                -0.108747
                -0.109069
                -0.109069
                -0.109069
                -0.109391
                -0.109069
                -0.109069
                -0.108747
                -0.109069
                -0.109712
                -0.109391
                -0.109391
                -0.109712
                -0.109712
                -0.110356
                -0.109391
                -0.110034
                -0.110356
                -0.110034
                -0.110034
                -0.110034
                -0.110678
                -0.110356
                -0.110678
                -0.111
                -0.110678
                -0.110356
                -0.110678
                -0.110678
                -0.110678
                -0.111322
                -0.111322
                -0.111965
                -0.111643
                -0.111965
                -0.111322
                -0.111965
                -0.111965
                -0.111965
                -0.112287
                -0.112287
                -0.112609
                -0.112609
                -0.112931
                -0.112931
                -0.112609
                -0.113253
                -0.113896
                -0.113253
                -0.113896
                -0.114218
                -0.114862
                -0.114218
                -0.11454
                -0.114862
                -0.115505
                -0.115505
                -0.115505
                -0.116149
                -0.116149
                -0.116793
                -0.117115
                -0.116471
                -0.116793
                -0.116471
                -0.116793
                -0.117115
                -0.116793
                -0.117115
                -0.117115
                -0.117115
                -0.117436
                -0.117436
                -0.117436
                -0.117436
                -0.117758
                -0.117436
                -0.117758
                -0.117758
                -0.11808
                -0.118402
                -0.117758
                -0.117115
                -0.117758
                -0.117758
                -0.117758
                -0.117436
                -0.118402
                -0.11808
                -0.118724
                -0.118402
                -0.118402
                -0.118402
                -0.11808
                -0.118402
                -0.11808
                -0.11808
                -0.118402
                -0.11808
                -0.11808
                -0.11808
                -0.118402
                -0.118724
                -0.118402
                -0.117758
                -0.117758
                -0.117758
                -0.11808
                -0.117115
                -0.117758
                -0.11808
                -0.117758
                -0.117758
                -0.118402
                -0.118402
                -0.117758
                -0.117758
                -0.118402
                -0.118724
                -0.118402
                -0.11808
                -0.11808
                -0.117758
                -0.118402
                -0.117758
                -0.117758
                -0.11808
                -0.11808
                -0.117436
                -0.117758
                -0.11808
                -0.117436
                -0.117436
                -0.117436
                -0.117436
                -0.117115
                -0.117758
                -0.117436
                -0.117115
                -0.116793
                -0.117115
                -0.116471
                -0.116471
                -0.116471
                -0.116149
                -0.115827
                -0.115827
                -0.115505
                -0.115505
                -0.115505
                -0.114862
                -0.115184
                -0.114862
                -0.115184
                -0.114218
                -0.114218
                -0.113896
                -0.113896
                -0.113253
                -0.113574
                -0.113574
                -0.113574
                -0.113253
                -0.112931
                -0.113253
                -0.112931
                -0.112931
                -0.112287
                -0.112609
                -0.112609
                -0.112609
                -0.112609
                -0.112287
                -0.111965
                -0.112287
                -0.112287
                -0.112609
                -0.112609
                -0.112609
                -0.111965
                -0.111965
                -0.112287
                -0.111643
                -0.112287
                -0.112287
                -0.111322
                -0.111643
                -0.111643
                -0.111965
                -0.112287
                -0.111322
                -0.111965
                -0.111965
                -0.111965
                -0.112287
                -0.111965
                -0.112609
                -0.112287
                -0.111965
                -0.112287
                -0.112609
                -0.112609
                -0.112287
                -0.112609
                -0.112287
                -0.112609
                -0.112931
                -0.112931
                -0.112931
                -0.113253
                -0.113574
                -0.113253
                -0.113574
                -0.113574
                -0.113253
                -0.113253
                -0.113574
                -0.113896
                -0.113574
                -0.113574
                -0.113896
                -0.114218
                -0.11454
                -0.11454
                -0.11454
                -0.114218
                -0.11454
                -0.11454
                -0.11454
                -0.114218
                -0.11454
                -0.115505
                -0.114862
                -0.114862
                -0.115505
                -0.115505
                -0.115184
                -0.115505
                -0.115505
                -0.116149
                -0.115827
                -0.116149
                -0.116471
                -0.116149
                -0.116471
                -0.116793
                -0.116793
                -0.117115
                -0.117436
                -0.117758
                -0.117436
                -0.117758
                -0.118402
                -0.118402
                -0.118724
                -0.118724
                -0.118402
                -0.118724
                -0.118724
                -0.119367
                -0.119367
                -0.119046
                -0.119367
                -0.119689
                -0.120011
                -0.120011
                -0.120333
                -0.120655
                -0.120011
                -0.120333
                -0.120333
                -0.120655
                -0.120976
                -0.120976
                -0.120976
                -0.120976
                -0.120976
                -0.120976
                -0.12162
                -0.12162
                -0.12162
                -0.121298
                -0.121298
                -0.120976
                -0.121942
                -0.12162
                -0.12162
                -0.12162
                -0.12162
                -0.120976
                -0.121298
                -0.121298
                -0.121942
                -0.121942
                -0.121942
                -0.121942
                -0.121942
                -0.12162
                -0.121942
                -0.121942
                -0.122264
                -0.122264
                -0.121298
                -0.121298
                -0.121942
                -0.121298
                -0.121942
                -0.121942
                -0.12162
                -0.121298
                -0.12162
                -0.121298
                -0.12162
                -0.12162
                -0.121942
                -0.12162
                -0.12162
                -0.121298
                -0.120976
                -0.121298
                -0.12162
                -0.121298
                -0.120976
                -0.121298
                -0.121298
                -0.121298
                -0.121298
                -0.121298
                -0.121298
                -0.120976
                -0.120976
                -0.120976
                -0.120976
                -0.121298
                -0.120655
                -0.120333
                -0.120333
                -0.120333
                -0.120011
                -0.120011
                -0.120333
                -0.119367
                -0.119367
                -0.119689
                -0.118724
                -0.119046
                -0.118724
                -0.118402
                -0.118402
                -0.118724
                -0.118402
                -0.118402
                -0.11808
                -0.117758
                -0.117758
                -0.117758
                -0.117436
                -0.117436
                -0.117115
                -0.116793
                -0.116149
                -0.116149
                -0.116471
                -0.115827
                -0.115505
                -0.116149
                -0.116149
                -0.116149
                -0.116149
                -0.115827
                -0.116149
                -0.115827
                -0.115184
                -0.115505
                -0.115184
                -0.115827
                -0.115827
                -0.116149
                -0.115827
                -0.115505
                -0.115827
                -0.115505
                -0.115827
                -0.115184
                -0.115184
                -0.115505
                -0.115505
                -0.115505
                -0.115184
                -0.115184
                -0.115184
                -0.114862
                -0.115505
                -0.114862
                -0.114862
                -0.115184
                -0.115505
                -0.115184
                -0.115184
                -0.115505
                -0.115184
                -0.115184
                -0.115505
                -0.115827
                -0.116149
                -0.115827
                -0.116471
                -0.116471
                -0.115827
                -0.116471
                -0.116471
                -0.116471
                -0.116793
                -0.116471
                -0.117115
                -0.117115
                -0.117115
                -0.117758
                -0.117115
                -0.117115
                -0.117115
                -0.117115
                -0.117115
                -0.117436
                -0.117436
                -0.117758
                -0.11808
                -0.117758
                -0.118402
                -0.117758
                -0.118402
                -0.118402
                -0.117758
                -0.11808
                -0.118402
                -0.118402
                -0.11808
                -0.118724
                -0.119046
                -0.119046
                -0.119046
                -0.119367
                -0.119046
                -0.119367
                -0.119689
                -0.120011
                -0.120011
                -0.120655
                -0.120655
                -0.120655
                -0.120333
                -0.120655
                -0.120976
                -0.12162
                -0.12162
                -0.12162
                -0.121942
                -0.121942
                -0.122264
                -0.121942
                -0.122586
                -0.122586
                -0.122264
                -0.123229
                -0.123229
                -0.123229
                -0.122907
                -0.123873
                -0.123551
                -0.123873
                -0.123551
                -0.123551
                -0.123551
                -0.123873
                -0.123873
                -0.123551
                -0.123873
                -0.123873
                -0.124517
                -0.12516
                -0.124195
                -0.124195
                -0.124195
                -0.124517
                -0.124838
                -0.124517
                -0.124517
                -0.124838
                -0.124517
                -0.124838
                -0.124838
                -0.124517
                -0.124838
                -0.124517
                -0.124517
                -0.124195
                -0.124517
                -0.124517
                -0.124517
                -0.124517
                -0.124838
                -0.124517
                -0.124517
                -0.124195
                -0.124195
                -0.124517
                -0.124517
                -0.124195
                -0.124838
                -0.124517
                -0.124517
                -0.123873
                -0.123551
                -0.124195
                -0.123873
                -0.123873
                -0.123551
                -0.124195
                -0.123873
                -0.123873
                -0.123873
                -0.123873
                -0.123873
                -0.123551
                -0.123873
                -0.123229
                -0.123551
                -0.123229
                -0.123551
                -0.123551
                -0.123551
                -0.122586
                -0.122907
                -0.122907
                -0.122907
                -0.122907
                -0.122907
                -0.122907
                -0.122264
                -0.122264
                -0.122586
                -0.121942
                -0.12162
                -0.121942
                -0.12162
                -0.12162
                -0.121298
                -0.120976
                -0.120655
                -0.120655
                -0.120976
                -0.120333
                -0.120655
                -0.120333
                -0.119689
                -0.119689
                -0.119689
                -0.119689
                -0.119367
                -0.119046
                -0.118724
                -0.118724
                -0.118402
                -0.119046
                -0.118402
                -0.118724
                -0.117758
                -0.117758
                -0.11808
                -0.11808
                -0.117758
                -0.117436
                -0.117758
                -0.117436
                -0.117115
                -0.117436
                -0.117115
                -0.117115
                -0.117436
                -0.117115
                -0.117115
                -0.117436
                -0.117758
                -0.117436
                -0.117115
                -0.117758
                -0.117436
                -0.117436
                -0.117758
                -0.117115
                -0.117115
                -0.117758
                -0.117758
                -0.117436
                -0.117115
                -0.117436
                -0.117758
                -0.117436
                -0.117436
                -0.117758
                -0.11808
                -0.118402
                -0.11808
                -0.117758
                -0.117758
                -0.118724
                -0.11808
                -0.118402
                -0.118402
                -0.118402
                -0.118402
                -0.118402
                -0.118724
                -0.119046
                -0.118724
                -0.119046
                -0.119046
                -0.119046
                -0.119046
                -0.118724
                -0.119367
                -0.119689
                -0.120011
                -0.119367
                -0.119689
                -0.119689
                -0.119689
                -0.119689
                -0.120011
                -0.120011
                -0.120011
                -0.120333
                -0.120333
                -0.120976
                -0.120976
                -0.120655
                -0.120333
                -0.121298
                -0.120655
                -0.120976
                -0.12162
                -0.12162
                -0.12162
                -0.121298
                -0.121942
                -0.12162
                -0.122264
                -0.122907
                -0.122586
                -0.122907
                -0.122586
                -0.122907
                -0.122907
                -0.122907
                -0.123551
                -0.123873
                -0.123873
                -0.123873
                -0.123873
                -0.124195
                -0.124838
                -0.124838
                -0.124517
                -0.124517
                -0.124838
                -0.124838
                -0.12516
                -0.125482
                -0.125482
                -0.12516
                -0.125804
                -0.125804
                -0.125804
                -0.126126
                -0.125482
                -0.125482
                -0.125804
                -0.126126
                -0.125804
                -0.125804
                -0.126448
                -0.126769
                -0.126126
                -0.126126
                -0.126448
                

                It's reading around 0 volts because I didn't connect any input signals.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rockon209
                  wrote on last edited by
                  #21

                  @JKSH Yes the device is plugged into the computer. But when i see in the NI Measurement and automation explorer its not detected. I read some where if you have USB3.0 drivers then its not detecting the earlier format devices (even it is connected to USB1.0 or USB 2.0) not sure though what is the problem.
                  I got this

                  Received 0 points
                  Error code for DAQmxCreateTask(): 0
                  Error code for DAQmxCreateAIVoltageChan(): -88302
                  Error code for DAQmxCfgSampClkTiming(): -200477
                  Error code for DAQmxStartTask(): -200478
                  Error code for DAQmxReadAnalogF64(): -200478
                  Error code for DAQmxStopTask(): 0
                  Error code for DAQmxClearTask (): 0

                  JKSHJ 1 Reply Last reply
                  0
                  • R rockon209

                    @JKSH Yes the device is plugged into the computer. But when i see in the NI Measurement and automation explorer its not detected. I read some where if you have USB3.0 drivers then its not detecting the earlier format devices (even it is connected to USB1.0 or USB 2.0) not sure though what is the problem.
                    I got this

                    Received 0 points
                    Error code for DAQmxCreateTask(): 0
                    Error code for DAQmxCreateAIVoltageChan(): -88302
                    Error code for DAQmxCfgSampClkTiming(): -200477
                    Error code for DAQmxStartTask(): -200478
                    Error code for DAQmxReadAnalogF64(): -200478
                    Error code for DAQmxStopTask(): 0
                    Error code for DAQmxClearTask (): 0

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #22

                    @rockon209 said in National Instruments USB 6002 read data in Qt Creator:

                    @JKSH Yes the device is plugged into the computer. But when i see in the NI Measurement and automation explorer its not detected. I read some where if you have USB3.0 drivers then its not detecting the earlier format devices (even it is connected to USB1.0 or USB 2.0) not sure though what is the problem.
                    ...
                    Error code for DAQmxCreateAIVoltageChan(): -88302

                    Error -88302 seems to be related to driver problems: http://digital.ni.com/public.nsf/allkb/19E7993CF8366EED8625764200771C68?OpenDocument

                    Anyway, your issue is definitely under National Instruments territory. I suggest you re-install your DAQmx drivers (preferably the latest version), and if you're still having issues, ask at the NI forum.

                    Error code for DAQmxCfgSampClkTiming(): -200477
                    Error code for DAQmxStartTask(): -200478
                    Error code for DAQmxReadAnalogF64(): -200478

                    See http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/01d50d3f86ee67d8862576cf00745e78/$FILE/NI-DAQmxErrorCodes.PDF -- Errors -200477 and -200478 mean that DAQmx is complaining that you have no devices or channels.

                    Once you fix error -88302, these should go away.

                    (Final note: Since you are getting meaningful error codes from the DAQmx functions, this is further proof that your Qt application has successfully linked to the DAQmx library)

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    1
                    • R Offline
                      R Offline
                      rockon209
                      wrote on last edited by
                      #23

                      @JKSH It was the problem with NI software and uninstall the full software and install it again and now it works.
                      I have one more question i want to read the digital Input signal and i am using "DAQmxReadDigitalU16" function to read but i am not getting the ouput
                      i am getting following error:-
                      The program has unexpectedly finished.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        rockon209
                        wrote on last edited by
                        #24

                        NO worries all good.

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          rockon209
                          wrote on last edited by
                          #25

                          @JKSH
                          Hello JKSH as the code above mentioned i can get 1000 sample points when i run the code but if i want to read and store continuously the data from a port of the device how i can do it. Can you please helm me in this?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            smanchineella
                            wrote on last edited by
                            #26

                            @JKSH or anyone else how many experience in this field, I have encountered a similar issue to the one you have described in your previous posts. I have copied the sample code you posted above and have done extensive research, yet I am still receiving an error "Undefined Reference to DAQmxCreateTask' and so on for all my DAQmx commanddseventhough I have explicitly defined how the library is connected to the project in the project file as you have described in your previous post with the include path and library path. My paths also match yours exactly so I am incredibly confused on where this error is coming form. I have attached my source code, do you think you could take a quick look at what may be going wrong.

                            projectfilescreenshot.PNG mainfilescreenshot.PNG errormessagedisplayed.PNG

                            aha_1980A 1 Reply Last reply
                            0
                            • S smanchineella

                              @JKSH or anyone else how many experience in this field, I have encountered a similar issue to the one you have described in your previous posts. I have copied the sample code you posted above and have done extensive research, yet I am still receiving an error "Undefined Reference to DAQmxCreateTask' and so on for all my DAQmx commanddseventhough I have explicitly defined how the library is connected to the project in the project file as you have described in your previous post with the include path and library path. My paths also match yours exactly so I am incredibly confused on where this error is coming form. I have attached my source code, do you think you could take a quick look at what may be going wrong.

                              projectfilescreenshot.PNG mainfilescreenshot.PNG errormessagedisplayed.PNG

                              aha_1980A Offline
                              aha_1980A Offline
                              aha_1980
                              Lifetime Qt Champion
                              wrote on last edited by
                              #27

                              Hi @smanchineella,

                              some questions:

                              • which compiler are you using?
                              • which architecture, 32 or 64 bit?
                              • where is the file NIDAQmx.lib located on your computer?

                              Regards

                              Qt has to stay free or it will die.

                              S 1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                smanchineella
                                wrote on last edited by smanchineella
                                #28
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • aha_1980A aha_1980

                                  Hi @smanchineella,

                                  some questions:

                                  • which compiler are you using?
                                  • which architecture, 32 or 64 bit?
                                  • where is the file NIDAQmx.lib located on your computer?

                                  Regards

                                  S Offline
                                  S Offline
                                  smanchineella
                                  wrote on last edited by
                                  #29

                                  @aha_1980 I am using the default compiler which came with qt (I believe it is MinGW-64 bit). Both the compiler and my pc are both 64 bit. The NIDAQmx.lib file is located at C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib

                                  Please let me know if you see any issues with how it is setup on my pc. Any suggestions are greatly appreciated!

                                  aha_1980A 1 Reply Last reply
                                  0
                                  • S smanchineella

                                    @aha_1980 I am using the default compiler which came with qt (I believe it is MinGW-64 bit). Both the compiler and my pc are both 64 bit. The NIDAQmx.lib file is located at C:\Program Files (x86)\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib

                                    Please let me know if you see any issues with how it is setup on my pc. Any suggestions are greatly appreciated!

                                    aha_1980A Offline
                                    aha_1980A Offline
                                    aha_1980
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #30

                                    Hi @smanchineella,

                                    ...\lib\msvc\NIDAQmx.lib suggests that this is an import library for MSVC compiler. It does not say if that import library is for 32 or 64 bit. Both can be a problem.

                                    In principle, you cannot mix MSVC and MinGW compiler, so you will either need to switch to MSVC too, or find an include lib for MinGW.

                                    Also, make sure both have the same bitness, otherwise it will likely also fail.

                                    Regards

                                    Qt has to stay free or it will die.

                                    Pablo J. RoginaP JKSHJ 2 Replies Last reply
                                    1
                                    • aha_1980A aha_1980

                                      Hi @smanchineella,

                                      ...\lib\msvc\NIDAQmx.lib suggests that this is an import library for MSVC compiler. It does not say if that import library is for 32 or 64 bit. Both can be a problem.

                                      In principle, you cannot mix MSVC and MinGW compiler, so you will either need to switch to MSVC too, or find an include lib for MinGW.

                                      Also, make sure both have the same bitness, otherwise it will likely also fail.

                                      Regards

                                      Pablo J. RoginaP Offline
                                      Pablo J. RoginaP Offline
                                      Pablo J. Rogina
                                      wrote on last edited by
                                      #31

                                      It does not say if that import library is for 32 or 64 bit

                                      Based on the installation folder C:\Program Files (x86)\National Instruments\... under Windows 64 bit, we can assume it's a 32 bit version of the library.

                                      @smanchineella as @aha_1980 mentioned please pay attention at the compiler and bitness of the library you're trying to use.

                                      Upvote the answer(s) that helped you solve the issue
                                      Use "Topic Tools" button to mark your post as Solved
                                      Add screenshots via postimage.org
                                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                      S 1 Reply Last reply
                                      2
                                      • Pablo J. RoginaP Pablo J. Rogina

                                        It does not say if that import library is for 32 or 64 bit

                                        Based on the installation folder C:\Program Files (x86)\National Instruments\... under Windows 64 bit, we can assume it's a 32 bit version of the library.

                                        @smanchineella as @aha_1980 mentioned please pay attention at the compiler and bitness of the library you're trying to use.

                                        S Offline
                                        S Offline
                                        smanchineella
                                        wrote on last edited by smanchineella
                                        #32

                                        @Pablo-J-Rogina @aha_1980 When I downloaded the NIDAQmx file from the NI website, it said it includes both 32 and 64 bit import library depending on the bitness of the computer and the compiler. However, based on your both replies, how would I go about installing a 32 bit MSVC library and linking that in?

                                        1 Reply Last reply
                                        0
                                        • aha_1980A aha_1980

                                          Hi @smanchineella,

                                          ...\lib\msvc\NIDAQmx.lib suggests that this is an import library for MSVC compiler. It does not say if that import library is for 32 or 64 bit. Both can be a problem.

                                          In principle, you cannot mix MSVC and MinGW compiler, so you will either need to switch to MSVC too, or find an include lib for MinGW.

                                          Also, make sure both have the same bitness, otherwise it will likely also fail.

                                          Regards

                                          JKSHJ Offline
                                          JKSHJ Offline
                                          JKSH
                                          Moderators
                                          wrote on last edited by
                                          #33

                                          @smanchineella said in National Instruments USB 6002 read data in Qt Creator:

                                          I am using the default compiler which came with qt (I believe it is MinGW-64 bit).

                                          The online Qt installer provides both 32-bit and 64-bit versions of MinGW. There is no default; you select the one you want to install.

                                          You must install 3 things:

                                          • A compiler
                                          • Qt libraries
                                          • DAQmx libraries

                                          All 3 things must have the same bitness, and the Qt libraries must match your compiler.

                                          @aha_1980 said in National Instruments USB 6002 read data in Qt Creator:

                                          In principle, you cannot mix MSVC and MinGW compiler, so you will either need to switch to MSVC too, or find an include lib for MinGW.

                                          The compiler for NIDAQmx.lib doesn't really matter because it is a C library, not a C++ library.

                                          @smanchineella said in National Instruments USB 6002 read data in Qt Creator:

                                          how would I go about installing a 32 bit MSVC library and linking that in?

                                          You already have 32-bit DAQmx libraries. Now you need a 32-bit compiler and matching 32-bit Qt.

                                          • Download the 32-bit MSVC compiler from Microsoft: https://visualstudio.microsoft.com/vs/features/cplusplus/
                                          • Run MaintenanceTool.exe in your Qt folder and install Qt 5.15.2 for MSVC2019 (32-bit)

                                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                          aha_1980A 1 Reply Last reply
                                          2

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved