% User Input

F = 750;  %compression force on ball screw in lbs
L = 11.1; %Stroke length in inches
lead = .2; %ball screw lead in inches
torqPerkN = 0.44; %torque required to raise 1kN in N-m
greduce = 25; %gearbox reduction
torqConst = 87.6;  %mN-M/A
stroke_t = 30; %time in seconds to complete 1 stroke
motor_V = 15; %desired motor output voltage

%
% First switch to metric

F = F * 4.44822 %N

% Now calculate the max torque produced at output of ball screw when max force is applied

maxT = (F/1000) * torqPerkN %max torque in N-M

% Calculate number of revolutions the ball screw will make during a full stroke

rev = L/lead  %revolutions

%
% I contacted Maxon with the above input and they initially recomended a DCX22L, EB 48V with the following characteristics

spd_const = 109;  %speed constant of the motor in rpm/V

% Assume we want to generate a healthy 15V to charge a 12V batt
% The minimum rpm needed to generate 15V is

min_rpm = motor_V * spd_const   %volts

% This means we will need to use a gearbox with a minimum reduction of (this assumes 60s stroke length).  Can pretty much get rid of this calc

min_red = min_rpm/rev     %no units

% Maxon recommended stepping up to a GPX22UP, 35:1 gearbox. So the torque transmitted to the motor would be

motor_torque = 1000 * maxT/greduce  %mN-M

% From the torque constant of the motor this should produce the following current

motor_I = motor_torque/torqConst  %Amps

% Calculate time it will take to do 1 stroke at minimum rpm

screw_rpm = min_rpm/greduce
stroke_t = (rev/screw_rpm)*60 %seconds

% Power produced from 1 stroke

power = motor_I * motor_V * stroke_t %joules

% Wire walker currently uses about 100J/cast (up and down).
%
%
% From Maxan generator design guide (https://support.maxongroup.com/hc/en-us/articles/360004496254-maxon-Motors-as-Generators):
% Optimum operation is at a load current
%
%
%
%
%
%
%
%