def reference_pulse(f_ext='', voltRange=0.2):
    ''' Spin polarize the crystal and send a pulse through at the freq where the AFC
    would be. Needs to know the number of teeth to know which bit of memory the pulse is stored at.'''

    mc.setWvfmKey('Pulse')
    AWG_trig_out(1)

    #Set picoscope up to collect data and wait for external trigger
    t_s = 4 * ns
    r_l = 20 * us
    t_sample, res = pico.run_rapid_block(ps,
                                         Vrange=voltRange,
                                         n_captures=1,
                                         t_sample=t_s,
                                         record_length=r_l)
    n_data = r_l / t_s

    print("Toggling MEMS switch high for 10 s")
    pb.Sequence(
        [
            (['ch5'], 0.5 * us),
            (['ch5', 'ch6'], 10),  #Spin polarise crystal
            (['ch5'], 0.5 * us, WAIT),
            (['ch5'], 49.5 * us),
            (['ch3', 'ch5'], 0.5 * us),
            (['ch1', 'ch5'], 50 * us),
            (['ch5'], 1 * ms)
        ],
        loop=False,
        bStart=False)
    sleep(11)

    #Old Sequence
    ##     pb.Sequence([(['ch5'], 0.5*us), (['ch5'], 0.5*us, WAIT), (['ch5'], 49.5*us),
    ##     (['ch3','ch5'], 0.5*us), (['ch1','ch5'],1*ms), (['ch5'], 1*ms)] ,loop=False,bStart=False)
    #CH3 to picoscope (start recording just before pulse arrives),
    #CH1 to open RF switch for AWG,
    #CH5 so carrier sideband beat on laser is strong
    sleep(0.1)
    #AWG_trig_out(0)

    #sleep(1)
    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    ##     for dat in data_total[0]:
    ##         if dat == "inf" or dat == "-inf":
    ##             raise RuntimeError, "Picoscope V range too small"

    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d REFERNCE Pico " + f_ext + '.mat')

    sci.savemat(file_name, {
        'Vrange': voltRange,
        'sampleRate': t_s,
        'data': data_total
    })
Exemple #2
0
def test_pico():
    ''' Testing the picoscope runblock code. Plug CH7 into the picoscope'''

    shots = 5
    f_ext = 'TestRunIgnore'

    t_s = 10 * us
    r_l = 10 * ms
    ps, t_sample, res = pico.run_rapid_block(Vrange=5,
                                             n_captures=shots,
                                             t_sample=t_s,
                                             record_length=r_l)
    n_data = r_l / t_s

    for i in range(shots):
        storage_arr = [(['ch3', 'ch5'], 25 * us),
                       (['ch1', 'ch5', 'ch7'], 500 * us), (['ch5'], 1 * ms)]
        pb.Sequence(storage_arr, loop=False)

    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d Pico " + f_ext + '.mat')

    sci.savemat(file_name, {'data': data_total})
    plt.plot(t, data[0, :])
    plt.show()
    ps.close()
