projects/test_marble_family/scan_vcxo.py
def measure_1(chip, v, dac=2, pause=1.1, repeat=1, gps=False, verbose=False):
    '''
    v should be between 0 and 65535
    freq_count gateware module configured to update every 1.0737 s
    '''
    prefix_map = {1: 0x10000, 2: 0x20000}
    if dac in prefix_map:
        v |= prefix_map[dac]
    else:
        print("Invalid DAC choice")
        exit(1)
    if gps:
        pause = 0.3 * pause
    chip.exchange([327692, 327689], [0, v])  # pps_config, wr_dac
    ppm = []
    oldn = None
    while len(ppm) < repeat:
        time.sleep(pause)
        if gps:
            raw = chip.exchange([13])
            n = (raw >> 28) & 0xf
            ovf = (raw >> 27) & 0x1
            count = raw & 0x7ffffff
            ok = oldn is not None and n == ((oldn + 1) & 0xf) and not ovf
            if verbose and oldn is not None:
                print("chk %x %x %d %9d %s" % (
                    oldn, n, ovf, count, "OK" if ok else ".")
                )
            if ok:
                x = (float(count) / 125000000.0 - 1.0) * 1e6
                ppm += [x]
            oldn = n
        else:
            raw = chip.exchange([5])
            ppm += [(float(raw) / 2**27 - 1.0) * 1e6]
    return ppm

    v should be between 0 and 65535
    freq_count gateware module configured to update every 1.0737 s
    
v should be between 0 and 65535
freq_count gateware module configured to update every 1.0737 s
v should be between 0 and 65535 freq_count gateware module configured to update every 1 . 0737 s
def measure_1(chip, v, dac=2, pause=1.1, repeat=1, gps=False, verbose=False):
    prefix_map = {1: 0x10000, 2: 0x20000}
    if dac in prefix_map:
        v |= prefix_map[dac]
    else:
        print("Invalid DAC choice")
        exit(1)
    if gps:
        pause = 0.3 * pause
    chip.exchange([327692, 327689], [0, v])  
    ppm = []
    oldn = None
    while len(ppm) < repeat:
        time.sleep(pause)
        if gps:
            raw = chip.exchange([13])
            n = (raw >> 28) & 0xf
            ovf = (raw >> 27) & 0x1
            count = raw & 0x7ffffff
            ok = oldn is not None and n == ((oldn + 1) & 0xf) and not ovf
            if verbose and oldn is not None:
                print("chk %x %x %d %9d %s" % (
                    oldn, n, ovf, count, "OK" if ok else ".")
                )
            if ok:
                x = (float(count) / 125000000.0 - 1.0) * 1e6
                ppm += [x]
            oldn = n
        else:
            raw = chip.exchange([5])
            ppm += [(float(raw) / 2**27 - 1.0) * 1e6]
    return ppm
def measure_1 ( chip , v , dac = 2 , pause = 1.1 , repeat = 1 , gps = False , verbose = False ) : prefix_map = { 1 : 0x10000 , 2 : 0x20000 } if dac in prefix_map : v |= prefix_map [ dac ] else : print ( "Invalid DAC choice" ) exit ( 1 ) if gps : pause = 0.3 * pause chip . exchange ( [ 327692 , 327689 ] , [ 0 , v ] ) ppm = [ ] oldn = None while len ( ppm ) < repeat : time . sleep ( pause ) if gps : raw = chip . exchange ( [ 13 ] ) n = ( raw >> 28 ) & 0xf ovf = ( raw >> 27 ) & 0x1 count = raw & 0x7ffffff ok = oldn is not None and n == ( ( oldn + 1 ) & 0xf ) and not ovf if verbose and oldn is not None : print ( "chk %x %x %d %9d %s" % ( oldn , n , ovf , count , "OK" if ok else "." ) ) if ok : x = ( float ( count ) / 125000000.0 - 1.0 ) * 1e6 ppm += [ x ] oldn = n else : raw = chip . exchange ( [ 5 ] ) ppm += [ ( float ( raw ) / 2 ** 27 - 1.0 ) * 1e6 ] return ppm
v should be between 0 and 65535
freq_count gateware module configured to update every 1.0737 s
v should be between 0 and 65535 freq_count gateware module configured to update every 1 . 0737 s
'''
    v should be between 0 and 65535
    freq_count gateware module configured to update every 1.0737 s
    ''' # pps_config, wr_dac
chip
v
dac
pause
repeat
gps
verbose