def north(stepsTakenAzi, stepsTakenAlt): stepsToTakeAzi = 1472 - stepsTakenAzi if stepsToTakeAzi < 0: stepperAzi.clockwise(5, abs(stepsToTakeAzi)) else: stepperAzi.counterclockwise(5, abs(stepsToTakeAzi)) stepsToTakeAlt = 128 - stepsTakenAlt if stepsToTakeAlt > 0: stepperAlt.counterclockwise(5, abs(stepsToTakeAlt)) else: stepperAlt.clockwise(5, abs(stepsToTakeAlt))
def north(stepsTakenAzi, stepsTakenAlt): stepsToTakeAzi = 1472 - stepsTakenAzi if stepsToTakeAzi < 0: stepperAzi.clockwise(5, abs(stepsToTakeAzi)) else: stepperAzi.counterclockwise(5, abs(stepsToTakeAzi)) stepsToTakeAlt = 128 - stepsTakenAlt if stepsToTakeAlt > 0: stepperAlt.counterclockwise(5, abs(stepsToTakeAlt)) else: stepperAlt.clockwise(5, abs(stepsToTakeAlt)) shelfDirection['Alt'] = 90 shelfDirection['Azi'] = 0 shelfDirection.close()
while True: moon = ephem.Moon(gatech) #All angles returned are in radians! moonAzi = round(moon.az * degrees_per_radian,2) moonAlt = round(moon.alt * degrees_per_radian,2) #Stepper stepsAzimuth = math.floor((moonAzi/360)*stepsPerRev*2.875) stepsToTakeAzi= stepsAzimuth - stepsTakenAzi stepsTakenAzi = stepsTakenAzi + stepsToTakeAzi if stepsToTakeAzi < 0: stepperAzi.clockwise(5,abs(stepsToTakeAzi)) else: stepperAzi.counterclockwise(5,abs(stepsToTakeAzi)) augmentedAlt = moonAlt+90 #Makes sure you don't have to work with negatives stepsToTakeAlt = math.floor((augmentedAlt/180)*256 - stepsTakenAlt) #Altitude percentage times step raange stepsTakenAlt = stepsTakenAlt + stepsToTakeAlt if stepsToTakeAlt > 0:#Moves stepper altitude stepperAlt.counterclockwise(5,abs(stepsToTakeAlt)) else: stepperAlt.clockwise(5,abs(stepsToTakeAlt)) #Print in Python Shell print('Moon: altitude: %4.1f deg azimuth: %5.1f deg' %(moonAlt , moonAzi) ,gatech.date,'stepsTakenAzi: %4.1f stepsToTakeAzi: %4.1F ' %(stepsTakenAzi,stepsToTakeAzi) ,'stepsTakeAlt: %4.1f stepsToTakeAlt: %5.1f' %(stepsTakenAlt,stepsToTakeAlt))