

thread_pitch = 0.5904
stroke_length = 60.0

motor_nameplate_hertz = 120.0
motor_nameplate_rpm = 1200.0

def find_rpm_for_spm(spm_target):
    revolutions_per_fullstroke = 2.0 * stroke_length / thread_pitch
    seconds_per_stroke = 60.0 / spm_target
    revolutions_per_second = revolutions_per_fullstroke / seconds_per_stroke
    return revolutions_per_second * 60.0

def find_hz_for_rpm(rpm_target):
    return rpm_target * (motor_nameplate_hertz / motor_nameplate_rpm)

if __name__ == '__main__':
    for x in [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]:
        rpm = round(find_rpm_for_spm(x), 3)
        hz = round(find_hz_for_rpm(rpm), 3)
        print(x, rpm, hz)
