11-08-2013 10:43 AM
I am developing an application in Visual Basic 6.0 using the NI-6034E board.
I am trying to to set Ch0 and Ch8 as a differential input channel.
The code I wrote works fine if I use DAQmx_Val_Cfg_Default parameter, but I get an error 'Variable not defined' if I use DAQmx_Val_Cfg_Diff.
This is the code involved :
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", DAQmx_Val_Cfg_Default, minValueTextBox.Text, maxValueTextBox.Text, DAQmx_Val_VoltageUnits1_Volts, "") = OK
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", DAQmx_Val_Cfg_Diff, minValueTextBox.Text, maxValueTextBox.Text, DAQmx_Val_VoltageUnits1_Volts, "") = error
I am using the DAQmx version 8.01
11-12-2013 03:47 PM
What's the value of physicalChannelTextBox.Text?
In DAQmx you just configure the positive input for a differential channel (e.g. "Dev1/ai0"). While ai8 will be used as the negative input for the differential measurement, it isn't configured in software. In fact, you'll get an error if you try to configure ai8 as a differential input (since it is already the negative terminal for ai0).
Best Regards,
11-13-2013 03:08 AM
Thank you for your reply.
I understand that but I didn't try to configure CH8, the problem is a different one.
I am using Ch0 (only one channel), TextBox.Text = Dev1/ai0
The problem is that then I try to configure 'Dev1/ai0' as 'Diff' I get the error 'Variable not defined' :
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", DAQmx_Val_Cfg_Diff, minValueTextBox.Text, maxValueTextBox.Text, DAQmx_Val_VoltageUnits1_Volts, "")
This configuration works fine but it's not a differential input configuration.
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", DAQmx_Val_Cfg_Default, minValueTextBox.Text, maxValueTextBox.Text, DAQmx_Val_VoltageUnits1_Volts, "")
11-13-2013 11:37 AM - edited 11-13-2013 11:38 AM
Ah, that's because you should be using DAQmx_Val_Diff. Here are the valid inputs according to the DAQmx C Reference Help:
DAQmx_Val_Cfg_Default | At run time, NI-DAQmx chooses the default terminal configuration for the channel. | |
DAQmx_Val_RSE | Referenced single-ended mode | |
DAQmx_Val_NRSE | Non-referenced single-ended mode | |
DAQmx_Val_Diff | Differential mode | |
DAQmx_Val_PseudoDiff | Pseudodifferential mode |
Best Regards,
11-14-2013 10:25 AM
Thank you John,
I made a mistake I wrote DAQmx_Val_Cfg_Diff instead of DAQmx_Val_Diff (I am actually using the coprrect parameter) as tyou can see below :
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, physicalChannelTextBox.Text, "", DAQmx_Val_Diff, minValueTextBox.Text, maxValueTextBox.Text, DAQmx_Val_VoltageUnits1_Volts, "")
I still get the 'Variable not defined' error message.
11-14-2013 10:37 AM
It doesn't make sense to me as both DAQmx_Val_Cfg_Default and DAQmx_Val_Diff are defined in the same place (NIDAQmx.h--you are including this in your program, right?). If you hadn't included NIDAQmx.h I would expect both variables to be undefined.
Are you sure it's DAQmx_Val_Diff that's undefined? Is it possible you still have DAQmx_Val_Cfg_Diff somewhere in your code?
Best Regards,
11-14-2013 11:43 AM
I am using VB6, not C and therefore I have no NIDAQmx.h or similar.
I even tried to use DAQmx_Val_PseudoDiff and got the same error message.
It seems that only DAQmx_Val_Cfg_Default is defined.
By the way I can't find where these variables are defined, I guess it happens in the driver.
This seems to be the function called by the timer to read the input channel :
DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, 10#, fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
I took an official NI example code and just modified the channel input configuration.
The rest works fine so far.
Anyway, I guess/hope you have used this family of 16bit data acquisition boards or similar.
How many bits, stipping the noise floor, can I actulaly expect to use on a high sampling rate like 100kHz?
Beacause of the high rate I cannot use averaging, it would defeat the purpose.
11-14-2013 01:23 PM
In VB6 you should still need to include the appropriate DAQmx library and header files. I don't have VB6 but I did manage to find some instructions here.
5. The first time you run these examples, you will need to add the DAQmx include and library files to the Visual Studio environment. Select Tools»Options.
6. Click the Directories tab. Make sure you are viewing the directories for include files, and add the following new path: C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include.
7. Add a link for library files with the following path: C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc.
It sounds like you're asking about the accuracy of the readings you might expect, you can find the specification here. I'll admit I'm more familiar with more recent NI-DAQ cards which typcially spec noise as a standard deviation, but it looks like the 6034E spec page quantifies noise for both single point and averaged results.
Best Regards,
11-15-2013 02:30 AM
Thank you again for your help,
but I cannot find the Directories tab in the Tools»Options of my computer.
I realised I have Visual Basic 6.0 development environment, not Visual Studio.
I will check it with a friend who has the full Visual Studio package.