session-based DAQ won't let me add analogoutput channel (windows 7, NIDAQ 6009)

3 visualizzazioni (ultimi 30 giorni)
I am trying to add an analog output channel, and even though I follow the documentation example carefully, no joy. It's only 2 lines of code - what is going wrong? I'm using the NIDAQ USB 6009 interface. Analog input works great. Thanks!
DOCUMENTATION: (“Generate Analog Output Signals”)
  1. s = daq.createSession('ni');
  2. addAnalogOutputChannel(s,'cDAQ1Mod2',0,'Voltage')
ans =
Data acquisition session using National Instruments hardware:
No data queued. Will run at 1000 scans/second. Number of channels: 1
index Type Device Channel MeasurementType Range Name
----- ---- --------- ------- --------------- ---------------- ----
1 ao cDAQ1Mod2 ao0 Voltage -10 to +10 Volts
Specify the channel ID on NI devices using a terminal name, like 'ao1', or a numeric equivalent like 1.
I GET THIS:
  1. s = daq.createSession('ni');
  2. addAnalogOutputChannel(s,'Dev1',0,'Voltage')
Warning: A channel that does not support clocked sampling was added to
the session. Clocked operations using startForeground and
startBackground will be disabled. Only on-demand operations using
inputSingleScan and outputSingleScan can be done.
ans =
Data acquisition session using National Instruments hardware:
Clocked operations using startForeground and startBackground are disabled.
Only on-demand operations using inputSingleScan and outputSingleScan can be done.
Number of channels: 1
index Type Device Channel MeasurementType Range Name
----- ---- ------ ------- ------------------- --------------- ----
1 ao Dev1 ao0 Voltage (SingleEnd) 0 to +5.0 Volts

Risposta accettata

Nidhi Jain
Nidhi Jain il 14 Lug 2014
Modificato: Nidhi Jain il 14 Lug 2014
Hi,
From the output, it looks like, you have been able to add the channel. “ao0” is the channel that got created after you executed:
>> addAnalogOutputChannel(s,'Dev1',0,'Voltage')
Inspite the warning message, the channel got added.
To check if the Analog output is working, you can use the “outputSingleScan” command:
>> outputSingleScan(s,[3.0])
You can refer the document for more information on outputSingleScan: http://www.mathworks.com/help/releases/R2014a/daq/ref/outputsinglescan.html
If this is not what you expected, let me know what you are trying to do and what you expect from the above line?
  2 Commenti
Bill betz
Bill betz il 14 Lug 2014
Hi Nidhi, Thanks very much for your answer. I should have said that I need to run analog INPUT as well as output. Also, the output signal is a pulse, so I need at least two 'scans' - to 5V and then back to zero. So, I want to queue the output signal (e.g., [0; 5; 0]) and then, when a button is clicked on the GUI, start the output. All the while, analog INPUT is running in the background (using a Listener to get and plot the data as they arrive. Best wishes, Bill
Nidhi Jain
Nidhi Jain il 15 Lug 2014
Hi Bill,
You can have the background session running for the analog input (using the listener to get and plot data), this can initiate the callback every 1/10th of a second, but since you also want a GUI at the same time, I think you will have better success using 2 MATLAB sessions.
If the callback did contain the GUI code, it would get refreshed too often to be able to press the buttom for the analog output.
If you could incorporate the GUI code that calls the analog output in the background function itself, that could be an option.
For example, if the analog input has a callback running in the background which is called every half second, and this callback checks the system time and once the time is a multiple of 5, it runs the analog output. So you don’t have the GUI code but the analog output is run every 5 minutes by the background callback itself.
I hope this helps.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Acquisition Toolbox Supported Hardware in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by