motor test

This commit is contained in:
Bernd Reuther 2021-03-04 15:53:26 +01:00
parent 2ad88bf305
commit 1d9d50d853
2 changed files with 16 additions and 11 deletions

View File

@ -81,17 +81,14 @@ def action(changePin, action):
return render_template('main.html', **templateData)
@kamera_server.route("/motor1_test")
def motor_test():
#m2.pwm4.ChangeFrequency(freq_halten)
m1.stop()
m1.start()
m1.vorwaerts(10)
time.sleep(2)
m1.rueckwaerts(10)
#print('Motortest')
# Pass the template data into the template main.html and return it to the user
return 'fertig'
@kamera_server.route("/<motor>/<position>")
def motor_test(motor, position):
if motor == "drehen":
m1.stop()
m1.start()
m1.gehe_zu(int(position))
return 'Drehen: ' + m1.pos
if __name__ == "__main__":
kamera_server.run(host='0.0.0.0')

View File

@ -137,6 +137,14 @@ class motor():
self.rueckwaerts(self.schritte_max, 1)
self.pos = 0
def gehe_zu(self, position):
temp_schritte = int(position) - self.pos
if temp_schritte > 0:
self.vorwaerts(temp_schritte)
else:
self.rueckwaerts(temp_schritte)
def einzelschritt(spule, status, ges_schritte, schritt, t1, t2):
w = (schritt * 100 / (ges_schritte - 1)) * 1.8
s = round(math.sin(math.radians(w)), 2)