コード例 #1
0
 def updateY(self):
     self.voltage = self.YSpinBox.value()
     cnt_vlt = int(
         round((self.voltage - self.minVolt) * 65535 /
               (self.maxVolt - self.minVolt)))
     daq.DacSetOutputMode(handle, daqh.DddtLocal, 2, daqh.DdomVoltage)
     daq.DacWt(handle, daqh.DddtLocal, 2, cnt_vlt)
コード例 #2
0
 def updateVt(self):
     self.voltage = self.voltageSpinBox.value()
     self.distanceSpinBox.setValue(
         self.voltage * 15)  # Assumes that piezo moves 15 um per volt.
     cnt_vlt = int(
         round((self.voltage - self.minVolt) * 65535 /
               (self.maxVolt - self.minVolt)))
     daq.DacSetOutputMode(handle, daqh.DddtLocal, 0, daqh.DdomVoltage)
     daq.DacWt(handle, daqh.DddtLocal, 0, cnt_vlt)
コード例 #3
0
    def ellipse(self):

        minVolt = -10.0
        maxVolt = 10.0
        freq = 2000  # frequency
        NS = freq * 1  # total number of seconds for entire scan
        COUNT = 32  # 32 data points per circle
        DACFREQ = freq * COUNT  # frequency at which data points are updated for DAC output
        i = np.arange(COUNT) * (
            (2 * np.pi) / 32)  # 2*pi*1second for 32 points => 2pi/32
        x = np.cos(i) * 1
        y = np.sin(i) * 1

        cnt_x = ((((x + self.XSpinBox.value() - minVolt) * 65535 /
                   (maxVolt - minVolt)))).astype(np.uint16)
        cnt_y = ((((y + self.YSpinBox.value() - minVolt) * 65535 /
                   (maxVolt - minVolt)))).astype(np.uint16)

        daq.DacSetOutputMode(handle, daqh.DddtLocal, 1, daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocal, 1, daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 1, daqh.DdcsDacClock)
        daq.DacWaveSetFreq(handle, daqh.DddtLocal, 1, DACFREQ)
        daq.DacWaveSetMode(handle, daqh.DddtLocal, 1, daqh.DdwmNShot,
                           NS * COUNT)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 1, cnt_x, COUNT,
                             daqh.DdtmUserBuffer)
        daq.DacWaveSetUserWave(handle, daqh.DddtLocal, 1)

        daq.DacSetOutputMode(handle, daqh.DddtLocal, 2, daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocal, 2, daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 2, daqh.DdcsDacClock)
        daq.DacWaveSetFreq(handle, daqh.DddtLocal, 2, DACFREQ)
        daq.DacWaveSetMode(handle, daqh.DddtLocal, 2, daqh.DdwmNShot,
                           NS * COUNT)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 2, cnt_y, COUNT,
                             daqh.DdtmUserBuffer)
        daq.DacWaveSetUserWave(handle, daqh.DddtLocal, 2)

        daq.DacWaveArm(handle, daqh.DddtLocal)
        print("Scanning in progress")
        tm.sleep(NS / freq + 0.1)
        print("Scanning complete")
        daq.DacWaveDisarm(handle, daqh.DddtLocal)
コード例 #4
0
buf0        = np.zeros((COUNT), dtype=np.uint16)
buf1        = np.zeros((COUNT), dtype=np.uint16) + 60000
buf         = (np.column_stack((buf0,buf1)))
buf_flatten = buf.flatten()

devName = daq.GetDeviceList()[0]
print "Connecting to %s\n\n" % devName  
handle = daq.Open(devName)
if handle == -1:
    print "Cannot conncet to device\n"
    print "Exit"
    sys.exit(handle)

