Exemple #1
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("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()
Exemple #2
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("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')
ip_address = '10.0.0.220'
port_number = 8282

### 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("RunMultiPulseMode.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 Multi Pulse
    tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP MULTIPULSE')

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

    # set Channel 1's voltage to 20 V
    tcp_socket.send_scpi_command('SOUR1:VOLT 20')
ip_address = '10.0.0.220'
port_number = 8282

### 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("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
ip_address = '10.0.0.220'
port_number = 8282

### 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("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')
ip_address = '10.0.0.220'
port_number = 8282

### 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("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 these before starting application

# SpikeSafe IP address and port number
ip_address = '10.0.0.220'
port_number = 8282 

### 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)
Exemple #8
0
    logging.basicConfig(filename=os.path.relpath(filename_grease_log),
                        filemode='w',
                        format=' %(message)s',
                        datefmt='%S',
                        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:
Exemple #9
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("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 these before starting application

# SpikeSafe IP address and port number
ip_address = '10.0.0.220'
port_number = 8282          

### 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')
        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)

    # 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')
# A value of zero corresponds to a completely zoomed in graph. Increase the value to zoom out. Recommended values are between 0.001 and 0.100
graph_zoom_offset = 0.01

### 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("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')
    spike_safe_socket.send_scpi_command('SOUR1:PULS:PER?')
    pulse_period = spike_safe_socket.read_data()
    log_and_print('Updated Pulse Period: {}s'.format(pulse_period))

    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')
Exemple #14
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("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)
Exemple #15
0
ip_address = '10.0.0.220'
port_number = 8282

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

### set these before starting application

# 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
ip_address = '10.0.0.220'
port_number = 8282

### 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("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')
Exemple #18
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("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')
Exemple #19
0
ip_address = '10.0.0.220'
port_number = 8282

### 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("ReadAllEvents.py started.")

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

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

    # read all events in SpikeSafe event queue, store in list, and print them to the log file
    event_data = read_all_events(tcp_socket)
    for event in event_data:
        log.info(event.event)

    # disconnect from SpikeSafe
    tcp_socket.close_socket()

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

except SpikeSafeError as ssErr:
        deviceId, cas_spectrometer.dpidNeedDarkCurrent).rval
    if cas_needs_dark_current_measurement != 0:
        cas_spectrometer.casSetShutter(deviceId, 1)
        cas_spectrometer.casMeasureDarkCurrent(deviceId)
        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))
ip_address = '10.0.0.220'
port_number = 8282

### 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("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.'
        )
step_size_A = (stop_current_A - start_current_A) / (step_count - 1)
load_ohm_value = 1

### 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("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)
ip_address = '10.0.0.220'
port_number = 8282

### 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("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')