Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB-6008 write analog out with Python

Hello,

how do I write to the DA output of the USB-6008 with python?

I installed the latest version of NI-DAQmx runtime (18.10) and installed the nidaqmx python package with pip.

Could you please give me an example how to simply write a value to one analog output?

When I use (as mentioned in the documentation):

import nidaqmx
from nidaqmx.types import CtrTime

with nidaqmx.Task() as task:
	task.ao_channels.add_ao_voltage_chan("Dev1/ao0")
	task.write([1.1, 2.2, 3.3, 4.4, 5.5], auto_start=True)

I got the error message:

nidaqmx.errors.DaqError: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_AO_Max
Requested Value: 10.0
Maximum Value: 5.0
Minimum Value: 0.0
Channel Name: Dev1/ao0

Task Name: _unnamedTask<0>

Status Code: -200077

Isn't there a simpler method to write to the DA?

What does the failure message mean?

 

Thank you very much in advance!

- Olli

0 Kudos
Message 1 of 3
(5,105 Views)

Hi,

 

In task write you specify value more than 5. As you can see in error message, this is max you can output.

Best Regards,
TK
Certified LabVIEW Architect (CLA)

Message 2 of 3
(5,071 Views)

I solved this error by setting task.ao_channels.add_ao_voltage_chan("Dev1/ao0",min_val=0.0,max_val=5.0).

 

While USB-6008 provides analog output 0 to 5 volts, the default argument setting of the function is -10 to 10 volts, it should be properly set.

 

 

I have a similar error message as follows:

import nidaqmx.system

task = nidaqmx.Task()
task.ao_channels.add_ao_voltage_chan("Dev1/ao0")
task.write([0.0, 1.1])

 

 

Traceback (most recent call last):

File "<ipython-input-3-def2c75c44d0>", line 1, in <module>
task.write([0.0, 1.1])

File "C:\Users\slee\Anaconda3\lib\site-packages\nidaqmx\task.py", line 1169, in write
channels_to_write = self.channels

File "C:\Users\slee\Anaconda3\lib\site-packages\nidaqmx\task.py", line 168, in channels
self._handle, flatten_channel_string(self.channel_names))

File "C:\Users\slee\Anaconda3\lib\site-packages\nidaqmx\_task_modules\channels\channel.py", line 118, in _factory
check_for_error(error_code)

File "C:\Users\slee\Anaconda3\lib\site-packages\nidaqmx\errors.py", line 127, in check_for_error
raise DaqError(error_buffer.value.decode("utf-8"), error_code)

DaqError: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_AO_Max
Requested Value: 10.0
Maximum Value: 5.0
Minimum Value: 0.0
Channel Name: Dev3/ao0

Task Name: _unnamedTask<0>

Status Code: -200077

 

 

 

somehow, the error might be related with some character encoding rather than inputting a wrong value.

do you have any idea of what is wrong?

 

Message 3 of 3
(4,690 Views)