adds encoder calculation and optimizes henrypump calcs

This commit is contained in:
Patrick McDonagh
2018-02-01 11:55:23 -06:00
parent 078a72c918
commit 67d6ad76a5
2 changed files with 75 additions and 0 deletions

25
encoder.py Normal file
View File

@@ -0,0 +1,25 @@
"""Encoder functions."""
MAX_RPM = 1200.0
def pulse_freq(rpm, pulses_per_rev):
"""Calculate the pulse frequency."""
rotations_per_second = rpm / 60.0
pulses_per_second = rotations_per_second * pulses_per_rev
return pulses_per_second
if __name__ == '__main__':
for x in range(0, 101):
rpm = MAX_RPM * (x * 0.01)
pulse_freq_at_rpm = pulse_freq(rpm, 6000)
print("{}\t\t{}".format(rpm, round(pulse_freq_at_rpm / 1000000.0, 4)))
last_freq_at_maxrpm = 0.0
for pulses_per_rev in range(0, 65536):
freq_at_maxrpm = pulse_freq(MAX_RPM, pulses_per_rev)
if last_freq_at_maxrpm < 500000.0 and freq_at_maxrpm >= 500000.0:
print("500 kHz at {}".format(pulses_per_rev))
exit()
last_freq_at_maxrpm = freq_at_maxrpm

View File

@@ -18,6 +18,9 @@ g_motor_full_speed_rpm = 1200.0 # RPM
g_run_speed = 120.0 # Hz
MAX_NUT_ENDLOAD = 11000.0 # pounds
FLUID_GRADIENT = 0.43733 # PSI/ft
pump_constants = {
0.625: 0.046,
0.75: 0.066,
@@ -36,6 +39,53 @@ pump_constants = {
4.75: 2.630
}
fluid_load_constants = {
1.0625: 0.384,
1.25: 0.531,
1.5: 0.765,
1.75: 1.041,
2.0: 1.36,
2.25: 1.721,
2.5: 2.125,
2.75: 2.571
}
def _ftlb_to_nm(ftlb):
"""Convert ft-lbs to n-m."""
return ftlb / 0.73756
def _nm_to_ftlb(nm):
"""Convert n-m to ft-lbs."""
return nm * 0.73756
def max_production(pump_size, strokes_per_minute, stroke_length):
"""Calculate the maximum production capabilities of a pump at a speed."""
try:
return pump_constants[pump_size] * strokes_per_minute * stroke_length
except KeyError:
print("No pump constant for that size pump.")
def end_load(pump_size, depth, strokes_per_minute, stroke_length):
"""Calculate the end load on the nut."""
try:
fluid_load_constant = fluid_load_constants[pump_size]
return depth * fluid_load_constant * (FLUID_GRADIENT / 0.433)
except KeyError:
print("No fluid load constant for that size pump.")
def max_producing_depth(pump_size):
"""Calculate the maximum producing depth."""
try:
fluid_load_constant = fluid_load_constants[pump_size]
return MAX_NUT_ENDLOAD / (fluid_load_constant * (FLUID_GRADIENT / 0.433))
except KeyError:
print("No fluid load constant for that size pump.")
def voltage_drop(length, current, temperature, circular_mils, alpha):
"""Calculate the voltage drop in the wire."""