Exemple #3
0
def make_AFC(n, bjt, burn_f, hyperfine, f_ext='', record="False", shots=1):
    '''
    Runs functions to make AFC and store / read out pulse
    n = number of teeth in comb
    bjt = burn jump time, time spent burning at each hyperfine (usually 500ms)
    hyperfine = hyperfine level to spin to (-7,2 for AFC)
    f_ext = end of each file name for data recording
    '''

    #Prepare instruments pre-storage.
    #Write to the wf the freq and power needed,
    wf_24_cw(burn_f + 10e6 + 460.99e6, -10)  #Freq offset from the pulses freq.

    #Spin pol crystal and record a refence pulse (through the non-existant AFC)
    spin_pump_seq(spintime=10 * s, SpecAnSweep='N', rec='Y')
    ##     reference_pulse(f_ext)

    ##     if record == "True":
    ##         save_offset_custom(SpecAn, 5, "1.txt",freq = burn_f + 1443*MHz, span = 40*MHz, res = 30*kHz, sweep = 50*ms)
    ##
    ##     #Make the AFC and record AFC at dm = 1 and 0. Also record initial comb holes
    ##     spin_jump(burn_f,state = hyperfine,rec = record, span = 20*MHz, teeth = n)

    ##     if record == "True":
    ##         record_dm_1(burn_f, hyperfine, tn=n)

    ##     save_offset_custom(SpecAn, 5, "1.txt",freq = burn_f + 1443*MHz, span = 40*MHz)
    ##     spin_jump(burn_f,state = hyperfine ,rec = 'True', span = 20*MHz, teeth = teeth, f_ext = file_suff, bjt = 500)
    ##     record_dm_1(burn_f, hyperfine + ' ' + file_suff, tn = teeth)

    #Set AWG to output storage pulse
    mc.setWvfmKey('Pulse')
    AWG_trig_out(1)

    #Set picoscope up to collect data and wait for external trigger
    t_s = 4 * ns
    r_l = 50 * us
    t_sample, res = pico.run_rapid_block(ps,
                                         Vrange=0.5,
                                         n_captures=shots,
                                         t_sample=t_s,
                                         record_length=r_l)
    n_data = r_l / t_s
    sleep(0.1)

    #CH3 trigger picoscope.
    #CH5 suppress carrier EOM.
    #CH1 Open RF switch for AWG.
    for i in range(shots):
        #1ms allows for a time gap between each shot
        pb.Sequence([(['ch5'], 0.5 * us), (['ch5'], 0.5 * us, WAIT),
                     (['ch5'], 49.5 * us), (['ch3', 'ch5'], 0.5 * us),
                     (['ch1', 'ch5'], 50 * us), (['ch5'], 1 * ms)],
                    loop=False,
                    bStart=False)

    sleep(0.1)

    #Get data from picoscope
    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    AWG_trig_out(0)
    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d Pico " + f_ext + '.mat')

    sci.savemat(file_name, {'data': data_total})
    plt.plot(t, data[0, :])
    plt.show()
Exemple #4
0
def photonicsSweepPicoRecord(f,
                             p,
                             sweep,
                             fOffsRecordLength=12,
                             fName='',
                             showDataPlot=False,
                             openP=False):
    if 'ps' not in globals():
        global ps
        ps = pico.open_pico()

    if openP:
        ps = pico.open_pico()

    tDiff = 0
    tArr = np.empty(0)
    offsArr = np.empty(0)

    ITLA = photonicsControl(f, p, sweep)
    time.sleep(0.1)

    print('Setting up picoscope collection')
    t_s = 100e-6
    # =============================================================================
    #     r_l = 10 #~100,000 data points
    # =============================================================================
    r_l = 100  #1,000,000 data points
    # =============================================================================
    #     r_l = 20 #200,000 data points
    # =============================================================================
    chB = [True, 20]
    t_sample, res = pico.run_rapid_block(ps,
                                         Vrange=5,
                                         n_captures=1,
                                         t_sample=t_s,
                                         record_length=r_l,
                                         chB=chB)

    time.sleep(0.1)

    tStart = time.time()
    pb.Sequence([(['ch3', 'ch5', 'ch2'], 0.01), (['ch5', 'ch2'], 0.01)],
                loop=False)  #Trigger PB

    while tDiff < fOffsRecordLength:
        offsArr = np.append(offsArr, ITLA.ReadOffsetFreq())
        tDiff = time.time() - tStart
        tArr = np.append(tArr, tDiff)

        time.sleep(0.01)

    data = np.vstack([tArr, offsArr]).T

    print('Formatting and saving data')
    dataPicoA, dataPicoB = pico.get_data_from_rapid_block(ps)
    t = np.arange(dataPicoA.shape[0]) * t_s
    data_total = np.vstack([t, dataPicoA, dataPicoB])
    data_total = data_total.T

    date = time.strftime('%y-%m-%d')
    #Save laser freq offset and pico data
    filenameMat = "C:\Users\Milos\Desktop\James\\" + date + ' ' + fName + '.mat'
    sio.savemat(
        filenameMat, {
            'Time': tStart,
            'CenterF': f,
            'Sweep': sweep[2],
            'SweepRate': sweep[1],
            'DataSweep': data,
            'DataPico': data_total
        })

    if showDataPlot:
        plt.plot(data.T[1])
        plt.show()

    photonicsOff(ITLA)

    return data, ps
