import numpy as np
import matplotlib.pyplot as plt
# The input amplitude and rotations of the potentiometer
Vin = 5
rotation_experimental = np.array([0, 90, 180, 270])
# Output amplitude at the same rotations as above
Vout_experimental = np.array([0, 3.8, 4.4, 4.6])
R1_simulation = np.array([20, 40, 60, 80])
# Output amplitude at the same rotations as above
Vout_simulation = np.array([3.3, 4, 4.3, 4.4])
kOhm_per_degree_of_rotation = 100 / 270
# these are not the answers... but they might give some insight???
#Vout_experimental = np.array([0, 3.8, 4.4, 4.6])
#Vout_simulation = np.array([3.3, 4, 4.3, 4.4])
#kOhm_per_degree_of_rotation = 10.0 / 360
# this will compute the resistance corresponding to each rotation
R1_determined_from_experimental = kOhm_per_degree_of_rotation * rotation_experimental
# Plot
plt.plot(rotation_experimental, Vout_experimental,'rs-')
plt.title('Plot 1: Experimental Results: Response to Rotation')
plt.xlabel('Rotation (deg)')
plt.ylabel('Output (V)')
plt.grid(True)
plt.show()
# Plot
plt.plot(R1_simulation, Vout_simulation,'bo--')
plt.title('Plot 2: Simulation Results: Vout vs. R1')
plt.xlabel('R1 (k$\Omega$)')
plt.ylabel('Output (V)')
plt.grid(True)
plt.show()
# Plot
plt.plot(R1_simulation, Vout_simulation,'rs-')
plt.plot(R1_determined_from_experimental, Vout_experimental,'bo--')
plt.title('Plot 3: Overlaid Results')
plt.xlabel('R1 (k$\Omega$)')
plt.ylabel('Output (V)')
plt.grid(True)
plt.legend(("Experimental: R1 inferred from rotation","Simulation Results (same as plot 2)"))
plt.show()
#print "R1_determined_from_experimental is {0}".format(R1_determined_from_experimental)