working mpc with L293D motor driver

This commit is contained in:
Simon Pirkelmann 2019-06-26 11:36:54 +02:00
parent 2711373d44
commit 7d69c91752
2 changed files with 3 additions and 3 deletions

View File

@ -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:

View File

@ -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 --------