03-31-2014 11:26 AM
Hi, I need to select a voltage range such as -1V to +1V from .m file in MATLAB to acquire data from NI-6008 DAQ.
I appreciate if some one send me an example code.
The system is working fine and I can successfully control sampling rate but not the Voltage range.
Regards
Solved! Go to Solution.
04-01-2014 05:57 PM
Please see this discussion forum post related to your input task:
http://forums.ni.com/t5/Multifunction-DAQ/ni-daq-6008-with-matlab/td-p/2515242
04-02-2014 11:23 AM
@Karl-G wrote:
Please see this discussion forum post related to your input task:
http://forums.ni.com/t5/Multifunction-DAQ/ni-daq-6008-with-matlab/td-p/2515242
Thanks. I will check it.
Best regards.
04-02-2014 11:33 AM
@Karl-G wrote:
Please see this discussion forum post related to your input task:
http://forums.ni.com/t5/Multifunction-DAQ/ni-daq-6008-with-matlab/td-p/2515242
Hi Karl, it seems that non of the provided answers in the discussion solve my problem. Therefore my question is still waiting for a valid answer.
Many thanks for your help
04-02-2014 11:55 AM
s = daq.createSession('ni')
ch = s.addAnalogInputChannel('dev1', 0, 'voltage')
ch.Range = [-1 1]
Alternatively,
s = daq.createSession('ni')
s.addAnalogInputChannel('dev1', 0, 'voltage')
s.Channels(1).Range = [-1 1]
Wael Hemdan
MathWorks
04-02-2014 11:58 AM
@whemdan wrote:
s = daq.createSession('ni')
ch = s.addAnalogInputChannel('dev1', 0, 'voltage')
ch.Range = [-1 1]
Alternatively,
s = daq.createSession('ni')
s.addAnalogInputChannel('dev1', 0, 'voltage')s.Channels(1).Range = [-1 1]
Wael Hemdan
MathWorks
Thanks Wael.
I will try the second alternative as the first one did not work.
Best regards to you.
04-02-2014 12:09 PM - edited 04-02-2014 12:27 PM
Hi
Both alternatives are equivalent, the 2nd alternative is how to get to a channel if you had not saved it to a variable when you created it.
When you say it did not work, did you get an error message?
I just tried it on my machine with an NI USB-6008 with 4 channels, and range set to [-1 1] on one of those channels:
>> 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.
>> s.addAnalogInputChannel('dev2', 0:3, 'voltage')
ans =
Data acquisition session using National Instruments hardware:
Will run for 1 second (1000 scans) at 1000 scans/second.
Number of channels: 4
index Type Device Channel MeasurementType Range Name
----- ---- ------ ------- --------------- ---------------- ----
1 ai Dev2 ai0 Voltage (Diff) -20 to +20 Volts
2 ai Dev2 ai1 Voltage (Diff) -20 to +20 Volts
3 ai Dev2 ai2 Voltage (Diff) -20 to +20 Volts
4 ai Dev2 ai3 Voltage (Diff) -20 to +20 Volts
>> s.Channels(2).Range = [-1 1]
s =
Data acquisition session using National Instruments hardware:
Will run for 1 second (1000 scans) at 1000 scans/second.
Number of channels: 4
index Type Device Channel MeasurementType Range Name
----- ---- ------ ------- --------------- ------------------ ----
1 ai Dev2 ai0 Voltage (Diff) -20 to +20 Volts
2 ai Dev2 ai1 Voltage (Diff) -1.0 to +1.0 Volts
3 ai Dev2 ai2 Voltage (Diff) -20 to +20 Volts
4 ai Dev2 ai3 Voltage (Diff) -20 to +20 Volts
Properties, Methods, Events
>> s.inputSingleScan
ans =
-0.0034 0.0008 0.0012 0.0059
Wael Hemdan
MathWorks
04-02-2014 02:53 PM
@whemdan wrote:
Hi
Both alternatives are equivalent, the 2nd alternative is how to get to a channel if you had not saved it to a variable when you created it.
When you say it did not work, did you get an error message?
I just tried it on my machine with an NI USB-6008 with 4 channels, and range set to [-1 1] on one of those channels:
>> 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.
>> s.addAnalogInputChannel('dev2', 0:3, 'voltage')
ans =
Data acquisition session using National Instruments hardware:
Will run for 1 second (1000 scans) at 1000 scans/second.
Number of channels: 4
index Type Device Channel MeasurementType Range Name
----- ---- ------ ------- --------------- ---------------- ----
1 ai Dev2 ai0 Voltage (Diff) -20 to +20 Volts
2 ai Dev2 ai1 Voltage (Diff) -20 to +20 Volts
3 ai Dev2 ai2 Voltage (Diff) -20 to +20 Volts
4 ai Dev2 ai3 Voltage (Diff) -20 to +20 Volts
>> s.Channels(2).Range = [-1 1]
s =
Data acquisition session using National Instruments hardware:
Will run for 1 second (1000 scans) at 1000 scans/second.
Number of channels: 4
index Type Device Channel MeasurementType Range Name
----- ---- ------ ------- --------------- ------------------ ----
1 ai Dev2 ai0 Voltage (Diff) -20 to +20 Volts
2 ai Dev2 ai1 Voltage (Diff) -1.0 to +1.0 Volts
3 ai Dev2 ai2 Voltage (Diff) -20 to +20 Volts
4 ai Dev2 ai3 Voltage (Diff) -20 to +20 Volts
Properties, Methods, Events
>> s.inputSingleScan
ans =
-0.0034 0.0008 0.0012 0.0059
Wael Hemdan
MathWorks
Great.
Thanks a lot Wael.
It is now perfectly working.
Best regards