Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -200077 from DAQmxCreateAOVoltageChan

I'm making DAQmx function declarations from within my Delphi program
and can get DAQmxResetDevice and DAQmxCreateTask to work without
errors. However, I get error -200077 "Requested value is not a
supported value for this property." from DAQmxCreateAOVoltageChan.
I'm not sure what the correct value for the Units parameter is, as the
NI-DAQmx C Reference gives it as "DAQmx_Val_Volts" which I cannot
access since I am programming in Delphi (Ver 7 with DAQmx 7.3).

I've tried using assigned variables as in :
{ DAQmx_status := DAQmxCreateAOVoltageChan (TaskHandle,
AO_physicalChannel, nameToAssignToChannel, minVal, maxVal, units,
customScaleName); }

Or directly providing parameters to the function as in :
DAQmx_status := DAQmxCre
ateAOVoltageChan (TaskHandle, 'Dev1/AO1',
'CH0' , -10, 10, 0, nil);

DAQmxCreateAOVoltageChan is declared as :

interface

function DAQmxCreateAOVoltageChan (TaskHandle : cardinal; const
physicalChannel : PChar; const nameToAssignToChannel : PChar;
minVal : double; maxVal : double;
units : integer; const customScaleName : PChar) : integer; stdcall;

Implementation
function DAQmxCreateAOVoltageChan (TaskHandle : cardinal; const
physicalChannel : PChar; const nameToAssignToChannel : PChar;
minVal : double; maxVal : double;
units : integer; const customScaleName : PChar) : integer; external
'nicaiu.dll';

I get the same error from Analog Input in DAQmxCreateAIVoltageChan.
This is on a PCI-MIO-16E-4 which is listed in MAX undex DAQmx
hardware..

Is there a list somewhere of what the numerical values are for the
various named parameters such as DAQmx_Val_Volts, assuming that is the
problem ?

Steve
0 Kudos
Message 1 of 11
(7,524 Views)
Hello Steve

(some answers may be in nidaqmx.h)

Ulrich
0 Kudos
Message 2 of 11
(7,522 Views)
Hi everyone,

I'm trying to create a task which uses DAQmxCreateAIVoltageChan in Visual Basic 6!

Private Declare Function DAQmxCreateAIVoltageChan Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal PhysicalChannel As String, ByVal nameToAssignToChannel As String, ByVal TerminalConfig As DAQmxTerminalConfig, ByVal minVal As Double, ByVal maxVal As Double, ByVal units As DAQmxUnits, ByVal customScaleName As String) As Long

Public Enum DAQmxTerminalConfig
DAQmx_Val_Cfg_Default = -1
DAQmx_Val_RSE = 0
DAQmx_Val_NRSE = 1
DAQmx_Val_Diff = 2
DAQmx_Val_PseudoDiff = 3
End Enum

Public Enum DAQmxUnits
DAQmx_Val_Volts = 0
DAQmx_Val_FromCustomScale = 1
End Enum


I am getting error code : -200077 : Requested value is not ....

I guess this comes from ByVal customScaleName As String where in ANSI C I have to asign NULL. Can someone tell me what I have to write in Visual Basic, I have tried vbnullstring, vbnullcharacter, 0 ,"" chr(0) ...., Null , Nothing etc.

A little shorter: What is "const char NULL" (ANSI C) in Visual Basíc!
Maybe there is another problem, but don't see one.
Thanks,

Holger
0 Kudos
Message 3 of 11
(7,474 Views)
Hi Holger!

I had a similar problem with matlab, where xy=[] did the job...
Does this link help you:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/office97/html/usingdynamic-linklibraries.asp
It talks about MS Access, but I think the methods described there apply to the full Visual Basic to the the same degree.

This link (German, sorry)
http://www.a-m-i.de/tips/strings/strings.php
talks about defining and trimming strings and the null terminator in VB, maybe useful for you?
If I understand correctly:
teststring=space(0) (Might be enough?! http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctspace.asp )
teststring=trim(teststring)