#settings for channel 0
#Set for a static waveform
daq.DacSetOutputMode(handle, daqh.DddtLocal, 0, daqh.DdomDynamicWave);
#Immediate Trigger, (the final paramater is not yet used)
daq.DacWaveSetTrig(handle, daqh.DddtLocal, 0, daqh.DdtsImmediate, 0)
#Use the Local DAC clock
daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 0, daqh.DdcsDacClock)
#Set the frequency
daq.DacWaveSetFreq(handle, daqh.DddtLocal, 0, FREQ)  
#Repeat infinatly, the final parameter (updateCount) is ignore with infinite loop
daq.DacWaveSetMode(handle, daqh.DddtLocal, 0, daqh.DdwmInfinite, 0)	
#for an infintite loop, the buffer must cycle
daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 0, buf, COUNT, daqh.DdtmCycleOn + daqh.DdtmUpdateBlock)
#set channel 0 to be a user wave
daq.DacWaveSetUserWave(handle, daqh.DddtLocal, 0)	

#settings for channel1, see channel 0 settings for explanations
daq.DacSetOutputMode(handle, daqh.DddtLocal, 1, daqh.DdomDynamicWave)
コード例 #5
0
minVolt = -10.0

buf0    = np.zeros((COUNT,), dtype=np.uint16)
buf1    = np.zeros((COUNT,), dtype=np.uint16)

devName = daq.GetDeviceList()[0]
print "Connecting to %s\n\n" % devName  
handle = daq.Open(devName)
if handle == -1:
    print "Cannot conncet to device\n"
    print "Exit"
    sys.exit(handle)

#both channels must have the following same settings
chan = chans[0]
daq.DacSetOutputMode(handle, daqh.DddtLocal, chan, daqh.DdomStaticWave)
daq.DacWaveSetTrig(handle, daqh.DddtLocal, chan, daqh.DdtsImmediate, 1)
daq.DacWaveSetClockSource(handle, daqh.DddtLocal, chan, daqh.DdcsDacClock)
daq.DacWaveSetFreq(handle, daqh.DddtLocal, chan, FREQ*COUNT)  #output freq = clock freq/buffersize
daq.DacWaveSetMode(handle, daqh.DddtLocal, chan, daqh.DdwmInfinite, 0)
chan = chans[1]
daq.DacSetOutputMode(handle, daqh.DddtLocal, chan, daqh.DdomStaticWave)
daq.DacWaveSetTrig(handle, daqh.DddtLocal, chan, daqh.DdtsImmediate, 1)
daq.DacWaveSetClockSource(handle, daqh.DddtLocal, chan, daqh.DdcsDacClock)
daq.DacWaveSetFreq(handle, daqh.DddtLocal, chan, FREQ*COUNT)  #output freq = clock freq/buffersize
daq.DacWaveSetMode(handle, daqh.DddtLocal, chan, daqh.DdwmInfinite, 0)


#waveform settings
AMP0_DWORD = int(round(65535 * AMP0/(maxVolt-minVolt) ))
AMP1_DWORD = int(round(65535 * AMP1/(maxVolt-minVolt) ))
コード例 #6
0
#DAC takes range of values from 0 for the Daq's minumum output to
#65535 for the Daq's maximum output

#The following routine automatically determines the max and min voltage for
#the device used

maxVolt = 10.0
minVolt = -10.0

#set output settings
cnt_vlt = [
    int(round((vlt - minVolt) * 65535 / (maxVolt - minVolt)))
    for vlt in flt_vlt
]
#set output mode of channel 1 and 2
daq.DacSetOutputMode(handle, daqh.DddtLocal, chans[0], daqh.DdomVoltage)
daq.DacSetOutputMode(handle, daqh.DddtLocal, chans[1], daqh.DdomVoltage)

#start output
daq.DacWtMany(handle, [daqh.DddtLocal, daqh.DddtLocal], chans, cnt_vlt)

print "Outputting %2.2f on chan 0 and %2.2f on chan 1\n" % (OUT_ONE, OUT_TWO)
print "Press any key to turn off DC output"

raw_input("Press Enter to continue...")

