Пример #1
0
    def startTask(self):
        # Create NI analog tasks
        self.ni_task = nicontrol.AnalogWaveformOutput("USB-6002", 0)
        self.ni_task.addChannel("USB-6002", 1)

        # Identify the longest period and use as the length of the buffer: NOTE: the higher frequency must be a multiple of the lowest
        duration = max(1 / self.x_freq, 1 / self.y_freq)
        time = np.arange(0, duration, 1 / self.sampleRate)

        # Create waveforms
        wave_x = self.x_offset + self.x_amp * np.sin(
            2 * np.pi * self.x_freq * time)
        wave_y = self.y_offset + self.y_amp * np.sin(
            2 * np.pi * self.y_freq * time)
        self.waveform = self.coerceToRange(np.concatenate((wave_x, wave_y)))

        # Send waveform to ni card
        self.ni_task.setWaveform(self.waveform,
                                 self.sampleRate,
                                 clock="ctr0out")

        # Start task
        self.ni_task.startTask()

        self.running = True
Пример #2
0
                def initAoTask():

                    # Create channels.
                    self.ao_task = nicontrol.AnalogWaveformOutput(analog_data[0][0], analog_data[0][1])
                    for i in range(len(analog_data) - 1):
                        self.ao_task.addChannel(analog_data[i+1][0], analog_data[i+1][1])

                    # Add waveform
                    return self.ao_task.setWaveform(waveform, frequency, clock = self.waveform_clock)
Пример #3
0
    def startHardwareTimedMove(self, z_positions):
        # Clean up the previous task
        self.ni_task.stopTask()
        self.ni_task.clearTask()

        # Create hardware timed task
        self.ni_task = nicontrol.AnalogWaveformOutput(self.board, self.line)

        # Set waveform
        voltages = z_positions * self.scale

        # Convert to a list of channel values and write
        self.ni_task.setWaveform(voltages, 100, clock=self.trigger_source)
        # NOTE: the frequency is hardcoded to a maximum allowed value (arbitrary)

        self.ni_task.startTask()
Пример #4
0
            def startAoTask():
                
                try:
                    # Create channels.
                    self.ao_task = nicontrol.AnalogWaveformOutput(analog_data[0][0], analog_data[0][1])
                    for i in range(len(analog_data) - 1):
                        self.ao_task.addChannel(analog_data[i+1][0], analog_data[i+1][1])

                    # Add waveform
                    self.ao_task.setWaveform(waveform, frequency, clock = wv_clock)

                    # Start task.
                    self.ao_task.startTask()
                except nicontrol.NIException:
                    return True
                    
                return False