How to add a channel with session based interface?

4 views (last 30 days)
I'm trying to get an analog output with my NI-USB-6501 D/A device to control an other device. I've got the Data Acquisition Toolbox with 64bit Matlab R2011a running on Windows 7 .
First I tried to add or connect the device somehow with Matlab:
daqfind
ans =
[]
what were'n very succesfull. Then I tried:
s=daq.createsession('ni')
s=
Data acquisition session using National Instruments hardware:
Will run for 1 second (1000)scans at 1000 scans/second.
No channels have been added.
Next i wanted to add a channel. That's were my problems have started. With the 64bit version i must use the session-based interface, that's propably why this doesn't work
dio=digitalio('nidaq', 'Dev1')
So i tried
s.addAnalogOutputChannel('Dev1','ao2','Voltage')
and
ch=s.addAnalogOutputChannel('Dev1','ao2','Voltage')
but that all doesn't work at all. It answers:
???No appropriate method, property, or field addanalogoutputchannel for class daq.ni.session.
Im not sure wether I used the right deviceID, channelID and measurementType in
s.addAnalogOutputChannel(deviceID, channelID, measurementType)
Thanks in advance! Patrick

Accepted Answer

Friedrich
Friedrich on 23 Apr 2013
Edited: Friedrich on 23 Apr 2013
Hi,
it seems more like a programming mistake on your end. MATLAB is Case sensitive. Make sure you use the correct syntax:
>> s.addanalogoutputchannel
No appropriate method, property, or field addanalogoutputchannel for class
daq.ni.Session.
>> s.addAnalogOutputChannel
Adding a channel requires a device ID, a channel ID, and a measurement type.
The first call is most likely what you did (at least thats what the error message you get suggests), which will fail because the method name is wrong.
  1 Comment
Patrick
Patrick on 23 Apr 2013
Now I've got another problem.
s.addAnalogOutputChannel('Dev1','ao1','Voltage')
gives out:
??? There are no CompactDAQ devices available. So I tried to search/find my devices...
If I type in:
daq.getVendors
Matlab answers correctly with informations as ID, FullName, Adaptor Version etc.
But if I try :
daq.getDevices
ans =
No data acquisition devices available
The Matlabs help function wants me to examine my NI MAX. This NI MAX setupt has got a selftesting function which answers postitive. I also can create a task which is working (the device makes click sounds, which I thought would be my aim)
Might it be posible, that USB-6501 is no 'COMPACT' device and the command is only working with such 'COMPACT' devices?
Or might it be, that I'm completely on the wrong way? I thought i can add a channel and after i did that my device would give out the digital signals i want?
Thank you in advance!

Sign in to comment.

More Answers (0)

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!