Changes
Page history
u4099 created page: Lesson4Week6
authored
Mar 10, 2015
by
Daniel Jung Moltzen
Show whitespace changes
Inline
Side-by-side
Lesson4Week6.markdown
View page @
fca23529
...
...
@@ -123,12 +123,13 @@ public class PIDCarController {
LCD.drawInt(error,4,10,3);
LCD.refresh();
// Current light reading
int LightValue = light.readValue();
//
c
alculates the error by subtracting the offset
//
C
alculates the error by subtracting the offset
error = LightValue - offset;
//
c
alculates the derivative by subtracting the current error with the last error
//
C
alculates the derivative by subtracting the current error with the last error
derivative = error - lastError ;
// To avoid wind up and high integral value, we reset it to zero if the error equals
...
...
@@ -138,7 +139,7 @@ public class PIDCarController {
integral= 0;
integral = integral + error; }
//
Here we c
alculate the value for the turn
//
C
alculate the value for the turn
turn = (int) ((Kp * error) + (Ki * integral) + (Kd * derivative));
// Instantiates the power for the two motors
...
...
...
...