from matplotlib import pyplot as plt import numpy as np def make_current_graph(): v = [400, 600, 800, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000] i = [75.5, 79.8, 84.7, 88, 94, 97.4, 100.4, 102.8, 105.7, 107.8, 109.2, 112, 114.2, 115] fig, ax = plt.subplots(1, 1) ax.plot(v, i, linewidth=2, marker='x') ax.set_xlabel("Voltage (V)") ax.set_ylabel("Current (uA)") plt.savefig('opto-150.png') plt.show() if __name__ == '__main__': # This script calculates the voltage vs time of a capacitor (representing an electrostatic actuator) which is # initially completely discharged. The capacitor is connected to a voltage source v through an opto-coupler OPTO-150 # The scripts uses a crude forward finite differences scheme to calculate the voltage over time on the capacitor # (i.e. actuator) taking into account: 1) the current through the OPTO-150, which decreases when the capacitor # charges, and 2) the current spent in the voltage feedback reading circuit, which is proportional to the voltage # on the capacitor. This can be use to estimate how fast an actuator of a given size (i.e. capacitance) can be # charged by the hvps-x v = 4000 # enter the voltage set point of the hvps-x c = 1.4E-9 # enter the capacitance connected to the output in F Rmon = 500E6 # This is the monitoring resistor (R13). 250M in the initial release. Will be increased to 500M. dt = 1E-3 # time step of the FD calculation tf = 200E-3 # time at which the simulation stops time = np.arange(0, tf, dt) u = np.zeros_like(time) for i in range(len(u)-1): v_opto = v - u[i] i_opto = (14.6 * np.log(v_opto) - 13.3) / 1E6 i_meas = u[i] / Rmon i_charge = i_opto - i_meas u[i+1] = u[i] + dt * i_charge / c fig, ax = plt.subplots(1, 1) ax.plot(time, u) ax.set_xlabel('time (s)') ax.set_ylabel('Voltage (V)') plt.savefig('fd.png') plt.show()