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 @
f08f5ca4
...
@@ -112,21 +112,23 @@ public class PIDCarController {
...
@@ -112,21 +112,23 @@ public class PIDCarController {
LCD.clear();
LCD.clear();
LCD.drawString("Light: ", 0, 2);
LCD.drawString("Light: ", 0, 2);
LCD.drawString("Error: ", 0, 3);
LCD.drawString("Turn: ", 0, 4);
LCD.drawString("Turn: ", 0, 4);
LCD.drawString("PowerA: ", 0, 5);
LCD.drawString("PowerA: ", 0, 5);
LCD.drawString("PowerC: ", 0, 6);
LCD.drawString("PowerC: ", 0, 6);
while (! Button.ESCAPE.isDown())
while (! Button.ESCAPE.isDown())
{
{
LCD.drawInt(LightValue,4,10,2);
LCD.drawInt(LightValue,4,10,2);
LCD.drawInt(error,4,10,3);
LCD.drawInt(error,4,10,3);
LCD.refresh();
LCD.refresh();
int LightValue = light.readValue();
int LightValue = light.readValue();
error = LightValue - offset;
//calculates the error by subtracting the offset
error = LightValue - offset;
//calculates the derivative by subtracting the current error with the last error
derivative = error - lastError ;
derivative = error - lastError ;
// To avoid wind up and high integral value, we reset it to zero if the error equals
// To avoid wind up and high integral value, we reset it to zero if the error equals
...
...
...
...