Current chapter 11
This commit is contained in:
@@ -26,7 +26,7 @@ class SpeedController:
|
||||
current_ticks = self.encoder.read()
|
||||
speed_in_ticks = (current_ticks - self.last_ticks) / dt
|
||||
self.last_ticks = current_ticks
|
||||
self.actual_speed = robot.ticks_to_mm(speed_in_ticks) / 1000
|
||||
self.actual_speed = robot.ticks_to_m * speed_in_ticks
|
||||
# calculate the error
|
||||
error = (Settings.speed * Settings.motors_enabled) - self.actual_speed
|
||||
# calculate the control signal
|
||||
|
||||
@@ -13,10 +13,7 @@ wheel_circumference_mm = math.pi * wheel_diameter_mm
|
||||
gear_ratio = 298
|
||||
encoder_poles = 28
|
||||
ticks_per_revolution = encoder_poles * gear_ratio
|
||||
ticks_to_mm_const = wheel_circumference_mm / ticks_per_revolution
|
||||
|
||||
def ticks_to_mm(ticks):
|
||||
return ticks_to_mm_const * ticks
|
||||
ticks_to_m = (wheel_circumference_mm / ticks_per_revolution) / 1000
|
||||
|
||||
motor_A2 = pwmio.PWMOut(board.GP17, frequency=100)
|
||||
motor_A1 = pwmio.PWMOut(board.GP16, frequency=100)
|
||||
|
||||
Reference in New Issue
Block a user