Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #from sys import argv
- #functions
- def deltaX(a,b):
- return .5*(a+b)
- def deltaY(a,b):
- return .5*(a-b)
- def deltaA(x,y):
- return x+y
- def deltaB(x,y):
- return x-y
- def trunc(f,n):
- '''Truncates/pads a float f to n decimal places without rounding'''
- slen = len('%.*f' % (n, f))
- return str(f)[:slen]
- ##########
- ##########
- #constants
- diametre = int(raw_input('What is the pully diametre? '))
- steps = int(raw_input('How many steps (including micro)? '))
- pi = 3.14159
- ##########
- ##########
- #math
- circ = diametre*pi
- steps_per_deg = steps/360
- mm_per_deg = circ/360
- mm_step = mm_per_deg/steps_per_deg
- step_mm = steps_per_deg/mm_per_deg
- ##########
- ##########
- a = int(raw_input('What is new position Delta A? '))
- b = int(raw_input('What is new position Delta B? '))
- #math with functions
- pos_x = deltaX(a,b)
- pos_y = deltaY(a,b)
- pos_a = deltaA(pos_x,pos_y)
- pos_b = deltaB(pos_x,pos_y)
- motora = step_mm * pos_a
- print("""
- New Position dX = %s
- New Position dY = %s
- New Position dA = %s
- Motor moves %s steps
- New Position dB = %s
- """ % (pos_x,pos_y,pos_a,trunc(motora,0),pos_b))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement