예제 #1
0
 def initCtTask():
     self.ct_task = nicontrol.CounterOutput(
         self.counter_board, self.counter_id, frequency, 0.5)
     self.ct_task.setCounter(oversampling)
     self.ct_task.setTrigger(self.counter_trigger)
     print self.ct_task.verifyTask()
     return self.ct_task
예제 #2
0
            def startCtTask():
                try:
                    self.ct_task = nicontrol.CounterOutput(
                        self.counter_board, self.counter_id, frequency, 0.5)
                    self.ct_task.setCounter(oversampling)
                    self.ct_task.setTrigger(self.counter_trigger)
                    self.ct_task.startTask()
                except nicontrol.NIException:
                    return True

                return False
예제 #3
0
 def on(self, power):
     duty_cycle = float(power)*0.01
     if (duty_cycle < 0.0):
         duty_cycle = 0.0
     if (duty_cycle > 1.0):
         duty_cycle = 1.0
     self.ct_task = nicontrol.CounterOutput(self.board,
                                            self.line,
                                            self.frequency,
                                            duty_cycle)
     self.ct_task.setCounter(-1)
     self.ct_task.startTask()
     self.am_on = True
예제 #4
0
    def startFilm(self, seconds_per_frame, oversampling):
        illuminationHardware.DaqModulation.startFilm(self, seconds_per_frame, oversampling)

        # Calculate frequency. This is set slightly higher than the camere
        # frequency so that we are ready at the start of the next frame.
        frequency = (1.01 / seconds_per_frame) * float(oversampling)

        # Setup analog waveforms.
        if (len(self.analog_data) > 0):

            # Sort by board, channel.
            analog_data = sorted(self.analog_data, key = lambda x: (x[0], x[1]))

            # Set waveforms.
            waveform = []
            for i in range(len(analog_data)):
                waveform += analog_data[i][2]

            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)

            iters = 0
            while (iters < 5) and (not initAoTask()):
                hdebug.logText("initAoTask failed " + str(iters))
                self.ao_task.clearTask()
                time.sleep(0.1)
                iters += 1

        else:
            self.ao_task = False

        # Setup digital waveforms.
        if (len(self.digital_data) > 0):

            # Sort by board, channel.
            digital_data = sorted(self.digital_data, key = lambda x: (x[0], x[1]))

            # Set waveforms.
            waveform = []
            for i in range(len(digital_data)):
                waveform += digital_data[i][2]

            def initDoTask():

                # Create channels.
                self.do_task = nicontrol.DigitalWaveformOutput(digital_data[0][0], digital_data[0][1])
                for i in range(len(digital_data) - 1):
                    self.do_task.addChannel(digital_data[i+1][0], digital_data[i+1][1])

                # Add waveform
                return self.do_task.setWaveform(waveform, frequency, clock = self.waveform_clock)

            iters = 0
            while (iters < 5) and (not initDoTask()):
                hdebug.logText("initDoTask failed " + str(iters))
                self.do_task.clearTask()
                time.sleep(0.1)
                iters += 1

        else:
            self.do_task = False

        # Setup the counter.
        if self.counter_board:
            self.ct_task = nicontrol.CounterOutput(self.counter_board, 
                                                   self.counter_id,
                                                   frequency, 
                                                   0.5)
            self.ct_task.setCounter(oversampling)
            self.ct_task.setTrigger(self.counter_trigger)
        else:
            self.ct_task = False

        # Start tasks
        for task in [self.ct_task, self.ao_task, self.do_task]:
            if task:
                task.startTask()
예제 #5
0
    #
    def off(self):
        if self.am_on:
            self.dev.stopPWM()
            self.am_on = False


if __name__ == "__main__":
    if 0:
        ldc = LDC210("PCI-6733", 7)
        ldc.on()
        time.sleep(1)
        ldc.off()

    if 0:
        ct_task = nicontrol.CounterOutput("PCI-6733", 0, 100, 0.5)
        ct_task.setCounter(100)
        ct_task.setTrigger(0)
        ct_task.startTask()
        ldc = LDC210PWMNI("PCI-6733", 1)
        ldc.on(7)
        time.sleep(5)
        ldc.off()
        ct_task.stopTask()
        ct_task.clearTask()

    if 1:
        ldc = LDC210PWMLJ()
        ldc.on(10)
        time.sleep(5)
        ldc.off()