Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Using analog output with NI DAQmx Tools for MatLab

Hello,

I'm trying to program my NI-USB 6008 with The Mathworks MatLab. On this site, I found a very useful toolbox, called NI-DAQmx tools for MatLab.
http://zone.ni.com/devzone/conceptd.nsf/webmain/f7312fdfe627eed186257139001eca49 

All functions work perfectly, with one notable exception : I can't manage using analog outputs.

My needs are very simple : I need to set a single voltage on one of the outputs, then return control to my MatLab application and keep the value as set.

Although it's not exactly what I'm trying to do, I tried the function "GenNUpdates", which is supposed to send to the AO an array of data at a fixed rate.
Unfortunately, it doesn't work, I get the following error :

??? Error using ==> GenNUpdates
Error -200452 occurred at Property Node DAQmx Timing (arg 1) in MEXToolkit_Generate N Updates.vi->Generate N Updates.vi->858990635368GenNUpdates_nonUI.vi->858990635368GenNUpdates_nonUI.vi.ProxyCaller

Possible reason(s):

Specified property is not supported by the device or is not applicable to the task.

Property: SampClk.Rate

Task Name: _unnamedTask<DC1>

Curiously, the same function seems to work properly using another card (a PCMCIA NI 6024E).

On the other hand, in the toolbox, there are also demos with a user interface.
When I run the demo called GenNUPdates_UI, I get a control panel which seems to correspond to a simpler function : you enter a single value with a cursor, and obviously there is no rate to enter.  This works perfectly with the USB-6008, and I actually don't need anything more. But of course, I can't use it with the user interface, I need to access the underlying function.

So my question is double :
1. Is there a way to make the non-UI function work with the USB-6008, and set its rate to 0 Hz to get a single DC value ?
2. If not, is there a way to strip the UI-demo from its user interface and use it from the MatLab code ?

Thanks a lot for your help in anticipation,
Jean-Louis

 
0 Kudos
Message 1 of 5
(5,978 Views)

Hello Jean-Louis,

You are getting this error because you try to use a hardware-timed task for the USB-6008, which is not supported by this device, only software-timing.

Sorry, but i'm not familiar with the DAQmx Tools for MatLab, but there must be another function using software-timing for AO, and using this one it

should be possible to set the frequency to 0.

Hope this helps a little bit, Christian

 

 

0 Kudos
Message 2 of 5
(5,939 Views)
 I've run into exactly the same problem as jllon, but with a USB-6009. Was this problem ever resolved?

 It seems that the code in GenNUpdates_UI accommodates simple single-value setting of analog output voltages on the USB-6009, but the code in
GenNUpdates does not. There are no other MEX-files in the NI-DAQmx Tools for MATLab install which appear to do the job.

 Since the code obviously exists, would it be possible for a non-UI version of single value analog output setting to be provided as an MEX-file with the NI-DAQmx Tools for MATLab? Could a version be provided here?

0 Kudos
Message 3 of 5
(5,793 Views)
It was solved, but in a rather different way. Actually, these routines which are written in LabView have a very poor performance, which makes them of very little practical value.

Instead, NI support in Belgium pointed to an article which describes a much better method : accessing NI's DLL directly from MatLab. All functions which are normally accessible from ANSI C can in this way be called from MatLab.

Some info can be found here :
http://forums.ni.com/ni/board/message?board.id=250&message.id=10165&requireLogin=False
but I also received a sample file from NI (don't know if this one is available on the site).

An alternative method which seems to work equally well is via MatLab's Data Acquisition Toolbox : it now supports the USB cards and offers many functions, even if it's less complete than NI's DLL.

Good luck !
Jean-Louis


0 Kudos
Message 4 of 5
(5,787 Views)
Thanks for the link, Jean-Louis! Loading the NI-DAQmx DLL nicaiu.dll with the loadlibrary command allowed calls to all the DAQmx routines necessary to set the analog output on my USB-6009.
0 Kudos
Message 5 of 5
(5,743 Views)