hephy-dd / diode-measurement

IV/CV measurements for silicon sensors.
GNU General Public License v3.0
0 stars 2 forks source link

Change voltage yields range error #6

Closed arnobaer closed 3 years ago

arnobaer commented 3 years ago

Using change voltage to reduce the voltage during It measurements yields a range error due to the fact that the source range is set to the target voltage before ramping down.

Change voltage needs two strategies: increase voltage and decrease voltage, eg. (pseudo code)

def increase_voltage(current_voltage, target_voltage, step_voltage):
    context.set_source_range(target_voltage)  # set higher target range
    for voltage in linear_range(current_voltage, target_voltage, step_voltage):
        context.set_source_voltage(voltage)

def decrease_voltage(current_voltage, target_voltage, step_voltage):
    for voltage in linear_range(current_voltage, target_voltage, step_voltage):
        context.set_source_voltage(voltage)
    context.set_source_range(target_voltage)  # set lower target range

def change_voltage(current_voltage, target_voltage, step_voltage):
    if abs(current_voltage) > abs(target_voltage):
        decrease_voltage(current_voltage, target_voltage, step_voltage)
    else:
        increase_voltage(current_voltage, target_voltage, step_voltage)