T-Bot: drawing diagonal lines December 18, 2018 05:11PM |
Registered: 5 years ago Posts: 2 |
# Maximum speed STEP_PER_SECOND = 100 def doLine(dX, dY): # Coords dX = 400 dY = 300 # Coordinates to motor absolute position dY = -dY a_pos = dX + dY b_pos = dX - dY print("A_POS:", a_pos, "B_POS:", b_pos) a_pos_temp = abs(a_pos) b_pos_temp = abs(b_pos) a_spd = STEP_PER_SECOND b_spd = STEP_PER_SECOND if (a_pos_temp > b_pos_temp): b_spd = round(abs(STEP_PER_SECOND * (b_pos_temp / a_pos_temp))) elif (a_pos_temp < b_pos_temp): a_spd = round(abs(STEP_PER_SECOND * (a_pos_temp / b_pos_temp))) print("A_SPD:", a_spd, "B_SPD:", b_spd) MOTOR[0].setMaxSpeed(SE.steps_to_maxspeed(a_spd)) MOTOR[1].setMaxSpeed(SE.steps_to_maxspeed(b_spd)) # Move stepper MOTOR if (a_pos < 0): MOTOR[0].Move(SE.REV, -a_pos) else: MOTOR[0].Move(SE.FWD, a_pos) if (b_pos < 0): MOTOR[1].Move(SE.REV, -b_pos) else: MOTOR[1].Move(SE.FWD, b_pos) while (GPIO.input(SE.MTR0_BUSY) != 1) or (GPIO.input(SE.MTR3_BUSY) != 1): pass
Re: T-Bot: drawing diagonal lines December 18, 2018 11:20PM |
Registered: 9 years ago Posts: 5,232 |
Re: T-Bot: drawing diagonal lines December 29, 2018 06:05AM |
Registered: 5 years ago Posts: 2 |
Re: T-Bot: drawing diagonal lines December 30, 2018 02:45AM |
Registered: 9 years ago Posts: 5,232 |