@dlee , sorry for the delay.
Just to clarify, it is possible that your CW and CCW propellers are not exactly the same, therefore the CW and CCW motors are showing slightly different response to calibration. In this case we can calculate an average for this calibration and use that for all 4 motors. I modified the script to calculate the quadratic fit for all four calibration results together.
import numpy as np
import plotly.graph_objects as go
rpms = np.arange(0,13000) #rpm range for the quadratic fit
cals = []
fits = []
all_fits = []
#enter the calibration results from each motor
cals.append([7.53669159958e-06, 0.336081465707, 112.878194918])
cals.append([2.9479165331e-06, 0.37353561309, 35.6265065345])
cals.append([8.8413818561e-06, 0.3256003514, 132.362831923])
cals.append([7.1523119742e-07, 0.405821707061, -98.2189291548])
fig = go.Figure()
for idx in range(len(cals)):
fit = np.polyval(cals[idx], rpms)
fits.append(fit)
fig.add_trace(go.Scatter(x=rpms, y=fits[idx], name='Fit %d'%idx)) #plot each fit
#create an array that contains points sampled from each curve
#and perform a polynomial fit on all the data to find the average
all_data = np.array(fits).flatten('C')
all_rpms = np.array([rpms,rpms,rpms,rpms]).flatten('C')
#evaluate the average poly fit
ply = np.polyfit(all_rpms, all_data, 2)
av_fit = np.polyval(ply, rpms)
#print the average fit coefficients
print('Average Fit coefficients:')
print(' pwm_vs_rpm_curve_a0 = ' + str(ply[2]))
print(' pwm_vs_rpm_curve_a1 = ' + str(ply[1]))
print(' pwm_vs_rpm_curve_a2 = ' + str(ply[0]))
#plot the average
fig.add_trace(go.Scatter(x=rpms, y=av_fit, name='Average Fit'))
#finalize and show the figure
fig.update_layout(title='Motor Voltage vs. RPM')
fig.update_xaxes(title_text="RPM")
fig.update_yaxes(title_text="Motor Voltage (mV)")
fig.show()
It results in the following plot and average coefficients. You can enter these coefficients into your custom esc parameters xml file.
Average Fit coefficients:
pwm_vs_rpm_curve_a0 = 45.66215105517507
pwm_vs_rpm_curve_a1 = 0.36025978431449995
pwm_vs_rpm_curve_a2 = 5.01030529655002e-06
2dd75e2f-f722-464d-be82-5548568ec25b-image.png