def setUp(self): self.axis = Axis("X", command_type="I", command_id=0, test_mode=True) self.axis.debug = True self.axis.frequency = 125000.0 self.axis.pulse_count = 4294967295 self.axis.direction = 1 self.axis.start_ramp = 1 self.axis.finish_ramp = 1 self.axis.ramp_divide = 100 self.axis.ramp_pause = 10 self.axis.link_to_adc = 0 self.axis.enable_line_polarity = 1 self.axis.pulse_count_change_direction = 0 self.axis.pulse_counts_sent_back = 0 self.axis.wait_delay = 0 self.axis.enable_disable_x_pulse_count_replies = 1 self.axis.enable_disable_y_pulse_count_replies = 0 self.axis.enable_disable_z_pulse_count_replies = 0 self.axis.enable_disable_e_pulse_count_replies = 0 self.axis.pause_all_return_x_pulse_count = 0 self.axis.pause_all_return_y_pulse_count = 0 self.axis.pause_all_return_z_pulse_count = 0 self.axis.pause_all_return_e_pulse_count = 0
axis.send_command(axis.change_speed(x)) # Check for both reply and complete responses to be returned wait_for_responses(xaxis, ["RI01QX*", "CI01QX*"], "") # Print the responses print(f"------- Speed changed to {new_rpm} - command responses -------") xaxis.parse_responses(resps) steps_per_rev = int(input("How many steps per revolution [1600]? ") or "1600") direction = 0 # Forward rpm = 300 # Start RPM pulse_count = 4294967295 # Set to max so we can start and stop it when desired xaxis = Axis("X", command_id=1, serial_device="/dev/ttyS0") xaxis.debug = True # Setup the axis with values to start the motor frequency = xaxis.rpm_to_frequency(rpm=rpm, steps_per_rev=steps_per_rev, round_digits=3) set_axis_cmd = xaxis.set_axis(frequency=frequency, pulse_count=pulse_count, direction=direction, start_ramp=1, finish_ramp=1, ramp_divide=100, ramp_pause=10, enable_line_polarity=1) xaxis.send_command(set_axis_cmd) # Get the responses - look for both responses to be returned before continuing wait_for_responses(xaxis, ["RI01CX*", "CI01CX*"], "------- Set axis command responses -------") # Start the motor xaxis.send_command(xaxis.start()) # Check for both reply and complete responses to be returned wait_for_responses(xaxis, ["RI01SX*"], "------- Start command responses -------")
""" This just stops the motor in case a bug is encountered leaving the motor running. """ from pthat.pthat import Axis xaxis = Axis("X", test_mode=True) rpm = int(input("Enter RPM to calculate: ")) ramp_up_speed = int(input("Enter ramp up speed: ")) steps_per_rev = int(input("Enter the steps per revolution: ")) frequency = xaxis.rpm_to_frequency(rpm=rpm, steps_per_rev=steps_per_rev, round_digits=3) if ramp_up_speed == 0: ramp_up_freq = frequency else: ramp_up_freq = frequency / ramp_up_speed ramp_up_rpm = xaxis.frequency_to_rpm(frequency=ramp_up_freq, steps_per_rev=steps_per_rev) print(f"Ramp up: {ramp_up_freq} Hz = {ramp_up_rpm} RPM")