[Python] How to know that SCPI "STOP" command is working as intended

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    Good morning,

    I am using a DPO7054 in order to read the voltage signal of 2 Single-Photon Avalanche Diodes. I have used a GPIB connection to setup the acquisition of "CURVE"s from the two channels that I use. Since I do correlation measurements I need both "CURVE"s to be taken at the same time, for that I added a "STOP" SCPI command before the acquisition. Nonetheless, I don't know if this way is bug free, like, how do I know that CHANNEL 1 stopped while CHANNEL 2 didn't acquire another waveform, how do I know that another frame was not updated?

    The acquiring code look like this :

    import pyvisa

    rm = pyvisa.ResourceManager()
    scope = rm.open_resource('GPIB0::1::INSTR') #Create an Instrument variable
    data_list = []
    for ind in range(5):
    scope.write('START')
    scope.write('STOP')
    time.sleep(0.5)

    # ---- [START] iterate over the available channels ----
    for n in range(2):
    scope.write(f"DATA:SOURCE {n}")
    scope.query('*opc?') # '0' if not, '1' if yes
    if ind==0:
    scope.write("DATA:ENC RIB")
    scope.write("DATA:BYT_Or MSB")
    scope.write("DATA:WIDTH 1")
    scope.write("DATA:START 0")
    scope.write("DATA:STOP 1e10")
    recordLength = int(scope.query("WFMO:NR_P?")) are actually available
    scope.write("DATA:STOP {0}".format(recordLength)) #Set data stop

    # Acquire waveform
    scope.write("CURVE?")
    data = scope.read_binary_values(datatype='b',
    is_big_endian=True,
    container=np.ndarray,
    header_fmt='ieee',
    expect_termination=True) # Reading binary data

    opc = os.scope.query('*opc?')
    while opc == 0:
    print("CURVE not finished")
    time.sleep(0.5)
    opc

    print("CURVE done")
    data_list.append(data)


    I hope I explained my problem correctly.

    Thanks for your time.

    PS : I also don't know if the OPC command is actually working, the print in the "whille opc == 0" loop are never called even if I take waveforms of multiple milliseconds, which takes some time to communicate along the GPIB connection.

    Continue reading...

Compartilhe esta Página