cnt_vlt = [
    int(round((vlt - minVolt) * 65535 / (maxVolt - minVolt)))
    for vlt in [0, 0]
]
daq.DacWtMany(handle, [daqh.DddtLocal, daqh.DddtLocal], chans, cnt_vlt)
コード例 #7
0
    def raster(self):
        minVolt = -10.0
        maxVolt = 10.0
        freq = 1
        COUNT = 68 * 62
        FREQ = freq * COUNT
        x = []
        y = []
        NS = freq * 1
        i = 0
        while i < 62:
            j = 0
            while j < 62:
                x.append(j)
                y.append(i)
                j += 1
            j = 61
            if i is not 61:
                while j >= 10:
                    j -= 10
                    x.append(j)
                    y.append(i)
            if i is 61:  # The scan now has 62+6 points in each line and when it reaches the last line, it uses the same 6 points to go to beginning point
                while j >= 10:  # For the actual data that we are interested, we have to ignore 6 points after every 62 points
                    j -= 10
                    i -= 10
                    x.append(j)
                    y.append(i)
                i = 61
            i += 1

        cnt_x = ((((np.array(x) * 0.01 - minVolt) * 65535 /
                   (maxVolt - minVolt)))).astype(np.uint16)
        cnt_y = ((((np.array(y) * 0.01 - minVolt) * 65535 /
                   (maxVolt - minVolt)))).astype(np.uint16)

        daq.DacSetOutputMode(handle, daqh.DddtLocal, 1, daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocal, 1, daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 1, daqh.DdcsAdcClock)
        daq.DacWaveSetFreq(handle, daqh.DddtLocal, 1, FREQ)
        daq.DacWaveSetMode(handle, daqh.DddtLocal, 1, daqh.DdwmNShot,
                           NS * COUNT)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 1, cnt_x, COUNT,
                             daqh.DdtmUserBuffer)
        daq.DacWaveSetUserWave(handle, daqh.DddtLocal, 1)

        daq.DacSetOutputMode(handle, daqh.DddtLocal, 2, daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocal, 2, daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 2, daqh.DdcsAdcClock)
        daq.DacWaveSetFreq(handle, daqh.DddtLocal, 2, FREQ)
        daq.DacWaveSetMode(handle, daqh.DddtLocal, 2, daqh.DdwmNShot,
                           NS * COUNT)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 2, cnt_y, COUNT,
                             daqh.DdtmUserBuffer)
        daq.DacWaveSetUserWave(handle, daqh.DddtLocal, 2)

        self.rasterbuffer = np.ones(NS * COUNT, dtype=np.uint16)

        channels = [0]
        gains = [daqh.DgainDbd3kX1]
        flags = [daqh.DafCtr16]
        daq.AdcSetAcq(handle, daqh.DaamNShot, 0, NS * COUNT)
        daq.AdcSetScan(handle, channels, gains, flags)
        daq.AdcSetFreq(handle, FREQ)
        daq.SetOption(
            handle, 0, daqh.DcofChannel, daqh.DcotCounterEnhMeasurementMode,
            daqh.DcovCounterEnhMode_Counter +
            daqh.DcovCounterEnhCounter_ClearOnRead)
        daq.AdcTransferSetBuffer(handle, self.rasterbuffer, NS * COUNT, 1,
                                 daqh.DatmUpdateSingle + daqh.DatmCycleOff)
        daq.SetTriggerEvent(handle, daqh.DatsExternalTTL, daqh.DetsRisingEdge,
                            0, daqh.DgainDbd3kX1, daqh.DafCtr16,
                            daqh.DaqTypeCounterLocal, 0, 0, daqh.DaqStartEvent)
        daq.SetTriggerEvent(handle, daqh.DatsScanCount, daqh.DetsRisingEdge, 0,
                            daqh.DgainDbd3kX1, daqh.DafCtr16,
                            daqh.DaqTypeCounterLocal, 0, 0, daqh.DaqStopEvent)

        daq.AdcTransferStart(handle)
        daq.AdcArm(handle)
        print "waiting for Scan trigger...\n"
        daq.DacWaveArm(handle, daqh.DddtLocal)

        tm.sleep(1)
        handle1.Ctrig()

        print("Scanning...\n")

        active, retCount = daq.DacTransferGetStat(handle, daqh.DddtLocal, 1)
        while active & daqh.DdafTransferActive:
            active, retCount = daq.DacTransferGetStat(handle, daqh.DddtLocal,
                                                      1)
            #print(active, retCount)
        tm.sleep(
            0.1
        )  # Sometimes Data Acquisition isn't finished yet even though the DAC output is complete. Don't know why??? (Update frequencies and # of data points are the same)
        daq.AdcDisarm(handle)
        daq.DacWaveDisarm(handle, daqh.DddtLocal)

        print(self.rasterbuffer, len(self.rasterbuffer))
        imagedata = np.zeros((62, 62))
        i = j = k = 0
        while k < len(self.rasterbuffer):
            imagedata[j, i] = self.rasterbuffer[k]
            i += 1
            if i % 62 is 0:
                k += 6
                j += 1
                i = 0
            k += 1
        print(imagedata)

        plt.clf()
        plt.imshow(imagedata, cmap=cm.Greys_r)
        plt.show()
