Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Two channel scan using single task Daqmx with multiple output signals

Hello, 

 

I am using NI-USB-6211 DAQ to control the X-Y Galvanometers and I want to input multiple angle signals. The code only move to one position and stop. I am not sure if this is the problem with my code and are there any ways to check the problems? Thanks. 

 

import numpy as np
from PyDAQmx import *
import PyDAQmx

class Galvo:

def __init__(self):

print("initialized Galvo")

# State variables
self.x_mirror_volt = [0.0] # Initialize to origin
self.y_mirror_volt = [0.0]
self.writeFrequency = 120000.

# Initialize the Galvo setting
self.Galvo_MoveTask = Task()
self.Galvo_MoveTask.CreateAOVoltageChan("Dev1/ao0", "X_Out", -10., 10., DAQmx_Val_Volts, None)
self.Galvo_MoveTask.CreateAOVoltageChan("Dev1/ao1", "Y_Out", -10., 10., DAQmx_Val_Volts, None)
data_init = np.array(np.append(self.x_mirror_volt, self.y_mirror_volt), dtype = np.float64) # Initial the data with the (0.0, 0.0) pulses
self.Galvo_MoveTask.WriteAnalogF64(1, 1, -1, DAQmx_Val_GroupByChannel, data_init, None, None)

def raster_region(self, x_volt, y_volt):

# taskHandle.WriteAnalogF64(number of samples per channel, automatically start task,
# seconds before timeout (-1 means don't timeout), grouping of samples
# (by channel or by scan), data array, array size,
# number of samples actually read, None)
data = np.array(np.append(x_volt, y_volt), dtype = float64)

self.Galvo_MoveTask.CfgSampClkTiming(None, self.writeFrequency, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, np.size(x_volt))
self.Galvo_MoveTask.WriteAnalogF64(np.size(x_volt), 1, 10, DAQmx_Val_GroupByChannel, data, None, None)
self.Galvo_MoveTask.WaitUntilTaskDone(-1)
self.Galvo_MoveTask.StopTask()
self.Galvo_MoveTask.ClearTask()

if __name__ == "__main__":

test = Galvo()

x_volt = [0.5, 1.0, 1.5]
y_volt = [1.5, 0.5, 1.5]
print(x_volt)
print(y_volt)
test.raster_region(x_volt, y_volt)

 

0 Kudos
Message 1 of 1
(1,605 Views)