... | @@ -75,4 +75,19 @@ The function takes the overall travel distance and divide it by the the speed of |
... | @@ -75,4 +75,19 @@ The function takes the overall travel distance and divide it by the the speed of |
|
|
|
|
|
The calculation reveals a physical limitation to how frequent readings can be made. The sampling rate between each reading cannot be lower than this number. Eg. If we want to measure a distance of 255 cm we can’t conduct more than one reading pr 14.98 ms.
|
|
The calculation reveals a physical limitation to how frequent readings can be made. The sampling rate between each reading cannot be lower than this number. Eg. If we want to measure a distance of 255 cm we can’t conduct more than one reading pr 14.98 ms.
|
|
|
|
|
|
In exercise 2 we measured with a sampling rate of only 1ms. According to our calculation we should not have been able to get a reading. But after the lecture in week 4, we were informed that a buffer of 30ms is already integrated in the getDistance() method. This means our delay of 1ms would add to the 30ms and thus we were able to get a reading. |
|
In exercise 2 we measured with a sampling rate of only 1ms. According to our calculation we should not have been able to get a reading. But after the lecture in week 4, we were informed that a buffer of 30ms is already integrated in the getDistance() method. This means our delay of 1ms would add to the 30ms and thus we were able to get a reading.
|
|
\ No newline at end of file |
|
|
|
|
|
## Exercise 4
|
|
|
|
|
|
|
|
**Task:**
|
|
|
|
To run the trackerTester program and note the robot's behaviour and explain how the robot is controlled as a PID.
|
|
|
|
|
|
|
|
**Results:**
|
|
|
|
When running the TrackerTester program the robot is placed in front of a wall. The robot will move towards the wall until a certain threshold is reached. In the Tracker class we can see the threshold is set to 35cm under the desiredDistance variable. If the robot exceeds the threshold and comes too close to the wall it will reverse until it reaches the desiredDistance.
|
|
|
|
|
|
|
|
![IMG_7767](http://gitlab.au.dk/uploads/group-22/lego/e08113a595/IMG_7767.JPG)
|
|
|
|
Fig. 2 - Robot at desired distance
|
|
|
|
|
|
|
|
From looking at the code the Tracker class appears to have implemented a PID controller. Power is equal to the proportional term, where Pgain is set to 2.0 and error is the measured distance from the wall subtracted by the desiredDistance.
|
|
|
|
|
|
|
|
As described above the error is equal to the measured distance from the wall subtracted by the desiredDistance. According to referance 4 in the Lab Lesson plan (http://en.wikipedia.org/wiki/PID_controller#Set_Point_step_change) the error is equal to SP-PV. We can thus conclude that the setpoint (SP) is the distance from the wall (distance) and the process variable (PV) is the desiredDistance which is set to 35. The manipulated variable (MV) is the value calculated by the PID controller. In this case this is equal to the power variable. The power is then sent to the motor determining how fast the robot should move away or towards the wall. |
|
|
|
\ No newline at end of file |