Multifunction DAQ

取消
显示结果 
搜索替代 
您的意思是: 

Interleave samples: Two analog output (arrays with different lengths)

已解决!
转到解答
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

0 项奖励
1 条消息(共 5 条)
4,611 次查看

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

0 项奖励
2 条消息(共 5 条)
4,593 次查看

@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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 项奖励
3 条消息(共 5 条)
4,573 次查看

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? 

 

 

0 项奖励
4 条消息(共 5 条)
4,555 次查看
解答
已被主题作者 Ravi_S 接受

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)

 

0 项奖励
5 条消息(共 5 条)
4,546 次查看