예제 #1
0
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set each channel's pulse mode to Single Pulse
    tcp_socket.send_scpi_command('SOUR0:FUNC:SHAP SINGLEPULSE')

    # set each channel's current to 100 mA
    tcp_socket.send_scpi_command('SOUR0:CURR 0.1')

    # set each channel's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR0:VOLT 20')

    # set each channel's pulse width to 1ms. Of the pulse time settings, only Pulse On Time and Pulse Width [+Offset] are relevant in Single Pulse mode
    tcp_socket.send_scpi_command('SOUR0:PULS:TON 0.001')

    # set each channel's compensation settings to their default values
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to DC and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP DC')
    log_all_events(tcp_socket)

    # set Channel 1's safety threshold for over current protection to 50% and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
    log_all_events(tcp_socket)

    # set Channel 1's current to 100 mA and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
    log_all_events(tcp_socket)

    # set Channel 1's voltage to 10 V and check for all events
    log_all_events(spike_safe_socket)

    # space out the log and terminal output for clarity
    log_and_print('')


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

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

    # reset to default state and configure settings to run in Continuous Dynamic mode
    tcp_socket.send_scpi_command('*RST')
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSEDDYNAMIC')
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
    tcp_socket.send_scpi_command('SOUR1:PULS:CCOM 4')
    tcp_socket.send_scpi_command('SOUR1:PULS:RCOM 4')

    # initially setting the On and Off Time to their default values using the standard commands
    # Although not recommended, it is possible to use On Time, Off Time, Pulse Width, Period, and Duty Cycle commands in the same test session
    # If On or Off Time is specified using these standard commands, the Pulse Hold will be ignored
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 0.001')
    tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.009')

    # Check for any errors with initializing commands
    log_all_events(tcp_socket)
예제 #4
0
log = logging.getLogger(__name__)
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    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
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to Modulated DC
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP MODULATED')

    # set Channel 1's current to 200 mA. This will be the output current when a sequence step specifies "@100"
    tcp_socket.send_scpi_command('SOUR1:CURR 0.2')

    # set Channel 1's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')

    # set Channel 1's modulated sequence to a DC staircase with 5 steps
    # There are 5 current steps that each last for 1 second: 40mA, 80mA, 120mA, 160mA, and 200mA
    tcp_socket.send_scpi_command('SOUR1:SEQ 1(1@20,1@40,1@60,1@80,1@100)')
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # Synchronize rising edge of all channels
    tcp_socket.send_scpi_command('SOUR1:PULS:STAG 0')

    # set Channel 1's pulse mode to Pulsed Dynamic and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIASPULSEDDYNAMIC')

    # set Channel 1's current to 100 mA
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')

    # set Channel 1's voltage to 10 V
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')

    # set Channel 1's bias current to 20 mA and check for all events
예제 #7
0
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to Pulsed Sweep and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSEDSWEEP')

    # set Channel 1's Pulsed Sweep parameters to match the test expectation
    tcp_socket.send_scpi_command('SOUR1:CURR:STAR 0.02')
    tcp_socket.send_scpi_command('SOUR1:CURR:STOP 0.2')
    tcp_socket.send_scpi_command('SOUR1:CURR:STEP 100')

    # set Channel 1 to output one pulse per step
    tcp_socket.send_scpi_command('SOUR1:PULS:COUN 1')

    # set Channel 1's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
예제 #8
0
                        level=logging.INFO)
