Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2147

DAQ problems

$
0
0

I'm trying to write a data acquisition program in Visual Basic 6.0 running on a Windows 10 platform.
I have a DAQ system with a USB6251 OEM board installed and a microphone acting as an acoustic sensor.

I have stripped my VB program down as far as possible so as to remove any potential causes of error.

It looks like this:
**************************************************************************
Option Explicit
Dim taskHandle As Long
**************************************************************************
Private Sub btnStart_Click()
Dim data(1000) As Double
Dim numRead As Long 'variable stores the actual number of samples read
Dim terminalConfig As Long

terminalConfig = 10106

' Define error checking function
'#define DAQmxErrChk(functionCall) if( DAQmxFailed(error= (functionCall)) ) goto Error; else

'// Create Task
DAQmxErrChk (DAQmxCreateTask("", taskHandle))
DAQForm.Print ; "Done Create Task"

'// Create voltage input channel
'DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", " ", DAQmx_Val_Cfg_Default, -10, 10, DAQmx_Val_Volts, " "))
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", " ", terminalConfig, -10, 10, DAQmx_Val_Volts, " "))
DAQForm.Print ; "Done Create Channel"; DAQmx_Val_Cfg_Default; DAQmx_Val_Volts

'// Configure sample clock timing
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle, "", 100, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000))
DAQForm.Print ; "Done Configure"; DAQmx_Val_Rising; DAQmx_Val_FiniteSamps

'// Start Task
DAQmxErrChk (DAQmxStartTask(taskHandle))
'DAQForm.Print ; "Done Start Task"

'// Read data
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle, 100, 10, DAQmx_Val_GroupByChannel, data, 1000, numRead, ByVal 0&))
DAQForm.Print ; "Done Read Analog"


'// DAQmx Stop Code
DAQmxErrChk DAQmxStopTask(taskHandle)
DAQmxErrChk DAQmxClearTask(taskHandle)

End Sub
**************************************************************************
I have 2 modules linked in.

The first is NIDAQmxErrorCheck.bas whch contains the DAQmxErrChk function.
The second module is NIDAQmxBase.bas which handles the calls to the NI-DAQmxBase library.

At the Create Voltage Input Channel line, I run one or other of the commands to see if either works. The outcome is the same.

I get either a DAQmx Error Code 201003 Device cannot be accessed or else it prints out the diagnostic prints after each DAQ command then the program crashes.

 

I can't understand why I get the 201003 message. When I plug in my DAQ system, I call up the NI Device Monitor. It is set to Differential mode and when I move the microphone, the output voltage waveform jumps all over the place - which is entirely what I would expect. That confirms to me that, at least, a signal is getting into the laptop. So why does my program say the input device is absent or unpowered?

 

If I don't get the 201003 message, then the program executes the diagnostic print statement at DAQForm.Print ; "Done Configure"; DAQmx ... then the program crashes out.


Can someone kindly explain to me what I need to do to ensure that the program continues through the Start Task and beyond without crashing?


Viewing all articles
Browse latest Browse all 2147

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>