Exemple #5
0
def AFC_storage_n_readout(n,
                          bjt,
                          burn_f,
                          f_ext='',
                          record_dm1="False",
                          shots=1):
    '''
    Creates the AFC and records a number of echo shots

    n = number of teeth in comb
    bjt = burn jump time, time spent burning at each hyperfine (usually 500ms)
    burn_f = lcation of the dm -1 7/2 ~1GHz
    record_dm1 = records the AFC on the delta m = +1 transition.
    f_ext = end of each file name for data recording
    '''

    ###########################################################################
    #THIS STILL NEEDS TO BE SET UP FOR PB TRIGGERING (most of it is done)
    ###########################################################################

    hyperfine = '-7,2'  #hyperfine level we're spin jumping to

    #Spin pol crystal and record background at the dm = 1 (before spin jumping)
    spin_pump_seq(spintime=10 * s, SpecAnSweep='N', rec='Y')
    if record_dm1 == "True":
        save_offset_custom(SpecAn,
                           5,
                           "1.txt",
                           freq=burn_f + 1443 * MHz,
                           span=40 * MHz,
                           res=30 * kHz,
                           sweep=50 * ms)

    #Prepare instruments pre-storage.
    #Write to the wf the freq and power needed,


##     wf_13_cw(burn_f/1e6 + 10, -10)#Freq in MHz offset from the pulses freq.
    wf_24_cw(burn_f + 10e6, -10)  #Freq offset from the pulses freq.

    #Set picoscope up to collect data and wait for external trigger
    ######################################################################################
    t_s = 4 * ns
    r_l = 1 * ms
    ps, t_sample, res = pico.run_rapid_block(Vrange=5,
                                             n_captures=shots,
                                             t_sample=t_s,
                                             record_length=r_l)
    n_data = r_l / t_s
    ######################################################################################

    #Make the AFC and record AFC at dm = 1 and 0. Also record initial comb holes
    spin_jump(burn_f, state=hyperfine, rec=record_dm1, span=10 * MHz, teeth=n)

    if record_dm1 == "True":
        record_dm_1(burn_f, hyperfine)

    #Set AWG to output storage pulse
    j = 5  #n*(j+2) is the waveform for the jth hyperfine (5 = -7/2)
    mc.setWvfm(n * (j + 2) +
               1)  #so this + 1 is the waveform just after the comb creation

    #CH3 trigger picoscope.
    #CH5 suppress carrier EOM.
    #CH1 Open RF switch for AWG.
    for i in range(shots):
        storage_arr = [(['ch3', 'ch5'], 1 * us, WAIT), (['ch1',
                                                         'ch5'], 10 * us),
                       (['ch5'], 1 * ms)]
        #        storage_arr = [(['ch3','ch5'], 1*ms),(['ch7','ch5'], 1*ms),(['ch5'], 9*ms)]
        pb.Sequence(storage_arr, loop=False)

    #Get data from picoscope
    data = pico.get_data_from_rapid_block(ps)
    t = np.arange(data.shape[1]) * t_s
    data_total = np.vstack([t, data])
    data_total = data_total.T

    #Save formatted data.
    file_name = time.strftime("C:\Users\Milos\Desktop\James\\" +
                              "%Y-%m-%d Pico " + f_ext + '.mat')

    sci.savemat(file_name, {'data': data_total})
    plt.plot(t, data[0, :])
    plt.show()
    ps.close()