07-06-2018 11:22 AM
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
07-16-2018 05:54 AM
Hi,
In task write you specify value more than 5. As you can see in error message, this is max you can output.
04-26-2019 02:15 PM - edited 04-26-2019 02:38 PM
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?