From 7d69c91752ece5f0f4eca7ac5bf0c4edeffa6a33 Mon Sep 17 00:00:00 2001 From: spirkelmann Date: Wed, 26 Jun 2019 11:36:54 +0200 Subject: [PATCH] working mpc with L293D motor driver --- micropython_firmware/main.py | 4 ++-- remote_control/casadi_opt.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/micropython_firmware/main.py b/micropython_firmware/main.py index b949b4a..c66a392 100644 --- a/micropython_firmware/main.py +++ b/micropython_firmware/main.py @@ -12,7 +12,7 @@ class Motor: def __init__(self, enable, dir1, dir2): self.enable_pin = machine.Pin(enable, machine.Pin.OUT) self.enable_pwm = machine.PWM(self.enable_pin) - self.enable_pwm.freq(500) + self.enable_pwm.freq(250) self.dir1_pin = machine.Pin(dir1, machine.Pin.OUT) self.dir2_pin = machine.Pin(dir2, machine.Pin.OUT) @@ -33,7 +33,7 @@ class Motor: if self.direction: # switch direction if necessary self.reverse() # apply value as pwm signal - self.enable_pwm.duty(abs(value)*10) + self.enable_pwm.duty(int(abs(value)*10.23)) class Robot: diff --git a/remote_control/casadi_opt.py b/remote_control/casadi_opt.py index 4ff5abf..dccbb30 100644 --- a/remote_control/casadi_opt.py +++ b/remote_control/casadi_opt.py @@ -210,7 +210,7 @@ class OpenLoopSolver: # ---- path constraints ----------- # limit = lambda pos: 1-sin(2*pi*pos)/2 # self.opti.subject_to(speed<=limit(pos)) # track speed limit - maxcontrol = 0.5 + maxcontrol = 0.950 self.opti.subject_to(self.opti.bounded(-maxcontrol, self.U, maxcontrol)) # control is limited # ---- boundary conditions --------