### start of main program
try:
    log.info("ReadIdnExpanded.py started.")

    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()

    # connect to SpikeSafe
    tcp_socket.open_socket(ip_address, port_number)

    # request SpikeSafe information
    tcp_socket.send_scpi_command('*IDN?')

    # read SpikeSafe information
    data = tcp_socket.read_data()
    log.info("SpikeSafe *IDN? Response: {}".format(data))

    # request if Digitizer is available (This is only available on PSMU and PSMU HC depending on model)
    tcp_socket.send_scpi_command('VOLT:DIGI:AVAIL?')

    # read Digitizer information
    data = tcp_socket.read_data()
    log.info("SpikeSafe VOLT:DIGI:AVAIL? Response: {}".format(data))
    if data == "TRUE":
        tcp_socket.send_scpi_command('VOLT:VER?')
        digitizer_version = tcp_socket.read_data()
        tcp_socket.send_scpi_command('VOLT:DATA:HWRE?')
        digitizer_hardware_rev = tcp_socket.read_data()
        tcp_socket.send_scpi_command('VOLT:DATA:SNUM?')
        digitizer_serial_number = tcp_socket.read_data()
Ejemplo n.º 2
0
                        level=logging.INFO)

### start of main program
try:
    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # digitizer set up
    tcp_socket.send_scpi_command('VOLT:ABOR')

    # Set digitizer range to 10V
    tcp_socket.send_scpi_command('VOLT:RANG 10')

    tcp_socket.send_scpi_command('SYST:ERR?')
    syst_err_string = tcp_socket.read_data()

    # Set digitizer sampling mode
    if sampling_mode_input == 1:
        tcp_socket.send_scpi_command('VOLT:SAMPMODE FASTLOG')
    elif sampling_mode_input == 2:
        tcp_socket.send_scpi_command('VOLT:SAMPMODE MEDIUMLOG')
    elif sampling_mode_input == 3:
        tcp_socket.send_scpi_command('VOLT:SAMPMODE SLOWLOG')

    # Query the digitizer sampling mode
    tcp_socket.send_scpi_command('VOLT:SAMPMODE?')
    sampling_mode_string = tcp_socket.read_data()

    tcp_socket.send_scpi_command('SYST:ERR?')
    syst_err_string = tcp_socket.read_data()
Ejemplo n.º 3
0
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

### start of main program
try:
    log.info("ReadMemoryTableData.py started.")

    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # request SpikeSafe memory table
    tcp_socket.send_scpi_command('MEM:TABL:READ')

    # read SpikeSafe memory table and print SpikeSafe response to the log file
    data = tcp_socket.read_data()
    log.info(data)

    # parse SpikeSafe memory table
    memory_table_read = MemoryTableReadData().parse_memory_table_read(data)

    # disconnect from SpikeSafe
    tcp_socket.close_socket()

    log.info("ReadMemoryTableData.py completed.\n")

except SpikeSafeError as ssErr:
    # print any SpikeSafe-specific error to both the terminal and the log file, then exit the application
    error_message = 'SpikeSafe error: {}\n'.format(ssErr)
    log.error(error_message)
    print(error_message)
### start of main program
try:
    log.info("ConnectDisconnectSwitchSample.py started.")

    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # reset to default state
    tcp_socket.send_scpi_command('*RST')

    # check that the Force Sense Selector Switch is available for this SpikeSafe. We need the switch to run this sequence
    # If switch related SCPI is sent and there is no switch configured, it will result in error "386, Output Switch is not installed"
    tcp_socket.send_scpi_command('OUTP1:CONN:AVAIL?')
    isSwitchAvailable = tcp_socket.read_data()
    if isSwitchAvailable != 'Ch:1':
        raise Exception(
            'Force Sense Selector Switch is not available, and is necessary to run this sequence.'
        )

    # set the Force Sense Selector Switch state to Primary (A) so that the SpikeSafe can output to the DUT
    # the default switch state can be manually adjusted using SCPI, so it is best to send this command even after sending a *RST
    tcp_socket.send_scpi_command('OUTP1:CONN PRI')

    # set Channel 1's settings to operate in Multi-Pulse mode
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP MULTIPULSE')
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 1')
    tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 1')
