Device Selection



It' s possible to write a procedure that allow me to choose which device to perform an acquisition with my nationals boars?
I would select also the channels firstly to perform an acquisition.
Yes I know,
but I wish that when I start my program, It asks me directly that devices use to make the acquisition, if e.g. the Dev1 or DEV2.

As command to make the acquisition I using "DAQmx_Scan / DEV =" dev1 "WAVES =" wave1, 2; "

Therefore I would like to have the possibility to choose which device to use.

In the NIDAQ manual, I found this command:
fDAQmx_DeviceNames ()

but when I start it, nothing happens, but you should see the list of devices in the system.
fDAQmx_DeviceNames() returns a ";" separated list of the device names. It is not providing a selection on itself. try
print fDAQmx_DeviceNames()
You could feed this to a simple user input, store the name in a global string, and pass the string to the acquisition function.
HJ
Okay , but when , for example, I write the command (fDAQmx_DeviceNmaes) in the command window , the operation goes , but nothing appears .
where am I wrong ?
kachy_89P wrote:
Okay , but when , for example, I write the command (fDAQmx_DeviceNmaes) in the command window , the operation goes , but nothing appears .
where am I wrong ?


Following HJ's suggesting, in the command window enter:

 print fDAQmx_DeviceNmaes()
ok , I had not realized the print command .
Perfect, now it lists the two devices I have in the system .
Now try to write a procedure for the selection and then the place :) thanks a lot
It's ok?
It's a problem to select a single, specific device.
Why I don't Understand!!!uff

Function storeDev()
    print fDAQmx_DeviceNames()
    string/G DN
    DN =  fDAQmx_DeviceNames()
end

Function Scan()
    string DN
    make/O/N=100 wave1
    setscale/P x, 0,0.1, "s", Wave1
    DAQmx_SCAN/DEV= "DN" WAVES=" wave1, 2;"
ENd
kachy_89P wrote:
It's ok?
It's a problem to select a single, specific device.
Why I don't Understand!!!uff

Function storeDev()
    print fDAQmx_DeviceNames()
    string/G DN
    DN =  fDAQmx_DeviceNames()
end

Function Scan()
    string DN
    make/O/N=100 wave1
    setscale/P x, 0,0.1, "s", Wave1
    DAQmx_SCAN/DEV= "DN" WAVES=" wave1, 2;"
ENd


In the Scan() function, the global variable needs to be referenced by using this syntax:


SVAR DN = DN

But your are feeding the entire list to the fDAQmx command. Is this what you want? From your previous posts, you state that you want to choose the card to use. In that case, try the following code.

Function SelectDev()
    String/G DN =  ""
    String sSelected = ""
    string DAQlist = ""
    DAQlist =  fDAQmx_DeviceNames()
    print DAQlist
    Prompt sSelected, "Device to Use:", popup, DAQlist
    DoPrompt "Select a DAQ to use", sSelected
    if( V_flag == 1 )
        print "User Canceled"
        return 1
    endif
    DN = sSelected
end
 
Function Scan()
    SVAR DN = DN
    make/O/N=100 wave1
    setscale/P x, 0,0.1, "s", Wave1
    DAQmx_SCAN/DEV= "DN" WAVES=" wave1, 2;"
End


Hope this helps.
Thanks!
I just test your procedure, but, when Scan() is launched, appear this error (I lunch fDAQmx_ErrorString):

- print fDAQmx_ErrorString()
NI-DAQmx driver error while calling function DAQmxCreateAIVoltageChan; device DN:-200220: Device identifier is invalid.
Extended info:
Device identifier is invalid.
Device Specified: DN
Suggested Device(s): Dev3, Dev2
Task Name: DN
Status Code: -200220



NB: My two Dev are Simulated
kachy_89P wrote:
Thanks!
Extended info:
Device identifier is invalid.
Device Specified: DN
Suggested Device(s): Dev3, Dev2
Task Name: DN
Status Code: -200220



NB: My two Dev are Simulated


I'm not familiar with the NiDAQ functions and operations, so I'm not going to be much help here. However, from the error message quoted above, it appears that the flag: /DEV="DN" is being used incorrectly. I imagine that the syntax where the Device ID is quoted anticipates a literal string. You are using a string variable, so I would suggest trying the following to see which works...

DAQmx_SCAN/DEV= DN WAVES=" wave1, 2;"

DAQmx_SCAN/DEV= (DN) WAVES=" wave1, 2;"

or possibly, bu less likely,

DAQmx_SCAN/DEV= $DN WAVES=" wave1, 2;"

Perhaps someone familiar with this function will offer more knowledgeable comments.

Also, edit the scan function to print DN so you can see exactly what value is has

Function Scan()
    SVAR DN = DN
        print DN
...
Hi,
yesterday I checked with the "print" command, and actually the variable is correctly assigned.

However, as you advance you in your post, being a variable you need to change the command SCAN, like:

DAQmx_SCAN / DEV = DN = WAVES "wave1, 2;"

or this one

DAQmx_SCAN / DEV = (DN) WAVES = "wave1, 2;"

and the system works.

Thanks so much!
Have a nice day!