elif grease_input == 2:
    logging.basicConfig(filename=os.path.relpath(filename_no_grease_log),
                        filemode='w',
                        format=' %(message)s',
                        datefmt='%S',
                        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')
### setting up sequence log
log = logging.getLogger(__name__)
logging.basicConfig(filename='SpikeSafePythonSamples.log',format='%(asctime)s, %(levelname)s, %(message)s',datefmt='%m/%d/%Y %I:%M:%S',level=logging.INFO)

### start of main program
try:
    log.info("DigitizerOutputTriggerSample.py started.")
        
    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command      
    tcp_socket.send_scpi_command('*RST')                  
    log_all_events(tcp_socket)

    # abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
    tcp_socket.send_scpi_command('VOLT:ABOR')

    # set up Channel 1 for Multi Pulse output. To find more explanation, see run_spikesafe_operation_modes/run_multi_pulse
    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')
    tcp_socket.send_scpi_command('SOUR1:PULS:COUN 3')
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')    
    tcp_socket.send_scpi_command('SOUR1:PULS:CCOM 4')
    tcp_socket.send_scpi_command('SOUR1:PULS:RCOM 4')
### setting up sequence log
log = logging.getLogger(__name__)
logging.basicConfig(filename='SpikeSafePythonSamples.log',format='%(asctime)s, %(levelname)s, %(message)s',datefmt='%m/%d/%Y %I:%M:%S',level=logging.INFO)

### start of main program
try:
    log.info("FixedPulseCountUsingSoftwareTimingExample.py started.")
        
    # instantiate new TcpSocket to connect to SpikeSafe
    tcp_socket = TcpSocket()
    tcp_socket.open_socket(ip_address, port_number)

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command      
    tcp_socket.send_scpi_command('*RST')                  
    log_all_events(tcp_socket)

    # set Channel 1's mode to DC Dynamic and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSEDDYNAMIC')
    log_all_events(tcp_socket)

    # set Channel 1's Trigger Output to Positive and check for all events
    tcp_socket.send_scpi_command('OUTP1:TRIG:SLOP POS')
    log_all_events(tcp_socket)

    # set Channel 1's Trigger Output Always and check for all events
    tcp_socket.send_scpi_command('SOUR0:PULS:TRIG ALWAYS')
    log_all_events(tcp_socket)

    # set Channel 1's Pulse On Time to 1us and check for all events
예제 #11
0
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to Pulsed and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSED')
    log_all_events(tcp_socket)

    # set Channel 1's Pulse On Time to 1ms and check for all events
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 0.001')
    log_all_events(tcp_socket)

    # set Channel 1's Pulse Off Time to 9ms and check for all events
    tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.009')
    log_all_events(tcp_socket)

    # set Channel 1's safety threshold for over current protection to 50% and check for all events
        cas_spectrometer.casPerformAction(
            deviceId, cas_spectrometer.paPrepareMeasurement).rval)

    # reset the CAS4 trigger signal in preparation for the measurement
    cas_spectrometer.casSetDeviceParameter(deviceId,
                                           cas_spectrometer.dpidLine1FlipFlop,
                                           0)

    ### SpikeSafe Connection and Configuration (Start of typical sequence)

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

    # reset SpikeSafe to default state and check for all events
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set SpikeSafe Channel 1's pulse mode to Single Pulse and set all relevant settings. For more information, see run_spikesafe_operating_modes/run_dc
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP SINGLEPULSE')
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 1')
    tcp_socket.send_scpi_command('SOUR1:CURR {}'.format(set_current_amps))
    tcp_socket.send_scpi_command('SOUR1:VOLT {}'.format(compliance_voltage_V))
    log_all_events(tcp_socket)

    # turn on SpikeSafe Channel 1 and check for all events
    tcp_socket.send_scpi_command('OUTP1 1')
    log_all_events(tcp_socket)

    # wait until the channel is fully ramped and output a single pulse
    read_until_event(tcp_socket, 100)  # event 100 is "Channel Ready"
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
    tcp_socket.send_scpi_command('VOLT:ABOR')

    # set up Channel 1 for Bias Current output to determine the K-factor
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIAS')
    tcp_socket.send_scpi_command('SOUR0:CURR:BIAS 0.033')
    tcp_socket.send_scpi_command('SOUR1:VOLT 40')
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
    tcp_socket.send_scpi_command('OUTP1:RAMP FAST')

    log_and_print_to_console(
        '\nConfigured SpikeSafe to Bias Current mode to obtain K-factor. Starting current output.'
    )
예제 #14
0
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to DC and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIAS')
    log_all_events(tcp_socket)

    # set Channel 1's safety threshold for over current protection to 50% and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
    log_all_events(tcp_socket)

    # set Channel 1's bias current to 10 mA and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR:BIAS 0.01')
    log_all_events(tcp_socket)

    # set Channel 1's voltage to 10 V and check for all events
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's pulse mode to Bias Single Pulse
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIASSINGLEPULSE')

    # set Channel 1's current to 100 mA
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')

    # set Channel 1's bias current to 10 mA and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR:BIAS 0.01')

    # set Channel 1's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')

    # set Channel 1's pulse width to 1ms. Of the pulse time settings, only Pulse On Time and Pulse Width [+Offset] are relevant in Single Pulse mode