### start of main program
try:
    log.info("ForceSenseSwitchSample.py started.")

    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # reset to default state
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # check that the Force Sense Selector Switch is available for this SpikeSafe. We need the switch to run this sequence
    # If switch related SCPI is sent and there is no switch configured, it will result in error "386, Output Switch is not installed"
    tcp_socket.send_scpi_command('OUTP1:CONN:AVAIL?')
    isSwitchAvailable = tcp_socket.read_data()
    if isSwitchAvailable != 'Ch:1':
        raise Exception(
            'Force Sense Selector Switch is not available, and is necessary to run this sequence.'
        )

    # set the Force Sense Selector Switch state to Primary (A) so that the SpikeSafe can output to the DUT
    # the default switch state can be manually adjusted using SCPI, so it is best to send this command even after sending a *RST
    tcp_socket.send_scpi_command('OUTP1:CONN PRI')

    # set Channel 1 settings to operate in DC mode
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP DC')
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
    tcp_socket.send_scpi_command('VOLT:INIT')

    # turn on Channel 1 
    tcp_socket.send_scpi_command('OUTP1 1')

    # wait until Channel 1 is ready to pulse
    read_until_event(tcp_socket, 100) # event 100 is "Channel Ready"

    # output the Digitizer hardware output trigger. 10µs after this signal is outputted, the Multi Pulse sequence will start
    tcp_socket.send_scpi_command('VOLT:OUTP:TRIG')

    # check that the Multi Pulse output has ended
    has_multi_pulse_ended = ''
    while has_multi_pulse_ended != 'TRUE':
        tcp_socket.send_scpi_command('SOUR1:PULS:END?')
        has_multi_pulse_ended =  tcp_socket.read_data()
        wait(0.5)

    # output the Digitizer hardware output trigger. As long as the SpikeSafe is ready to pulse, this can be done continuously
    tcp_socket.send_scpi_command('VOLT:OUTP:TRIG')

    # check that the Multi Pulse output has ended
    has_multi_pulse_ended = ''
    while has_multi_pulse_ended != 'TRUE':
        tcp_socket.send_scpi_command('SOUR1:PULS:END?')
        has_multi_pulse_ended =  tcp_socket.read_data()
        wait(0.5)

    # wait for the Digitizer measurements to complete 
    wait_for_new_voltage_data(tcp_socket, 0.5)
    # Output 1ms pulse for Channel 1
    tcp_socket.send_scpi_command('OUTP1:TRIG')

    # check for all events and measure readings on the channel once per second for 2 seconds,
    # it is best practice to do this to ensure the channel is on and does not have any errors
    time_end = time.time() + 2
    while time.time() < time_end:
        log_all_events(tcp_socket)
        log_memory_table_read(tcp_socket)
        wait(1)

    # check that the Multi Pulse output has ended
    has_multi_pulse_ended = ''
    while has_multi_pulse_ended != 'TRUE':
        tcp_socket.send_scpi_command('SOUR1:PULS:END?')
        has_multi_pulse_ended = tcp_socket.read_data()
        wait(0.5)

    # After the pulsing has ended, set Channel 1's current to 200 mA while the channel is enabled
    tcp_socket.send_scpi_command('SOUR1:CURR 0.2')

    # Output 1ms pulse for Channel 1. Multiple pulses can be outputted while the channel is enabled
    tcp_socket.send_scpi_command('OUTP1:TRIG')

    # check for all events and measure readings after the second pulse output
    time_end = time.time() + 2
    while time.time() < time_end:
        log_all_events(tcp_socket)
        log_memory_table_read(tcp_socket)
        wait(1)