コード例 #8
0
    def run(self):

        if self.i is 0:  # Check to see if the zscan is setup at least once.
            print("You need to setup the program first. Starting setup.. \n")
            self.setup()
            self.i = 1
            print("Starting the process now.. \n")

        if self.V0 is not form.voltage:  # Check to see if the focus has changed
            self.V0 = form.voltage  # Change the mid-ramp settings caused by change in focus
            self.Vtadjust = self.V0 - self.Vtmid  # facilitates the mid-ramp to start at the focus point set by piezo
            self.Vt = np.concatenate([
                self.Vtup[self.l:] + self.Vtadjust,
                self.Vtdown + self.Vtadjust, self.Vtup[:self.l] + self.Vtadjust
            ])
            self.Vt = np.tile(self.Vt, self.N)
            self.DACwave = np.around(self.Vt / self.dV_DAC +
                                     self.resolution_half).astype('uint16')

        # initialize DAC output
        # ch0 = V(t)
        daq.DacSetOutputMode(handle, daqh.DddtLocal, 0, daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocal, 0, daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(
            handle, daqh.DddtLocal, 0,
            daqh.DdcsAdcClock)  #slave DAC to ADC clock (synchronous mode)
        daq.DacWaveSetFreq(
            handle, daqh.DddtLocal, 0, self.FREQ
        )  #set to same frequency as ADC (not sure if this step is necessary)
        daq.DacWaveSetMode(handle, daqh.DddtLocal, 0, daqh.DdwmInfinite, 0)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocal, 0, self.DACwave,
                             self.COUNT, daqh.DdtmUserBuffer)
        # ch1 = SYNC(t)
        daq.DacSetOutputMode(handle, daqh.DddtLocalDigital, 0,
                             daqh.DdomStaticWave)
        daq.DacWaveSetTrig(handle, daqh.DddtLocalDigital, 0,
                           daqh.DdtsImmediate, 0)
        daq.DacWaveSetClockSource(handle, daqh.DddtLocalDigital, 0,
                                  daqh.DdcsAdcClock)
        daq.DacWaveSetFreq(handle, daqh.DddtLocalDigital, 0, self.FREQ)
        daq.DacWaveSetMode(handle, daqh.DddtLocalDigital, 0, daqh.DdwmInfinite,
                           0)
        daq.DacWaveSetBuffer(handle, daqh.DddtLocalDigital, 0, self.bufSYNC,
                             self.COUNT, daqh.DdtmUserBuffer)

        # begin data acquisition
        daq.AdcTransferStart(handle)
        daq.AdcArm(handle)
        print "waiting for Scan trigger...\n"
        daq.DacWaveArm(
            handle, daqh.DddtLocal
        )  #need to arm ADC before DAC to ensure that both wait for hardware trigger

        tm.sleep(1)

        self.win = pg.GraphicsWindow()
        self.win.setWindowTitle('Photon Counts')

        self.p1 = self.win.addPlot()
        self.p1.setLabel('bottom', 'Time', 's')
        self.curve1 = self.p1.plot()
        self.win.nextRow()
        self.p2 = self.win.addPlot()
        self.p2.setLabel('bottom', 'Voltage', 'V')
        self.curve2 = self.p2.plot()
        self.curvetime = np.arange(self.SCANS) * (
            self.T * self.N / self.SCANS
        )  # Used to plot real time data with x-axis as time in seconds

        self.timer = pg.QtCore.QTimer()
        self.timer.setInterval(self.T)  # T milliseconds
        self.timer.timeout.connect(self.update)

        handle1.Ctrig()
        print("Scanning...\n")

        self.timer.start()