hov havde ikke gemt authored by Steffan Lildholdt's avatar Steffan Lildholdt
......@@ -61,12 +61,22 @@ The program for this exercise implements a standard PID controller in the follow
// Apply the PID regulation
controlledValue = (kp * error) + (ki * integral) + (kd * derivative);
controlSignal(controlledValue);
lastError = error;
Delay.msDelay(dt);
````
where the function controlSignal controls the power of the two motors in the following way
```java
protected void controlSignal(float controlledValue) {
leftMotor.controlMotor((int)(Tp + controlledValue),1);
rightMotor.controlMotor((int)(Tp - controlledValue),1);
}
````
In order to avoid a bang-bang control mechanism the two motors are applied a standard power `Tp`.
The control algorithm is wrapped in an LeJOS NXT application that is able to communicate with a PC running a LeJOS GUI application letting us choose values for `kp`,`ki`,`kd` and `Tp` remotely. Due to the complexity of the physical world many factors affect the controlling of the Lego car and it is therefore beneficial to modify control parameters on the fly.
### Exercise 6, Color Sensor
......
......