# SpikeSafe IP address and port number
ip_address = '10.0.0.220'
port_number = 8282

### 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?')
log = logging.getLogger(__name__)
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

### 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')
예제 #18
0
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
    tcp_socket.send_scpi_command('VOLT:ABOR')

    # set up Channel 1 for pulsed output. To find more explanation, see instrument_examples/run_pulsed
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSED')
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 0.001')
    tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.009')
    tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
    tcp_socket.send_scpi_command('SOUR1:PULS:CCOM 4')
    tcp_socket.send_scpi_command('SOUR1:PULS:RCOM 4')
    tcp_socket.send_scpi_command('OUTP1:RAMP FAST')
    tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
    tcp_socket.send_scpi_command('VOLT:ABOR')

    # set up Channel 1 for pulsed sweep output. To find more explanation, see instrument_examples/run_spikesafe_operating_modes/run_pulsed
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSEDSWEEP')
    tcp_socket.send_scpi_command('SOUR1:CURR:STAR 0.02')
    tcp_socket.send_scpi_command('SOUR1:CURR:STOP 0.2')
    tcp_socket.send_scpi_command('SOUR1:CURR:STEP 100')
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
    tcp_socket.send_scpi_command('SOUR1:PULS:TON 0.0001')
    tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.0099')
    tcp_socket.send_scpi_command('SOUR1:PULS:CCOM 4')
    tcp_socket.send_scpi_command('SOUR1:PULS:RCOM 4')
        cas_spectrometer.casSetShutter(deviceId, 0)
        cas_spectrometer.check_cas4_device_error(deviceId)

    # prepare the CAS4 for measurement and verify that there are no resulting errorss
    cas_spectrometer.check_cas4_error_code(
        cas_spectrometer.casPerformAction(
            deviceId, cas_spectrometer.paPrepareMeasurement).rval)

    ### SpikeSafe Connection and Configuration (Start of typical sequence)

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

    # reset to default state and check for all events,
    tcp_socket.send_scpi_command('*RST')
    tcp_socket.send_scpi_command('VOLT:ABOR')
    log_all_events(tcp_socket)

    # set up SpikeSafe Channel 1 for Pulsed Sweep output. To find more explanation, see instrument_examples/run_pulsed_sweep
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP PULSEDSWEEP')
    tcp_socket.send_scpi_command('SOUR1:CURR:STAR {}'.format(
        float(LIV_start_current_mA) / 1000))
    tcp_socket.send_scpi_command('SOUR1:CURR:STOP {}'.format(
        float(LIV_stop_current_mA) / 1000))
    tcp_socket.send_scpi_command(
        'SOUR1:CURR:STEP {}'.format(LIV_sweep_step_count))
    tcp_socket.send_scpi_command('SOUR1:VOLT {}'.format(compliance_voltage_V))
    tcp_socket.send_scpi_command(
        'SOUR1:PULS:TON {}'.format(pulse_on_time_seconds))
    tcp_socket.send_scpi_command(
log = logging.getLogger(__name__)
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

### 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
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # set Channel 1's mode to DC Dynamic mode and check for all events
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP DCDYNAMIC')
    log_all_events(tcp_socket)

    # set Channel 1's voltage to 10 and check for all events
    tcp_socket.send_scpi_command('SOUR1:VOLT 10')
    log_all_events(tcp_socket)

    # set Channel 1's Auto Range to On and check for all events
    tcp_socket.send_scpi_command('SOUR1:CURR:RANG:AUTO 1')
    log_all_events(tcp_socket)

    # set Channel 1's current to start current and check for all events
logging.basicConfig(filename='SpikeSafePythonSamples.log',
                    format='%(asctime)s, %(levelname)s, %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S',
                    level=logging.INFO)

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

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

    # reset to default state and check for all events,
    # it is best practice to check for errors after sending each command
    tcp_socket.send_scpi_command('*RST')
    log_all_events(tcp_socket)

    # Synchronize rising edge of all channels
    tcp_socket.send_scpi_command('SOUR0:PULS:STAG 0')

    # set each channel's pulse mode to Pulsed Dynamic
    tcp_socket.send_scpi_command('SOUR0:FUNC:SHAP BIASPULSED')

    # set each channel's current to 100 mA
    tcp_socket.send_scpi_command('SOUR0:CURR 0.1')

    # set each channel's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR0:VOLT 20')

    # set each channel's bias current to 20 mA and check for all events