03-17-2016 02:36 AM - edited 03-17-2016 02:36 AM
CHAN AOCHANNEL1 AOCHANNEL2 AOCHANNEL1 AOCHANNEL2 .............and so on SAMP * * * * * * * * * * * * .............and so on
Hi Guys, how would I go about interleaving two arrays of different lenghts in a two channel analog output?
In the above illustration, for instance, I would like to write 5 values in channel 1 followed by a single value channel 2 and so on..
I am using the DAQmx library commands to achieve this (not LabView).
I am able to write single values each time a task is opened with no issues, I was wondering if I can interleave the arrays so that the values are buffered and the tasks are completed with greater haste.
warm regards,
Ravi
Solved! Go to Solution.
03-17-2016 09:31 PM
after some thought it feels like the best approach wil be to repeat the values of channel 2, the same number of times as channel 1, so that the arrays are made equal. Is this the only viable approach?
thanks,
Ravi
03-18-2016 04:34 AM
@Ravi_S wrote:after some thought it feels like the best approach wil be to repeat the values of channel 2, the same number of times as channel 1, so that the arrays are made equal. Is this the only viable approach?
That is exactly what I was going to tell you to do.
03-18-2016 12:51 PM - edited 03-18-2016 12:55 PM
Would you consider this a proper sequence of command execution?
CREATING TASK 1 CREATING ANALOG_VO Channel 1 CONFIG. TIMING FOR ANALOG_VO Channel 1 CREATING TASK 2 CREATING ANALOG_VO Channel 2 CONFIG. TIMING FOR ANALOG_VO Channel 2 WRITE VALUES TO CHANNEL 1 WRITE VALUES TO CHANNEL 2 START TASK 1 START TASK 2
DAQmxCreateTask("",byref(taskHandle1)) DAQmxCreateAOVoltageChan(taskHandle1,"DAQ/ao0","",-9.0,9.0,DAQmx_Val_Volts,None) DAQmxCfgSampClkTiming(taskHandle1,"",SAMPLING_RATE,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,SAMPLE_SIZE_WX) DAQmxCreateTask("",byref(taskHandle2)) DAQmxCreateAOVoltageChan(taskHandle2,"DAQ/ao1","",-9.0,9.0,DAQmx_Val_Volts,None) DAQmxCfgSampClkTiming(taskHandle2,"",SAMPLING_RATE,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,SAMPLE_SIZE_WX) # DAQmx Write Voltage Values DAQmxWriteAnalogF64(taskHandle1,SAMPLE_SIZE_WX,0,2.0,DAQmx_Val_GroupByScanNumber,Voltage_X,None,None) #time.sleep(5) DAQmxWriteAnalogF64(taskHandle2,SAMPLE_SIZE_WY,0,2.0,DAQmx_Val_GroupByScanNumber,Voltage_Y_Ext,None,None) #time.sleep(5) # DAQmx Start Code DAQmxStartTask(taskHandle1) DAQmxStartTask(taskHandle2)
At the execution of highlighted code (the Writing to the second channel) the following error is issued:
PyDAQmx.DAQmxFunctions.DAQError: The specified resource is reserved. The operation could not be completed as specified. Task Name: _unnamedTask<1EB>
Do I have to increase the buffer size?
03-18-2016 04:39 PM - edited 03-18-2016 04:41 PM
objective achieved: I made the following changes:
CREATING TASK 1 CREATING ANALOG_VO Channel 1 & Channel 2 in TASK 1 CONFIG. TIMING FOR TASK 1 CREATED VOLTAGE ARRAY with Pre-interleaved SAMPLES WROTE VALUES TO TASK 1 STARTED TASK 1
DAQmxCreateTask("",byref(taskHandle1))
DAQmxCreateAOVoltageChan(taskHandle1,"DAQ/ao0:ao1","",-9.0,9.0,DAQmx_Val_Volts,None)
DAQmxCfgSampClkTiming(taskHandle1,"",SAMPLING_RATE,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,2*SAMPLE_SIZE_WX)
DAQmxWriteAnalogF64(taskHandle1,2*SAMPLE_SIZE_WX,0,2.0,DAQmx_Val_GroupByScanNumber,Voltage_Interleaved,None,None)
DAQmxStartTask(taskHandle1)