09-04-2015 04:54 AM
I want to sent a continuous signal and implement this function in Python 2.7. For this, I first tried the example of scipy cookbook:
http://forums.ni.com/ni/attachments/ni/250/84839/1/analogGenerationscipy.txt
I always get the error -200077: 'Requested value is not a supported value for this property. The property value may be invalid becau'
Thanh you
09-04-2015 08:58 AM
09-04-2015 10:01 AM
I use a NI USB-4431.
The adress of the output channel is "Dev1/ao0".
Here is a simpler code which still give an error with the function "DAQmxWriteAnalogF64" --> "argument 6: <type 'exceptions.TypeError'>: Don't know how to convert parameter 6"
import ctypes
import matplotlib.pyplot as plt
import numpy as np
nidaq = ctypes.windll.nicaiu # load the DLL
##############################
int32 = ctypes.c_long
uInt32 = ctypes.c_ulong
uInt64 = ctypes.c_ulonglong
float64 = ctypes.c_double
TaskHandle = uInt32
# the constants
DAQmx_Val_Cfg_Default = int32(-1)
DAQmx_Val_Volts = 10348
DAQmx_Val_Rising = 10280
DAQmx_Val_FiniteSamps = 10178
DAQmx_Val_GroupByChannel = 0
DAQmx_Val_GroupByScanNumber = 1
DAQmx_Val_Pascals = 10081
DAQmx_Val_Internal = 10200
DAQmx_Val_FromCustomScale = 10065
DAQmx_Val_Diff = 10106
DAQmx_Val_ContSamps = 10123
##############################
# initialize variables
taskHandle = TaskHandle(0)
max_num_samples = 10000
data = np.ones((max_num_samples,),dtype=np.float64)
freq_ech=102.4e3
nidaq.DAQmxCreateTask("",ctypes.byref(taskHandle))
nidaq.DAQmxCreateAOVoltageChan(taskHandle, "Dev1/ao0", "", float64(-1.0), float64(1.0), DAQmx_Val_Volts, None)
nidaq.DAQmxCfgSampClkTiming(taskHandle,"",float64(10000.0),DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,uInt64(max_num_samples))
nidaq.DAQmxWriteAnalogF64(taskHandle, max_num_samples, 0, -1, DAQmx_Val_GroupByScanNumber, data, None, None)
nidaq.DAQmxStartTask(taskHandle)
nidaq.DAQmxStopTask(taskHandle)
nidaq.DAQmxClearTask(taskHandle)