def serialComGWGDS1072AUgetTimeScale(obj):
    obj.flushInput() # FLUSHES THE INPUT
    obj.writelines(':TIMebase:SCALe?\n') #QUERRY THE GDS FOR THE SCALE
    serialComWaitForData(obj) #WAITS FOR A REPLY FROM THE GDS
    scale=obj.readline().rstrip() #READ THE QUERRY AND STRIPS TRAILING NEWLINE
    #print(scale)
    return scale
Beispiel #2
0
def serialComGWGDS1072AUgetPotOffset(obj, ch):
    obj.flushInput()  # FLUSHES THE INPUT
    obj.writelines(':CHANNEL' + str(ch) +
                   ':OFFset?\n')  #QUERRY THE GDS FOR THE OFFSET
    serialComWaitForData(obj)  #WAITS FOR A REPLY FROM THE GDS
    offset = obj.readline().rstrip(
    )  #READ THE QUERRY AND STRIPS TRAILING NEWLINE
    #print(scale)
    return offset
def serialComWaitForGWGDS1072AcqStatus(obj, ch, maxIter=1000):
    it = 0  #INITIALIZES ITERATOR TO 0
    obj.flushInput()  #FLUSHES THE INPUT OF THE PORT
    while True:
        obj.writelines(':ACQ' + str(ch) +
                       ':STAT?\n')  #QUERRY ACQUISTION STATUS CHANNEL 2
        serialComWaitForData(obj)  #WAITS FOR DATA
        stat = obj.read()  #READ DATA
        it += 1
        if (stat and stat[0] == '1' or it > maxIter):
            print('READY STATUS!')
            break  #STOP WAITING FOR ACQUISITION STATUS
def serialComIsDeviceGWGDS1072AU(obj):

    closePort=False
    
    if not obj.is_open:
        obj.open() #OPENS THE SERIAL PORTS IF CLOSED
        closePort=True #DECISION BASIS CLOSE PORT BEFORE RETURN
    
    obj.flushInput() #FLUSHES THE INPUT BUFFER
    obj.writelines('*IDN?\n')   #QUERRY THE PORT/DEVICE FOR ID NUMBER
    serialComWaitForData(obj) #WAITS FOR DATA
    data=obj.readline()  #READS THE DATA
    reResult=re.match('GW,GDS-1072A-U',data) #SEARCHES THE DATA FOR THE PATTERN
    isAFG2005=not not reResult#DECISION IS IT THE AFG2005

    if closePort:   #DECISION TO CLOSE PORT BEFORE RETURN
        obj.close()

    return isAFG2005
Beispiel #5
0
def serialComIsDeviceARDVOLACTUATOR(obj):

    closePort = False

    if not obj.is_open:
        obj.open()  #OPENS THE SERIAL PORTS IF CLOSED
        closePort = True  #DECISION BASIS CLOSE PORT BEFORE RETURN
    #print(obj.readline())
    obj.flushInput()  #FLUSHES THE INPUT BUFFER
    obj.writelines('*IDN?\n')  #QUERRY THE PORT/DEVICE FOR ID NUMBER
    #sleep(1)
    #obj.write('*IDN?')   #QUERRY THE PORT/DEVICE FOR ID NUMBER
    serialComWaitForData(obj)  #WAITS FOR DATA
    data = obj.readline()  #READS THE DATA
    #print(data)
    reResult = re.match('ARDVOLACTUATOR',
                        data)  #SEARCHES THE DATA FOR THE PATTERN
    isAFG2005 = not not reResult  #DECISION IS IT THE AARDUNO VOLUME ACTUATOR

    if closePort:  #DECISION TO CLOSE PORT BEFORE RETURN
        obj.close()

    return isAFG2005
Beispiel #6
0
    serGDS, ch)  # WAIT S FOR DEVICE TO BE READY TO ACQUIRE
data = numpy.zeros(4000)  #CONTAINER FOR DATA
data_index_start = 14  #
data_index_end = 8014  #8014 max
n = numpy.arange(0.0, len(data))  #INDEX FOR UNPACKED FORMATTED DATA
omega_excite = 2 * numpy.pi * freq_excite  #ANGULAR VEOLCITY OF THE EXCITATION

while True:
    ##SEND A VALUE AND SEE IF IT COMES BACK
    serGDS.writelines(
        ':ACQ' + str(ch) +
        ':LMEM?\n')  #INSTRUCTION TO THE GDS TO ACQUIRE WAVEFORM DATA

    while serGDS.inWaiting() == 0:
        pass  #WAITS FOR THE DATA
    serialComWaitForData(serGDS)  #WAITS FOR THE DATA

    x0 = serGDS.readlines()  #READS THE MEASUREMENT AS A LIST
    x1 = ''
    for i in range(len(x0)):
        x1 = x1 + x0[i]  #CONCATENATES ELEMENTS IN THE LIST

    time_interval0 = unpack_from(
        '>f', x1, 6)  #UNPACKS THE BYTES ASSOCIATED WITH THE TIME INTERVAL!
    time_interval = time_interval0[0]  #EXTRACTS THE TIME INTERVAL

    index_data = 0  #INDEX FOR UNPACKED AND FORMATTED DATA
    for data_index in range(data_index_start, data_index_end, 2):
        z = unpack_from('>h', x1,
                        data_index)  #UNPACKS A SHORT INTEGER FROM THE DATA
        z1 = float(z[0])  #EXTRACTS THE INTEGER AND CONVERTS TO A FLOAT
Beispiel #7
0
    H_excite = numpy.sum(
        numpy.multiply(data, numpy.exp(
            -1j * omega_excite * n *
            time_interval)))  #FREQUENCY RESPONSE AT THE EXCITATION FREQUENCY
    S = abs(
        H_excite)**2 / time_interval  #MAGNITUDE ACCORDING TO PARSEVALS THEOREM
    S = S / 10000 + 120.0
    #print(serARD.readlines())
    serARD.flushInput()
    serARD.flushOutput()
    print(str(S))
    serARD.write(str(S))

    #while serARD.inWaiting()==0:
    #pass
    serialComWaitForData(serARD, 10000000)
    bla02 = serARD.readline().rstrip()
    print(bla02)
    if bla02:
        print(bla02)
    else:
        print("FAILURE TO READ")

#scal=serialComGWGDS1072AUgetPotScale(serGDS,2) #GET THE POTENTIAL SCALE
#print(scal)

#offs=serialComGWGDS1072AUgetPotOffset(serGDS,2)
#print(offs)

# CLOSE PORTS
serGDS.close()