Good luck
Jens
Message 4 of 11
(7,467 Views)
Hallo Jens!

Deutsch ist natürlich auch ok! 😉
Thanks for your reply! I'll check that tomorrow. Looks promising and I hope to solve my problems with that.
I'll let you know my efforts tomorrow!
Cheers

Holger
0 Kudos
Message 5 of 11
(7,456 Views)
Hi,

unfortunately I had no success! Maybe someone can help me out with this.
Declaration:
Private Declare Function DAQmxCreateAIVoltageChan Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal PhysicalChannel As String, ByVal nameToAssignToChannel As String, ByVal TerminalConfig As DAQmxTerminalConfig, ByVal minVal As Double, ByVal maxVal As Double, ByVal units As DAQmxUnits, ByVal customScaleName As String) As Long
and
Public Enum DAQmxTerminalConfig
DAQmx_Val_Cfg_Default = -1
DAQmx_Val_RSE = 0
DAQmx_Val_NRSE = 1
DAQmx_Val_Diff = 2
DAQmx_Val_PseudoDiff = 3
End Enum

Public Enum DAQmxUnits
DAQmx_Val_Volts = 0
DAQmx_Val_FromCustomScale = 1
End Enum
(Are these numbers correct?? - C Reference don't say anything about the numbers)

Then I create a Task with:
DAQmxErrChk DAQmxCreateTask("", taskHandle)
No errors so far!
Then:
DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", "", DAQmx_Val_NRSE, -10, 10, DAQmx_Val_Volts, "")

Here the returned error is: -200077 : Requested value is not a supported value for this property.
I have no clue where to search the error! I have tried to put 10 different things in ByVal customScaleName As String !
Anyone know what to do???
Thanks

Holger
0 Kudos
Message 6 of 11
(7,439 Views)
Hi Holger!

I am too busy getting my Matlab/ADbasic/Ni-DAQmx-Hybrid to work, so I did not try it in VB 6.
But I can for sure confirm that the numbers you use are wrong!
For example:
DAQmx_Val_Volts = 10348
The correct values should be loaded into VB when you load the lib/dll I think!
So you can use DAQmx_Val_Volts as a global/public(?) variable.
You might want to have a look in the provided VB examples how to properly import the NI libraries (with the definitions of the constants).
If this fails, have a look at
...\National Instruments\NI-DAQ\Include\nidaqcns.inc
in your NI installation folder.
In this file, all the NI constants are listed.

CU & good luck
Jens
Message 7 of 11
(7,432 Views)
You should be able to get more contextual information about the error by calling DAQmxGetExtendedErrorInfo. This should tell you which specific attribute value is invalid.

Good luck,
Joe
Message 8 of 11
(7,431 Views)
Hi,

When you are putting in the values for terminal configurations (or anything else for that matter), you need to look in the NIDAQmx.h file to see what the appropriate values are.



//*** Values for DAQmx_AI_TermCfg ***
//*** Value set InputTermCfg ***
#define DAQmx_Val_RSE 10083 // RSE
#define DAQmx_Val_NRSE 10078 // NRSE
#define DAQmx_Val_Diff 10106 // Differential
#define DAQmx_Val_PseudoDiff 12529 // Pseudodifferential


//*** Value for the Terminal Config parameter of DAQmxCreateAIVoltageChan, DAQmxCreateAICurrentChan and DAQmxCreateAIVoltageChanWithExcit ***
#define DAQmx_Val_Cfg_Default -1 // Default
Message 9 of 11
(7,430 Views)
Hi everyone,

thanks for your help! Now it works!
I didn't know to set these weird numbers!
Is there a limitation on how fast I can create and clear tasks or how fast I can send one command after another?
Because I get an Overflow-Errormessege in VB6 when I don't execute the commands step by step!
Nevertheless your hints where very successfull!
Thanks

Holger
0 Kudos
Message 10 of 11
(6,925 Views)