Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog input using Excel and NI USB-6008

I'm new here and need some help please.  I am using Excel VBA and NI USB-6008 to read in some analog voltages.  I have been through the VB6 examples and have come across the example using Excel for digital IO.  Can't seem to get my code to work and I'm sure it's to my lack of understanding the syntax.

 

I tried DAQmxReadAnalogScalarF64 and DAQmxReadAnalogF64, with adjusting things in the config_port_click() sub.

 

Not sure if it is configuration or in the read subs.  Thank you in advance for any help.

 

 

Dim taskHandle0 As Long
Dim Status0 As Double
Dim data(0) As Double

Sub Configure_Port_Click()

Status0 = DAQmxCreateTask("", taskHandle0)
Status0 = DAQmxCreateAIVoltageChan(taskHandle0, "Dev1/ai0:7", "", _
DAQmx_Val_InputTermCfg_RSE, 0, 10, _
DAQmx_Val_VoltageUnits2_Volts, "")
Status0 = DAQmxCfgSampClkTiming(taskHandle0, "OnboardClock", 50, DAQmx_Val_Rising, _
DAQmx_Val_AcquisitionType_ContSamps, 50)
Status0 = DAQmxStartTask(taskHandle0)


End Sub

Private Sub Image1_Click()

Stat0 = DAQmxReadAnalogF64(taskHandle0, 1000, 10#, _
DAQmx_Val_GroupByChannel, data(0), 8, 10, ByVal 0&)
'Status0 = DAQmxReadAnalogScalarF64(taskHandle0, 10#, data(0), ByVal 0&)

Range(Cells(3, 1).Address) = data(0)

End Sub

Sub Stop_Task_Click()
Status0 = DAQmxStopTask(taskHandle0)
Status0 = DAQmxClearTask(taskHandle0)

0 Kudos
Message 1 of 3
(4,182 Views)

There is an example for using VBA with digital lines:

http://www.ni.com/example/25305/en/

 

But overall NI does not support VBA programming. I would recommend using a different software to take your data (I.e. LabVIEW, Visual Studio, LabWindows/CVI, etc.) and then exporting it to excel. 

Dane S.
Product Support Engineer
National Instruments
0 Kudos
Message 2 of 3
(4,148 Views)

Thank you for your input Dane,

The example shows DIO, and from it I figured out how to use the Analog Out from Excel.  I was hoping to do the same for Analog Input.  Your point is well taken regarding NI not supporting VB and your recommendations to use LabView.  I still would enjoy either figuring this out or having my error/s pointed out so it could be a learning experience for me.

 

Love LabView and NI products.

0 Kudos
Message 3 of 3
(4,144 Views)