Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Temperature in NI9211

I am developing software in VB6 for a client who has purchased two NI9211 with USB interface. I have downloaded and installed NI DAQmx. My VB program reads the values back from the device, but how do I get to temperature? Is there a simple VB example that shows how to retrieve temperature from the NI9211 with K-type thermocouples? I need this info urgently. I am not sure what the _CJTEMP value means - I know of course its the cold junction, but how do I use this value? I get 0.7739 mV back from this channel. Ai0 to ai3 are at about 128 uV. Best regards,
Peter AJ van der Made
Chief Scientist
vWISP Pty Ltd.

pmade@vwisp.net.au

0 Kudos
Message 1 of 3
(3,355 Views)

Peter,

This KnowledgeBase article shows where you can find the DAQmx examples for VB6.  The temperature examples should be in the Analog In/Measure Temperature folder.  One of these is for general thermocouple measurements.  I hope this helps you out. 

 

-Christina

Message 2 of 3
(3,339 Views)

Christina, my Visual Basic examples did not show any folder for thermocouple measurements, in fact, I could not find any examples online or in the NI knowledgebase that use the NI9211 and measure temperature using VB or VC++.

 

I figured it out though, here is the code that eventually worked and gave me a list of temperatures from one channel - easily changed to four channels (adapted from example: Acq_Int_clk). I hope it will be usefull to someone else;

 

Private Sub startCommandButton_Click()
    Dim sampsPerChanRead As Long
    Dim numChannels As Long
    Dim fillMode As DAQmxFillMode
    Dim bufferSize As Long
    Dim numSampsPerChannel As Long
    Dim arraySizeInSamps As Long
    ' DAQmx_Val_ThermocoupleType1_K_Type_TC
    On Error GoTo ErrorHandler
       
    startCommandButton.Enabled = False
    acquisitionDataGrid.ListItems.Clear
    acquisitionDataGrid.ColumnHeaders.Clear
   
    If ValidateControlValues Then
        startCommandButton.Enabled = True
        Exit Sub
    End If
   
    If scanOrderOption.Value = True Then
        fillMode = DAQmx_Val_GroupByScanNumber
    Else
        fillMode = DAQmx_Val_GroupByChannel
    End If
    bufferSize = 255
    numSampsPerChannel = CLng(samplesPerChannelTextBox.Text)
   
    'Create the DAQmx task.
    DAQmxErrChk DAQmxCreateTask("", taskHandle)
    taskIsRunning = True
 
    'Add an analog input channel to the task. (from original example code, removed)
    'DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", _
    '                DAQmx_Val_Cfg_Default, minValueTextBox.Text, maxValueTextBox.Text, _
    '                DAQmx_Val_VoltageUnits1_Volts, "")
                   
    DAQmxErrChk DAQmxCreateAIThrmcplChan(taskHandle, physicalChannelTextBox.Text, "", -100#, 1000#, DAQmx_Val_DegC, DAQmx_Val_ThermocoupleType1_K_Type_TC, DAQmx_Val_CJCSource1_BuiltIn, 0#, "")
    'Configure task for finite sample acquisition and read in data
    DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", frequencyTextBox.Text, DAQmx_Val_Rising, _
                    DAQmx_Val_AcquisitionType_FiniteSamps, CLng(samplesPerChannelTextBox.Text))
    DAQmxErrChk DAQmxGetTaskNumChans(taskHandle, numChannels)
    arraySizeInSamps = numSampsPerChannel * numChannels
    ReDim data(arraySizeInSamps)
   
    acquiringLabel.Visible = True
    acquiringLabel.Caption = "Acquiring..."
    DAQmxErrChk DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, 10#, _
                    fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
   
    'Populate the listView
    PopulateListView numChannels, fillMode, sampsPerChanRead
 
    'Call the StopTask module to stop the DAQmx task.
    StopTask
   
    startCommandButton.Enabled = True
   
     ' Display a message indicating the number of samples per channel read.
    acquiringLabel.Caption = "Samples per channel read = " & sampsPerChanRead
Exit Sub
   
ErrorHandler:
    If taskIsRunning = True Then
        DAQmxStopTask taskHandle
        DAQmxClearTask taskHandle
        taskIsRunning = False
    End If
    acquiringLabel.Visible = False
    startCommandButton.Enabled = True
    MsgBox "Error: " & Err.Number & " " & Err.Description, , "Error"
End Sub

 

 

0 Kudos
Message 3 of 3
(3,328 Views)