# This is actually working AWK Code.
# It is similar to C, but watch out for
# C's default use of integer math!
BEGIN{ pi=3.1415926536;
ORS="";
print "watts flywheel,gear ratio,amps motor/5,rpm motor/1000,Nm motor*10,watts motor/10,Nm flywheel*10";
ORS="\n";
# User Input:
throttle_fraction = 0.65;
rpm_flywheel = 2500;
gearbox_torque_efficiency_fraction = 0.8;
# FRC published motor specs for 775 Pro:
motor = "775 Pro";
volts_spec = 12;
rpm_free_spec = 18700;
amps_free_spec = 0.7;
amps_stall_spec = 134;
inoz_stall_spec = 100.54;
# Convert motor specs to SI units at throttled volts:
volts = throttle_fraction*volts_spec;
radsPerSec_free = (volts/volts_spec)*rpm_free_spec*pi/30;
amps_free = (volts/volts_spec)*amps_free_spec;
amps_stall = (volts/volts_spec)*amps_stall_spec;
Nm_stall = (volts/volts_spec)*inoz_stall_spec*0.00706155;
print ",," motor "; throttle_fraction=" throttle_fraction "; rpm_flywheel=" rpm_flywheel "; torque_efficiency=" gearbox_torque_efficiency_fraction;
}
{
# get gear ratios from user data file:
gear_ratio = $1;
# do computations and output CSV file for Excel:
radsPerSec_flywheel = rpm_flywheel*pi/30;
radsPerSec_motor = radsPerSec_flywheel*gear_ratio;
xNm_motor = amps_stall * (1 - radsPerSec_motor/radsPerSec_free);
Nm_motor = Nm_stall * (1 - radsPerSec_motor/radsPerSec_free);
amps_motor = amps_free + (Nm_motor/Nm_stall)*(amps_stall-amps_free);
Nm_flywheel = Nm_motor * gear_ratio * gearbox_torque_efficiency_fraction;
watts_motor = Nm_motor*radsPerSec_motor;
watts_flywheel = Nm_flywheel*radsPerSec_flywheel;
gearbox_power_efficiency_fraction = watts_flywheel/watts_motor;
rpm_motor = rpm_flywheel*gear_ratio;
print watts_flywheel "," gear_ratio "," amps_motor/5 "," rpm_motor/1000 "," Nm_motor*10 "," watts_motor/10 "," Nm_flywheel*10;
}
END{}