Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding 2 lines of DAQmx code into traditional C

Hello All,
 
I have traditional C-code in Visual C++ and I added these two lines (plus the necessary lib links and #include and #define lines) from DAQmx to convert channel 5 to a thermocouple channel:
 
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIThrmcplChan
      (taskHandle,"Dev1/ai5","",0.0,100.0,DAQmx_Val_DegC,DAQmx_Val_T_Type_TC,DAQmx_Val_ConstVal,25.0,""));
 
The rest of the code following it is traditional legacy c-code such as:
 
iStatus = DAQ_Rate(dSampRate, iUnits, &iSampTB, &uSampInt);
iStatus = DAQ_Rate(dScanRate, iUnits, &iScanTB, &uScanInt);
iStatus = DAQ_DB_Config(iDevice, iDBmodeON);
iRetVal = NIDAQErrorHandler(iStatus, "DAQ_DB_Config", iIgnoreWarning);
iStatus = SCAN_Sequence_Setup(iDevice, iNumChans, piChanVect, piGainVect, piScanRateDivVect, &iScansPerSeq,  &iSampsPerSeq); iRetVal = NIDAQErrorHandler(iStatus, "SCAN_Sequence_Setup", iIgnoreWarning);
 ...
 
I am using channels 0-5, the sampling rate is the same on all of them, and only ch.5 needs to be a thermocouple channel (ch.5 has a thermocouple probe attached).
 
Do I need to add anything else to get the DAQmx lines to work?
 
My new program compiles, builds, and runs fine, but shows zero on channel 5. The other voltage channels show the correct readings. I have a feeling the DAQmx lines I added are not taking effect.  I read somewhere that when adding DAQmx code to traditional C-code, something has to be unregistered then re-registered?

Thanks,
progprogprog
 
P.S.: The daq card I am using is PCI-6071E.
 
0 Kudos
Message 1 of 6
(3,683 Views)
>Do I need to add anything else to get the DAQmx lines to work?

Yes- you need to convert everything to use NI-DAQmx calls. You can't mix traditional and mx code.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 2 of 6
(3,676 Views)
Does traditional C-code have an equivalent function to convert a channel to thermocouple measurement? Or is this present only in mx? Thanks in advance.
0 Kudos
Message 3 of 6
(3,659 Views)
Why not do the task entirely with NI-DAQmx? It's more future-proof, more consistent across different DAQ products, and will allow you to move to M-series and newer devices. NI-DAQ Traditional should really only be used to run existing systems.

There are a number of examples in the NI-DAQmx installation, including using thermocouples.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 4 of 6
(3,654 Views)
Hello,
 
When reading temperature measurements with Traditional NI-DAQ, the voltage measurement is generally converted to a temperature based on software calculations explicity programmed in your LabVIEW or C program.  LabVIEW generally has VI's to make this conversion based on thermocouple types and CJC constants, etc.
 
It looks like you have two options.  I agree with John from WaveMetrics that the easiest thing to do would be to upgrade your code to the NI-DAQmx driver.  DAQmx allows you to create thermocouple "tasks" where you specify the thermocouple, and the temperature conversion is done automatically for you. 
 
The other option would be to stick with Traditional and use the analog input read that you've been using, and copy some algorithms that you can probably find online to convert your voltage into temperature based on your thermocouple.  Either would work.
 
I hope this helps,
 
Daniel L.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(3,642 Views)

I'm working on converting the code, but 90% of it will need to be re-written. This is for the long term.

If anyone can find the traditional code algorithms to convert an analog input channel to thermocouple, let me know.

 

Thanks in advance.

0 Kudos
Message 6 of 6
(3,613 Views)