Current chapter 11

This commit is contained in:
Danny Staple
2022-09-11 20:26:45 +01:00
parent df1d67e42d
commit 3c47ff9874
10 changed files with 30 additions and 41 deletions
+1 -1
View File
@@ -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
+1 -4
View File
@@ -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)