In [83]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

Obtain Empty ADC Value

In [85]:
fname = 'empty_fs10hz_cleaned.csv'
empty = pd.read_csv(fname,header=None,names=['datetime','adc'],parse_dates=[0])
empty = empty.set_index('datetime')
empty.describe()
Out[85]:
adc
count 9.980000e+02
mean -1.261880e+08
std 8.966628e+05
min -1.320588e+08
25% -1.259789e+08
50% -1.259462e+08
75% -1.259221e+08
max -1.258074e+08
In [86]:
empty.plot()
plt.title("String Pot Extended")
plt.ylabel('ADC Value')
plt.xlabel('Elapsed Time')
Out[86]:
Text(0.5, 0, 'Elapsed Time')

Obtain Full ADC Value

In [87]:
fname = 'full_fs10hz_cleaned.csv'
full = pd.read_csv(fname,header=None,names=['datetime','adc'],parse_dates=[0])
full = full.set_index('datetime')
full.describe()
Out[87]:
adc
count 9.980000e+02
mean 7.292633e+08
std 1.644891e+06
min 7.180838e+08
25% 7.294535e+08
50% 7.297814e+08
75% 7.300557e+08
max 7.302926e+08
In [88]:
full.plot()
plt.title("String Pot Retracted")
plt.ylabel('ADC Value')
plt.xlabel('Elapsed Time')
Out[88]:
Text(0.5, 0, 'Elapsed Time')

Determine the Transfer Function

In [104]:
#Get the transfer function
percent = np.array([0,100])
adc = np.array([empty.adc.max(),full.adc.max()])
np.diff(adc)
Out[104]:
array([856100075], dtype=int64)
In [103]:
m = (np.diff(percent) / np.diff(adc))
b = (percent[0]- m*adc[0])
print(f"percent full = {m[0]}*x + {b[0]}")
percent full = 1.1680877378734023e-07*x + 14.695411514827867

Verify the Calibration

In [116]:
fname = 'moving_fs10hz_cleaned.csv'
mov = pd.read_csv(fname,header=None,names=['datetime','bname','calculated position','adcname','adc'],parse_dates=[0])
mov = mov.set_index('datetime')
In [119]:
mov.plot(subplots=True, figsize=[11,8])
plt.suptitle("Moving After Calibration")
plt.xlabel('Elapsed Time');
In [ ]: