K values

We could use the heading and distance values measured by IR 1 to directly control the steering for the tank. However, this is not ideal. Instead, we need to multiply each of these values in order to scale them so that the resulting corrections fit better with the possible range of the hardware. The factor by which a measurement is multiplied is called a value.

Most proportional feedback loops use a k value. In this part of the program, we will use two: the first (k1) will multiply the measured beacon heading to control the magnitude of the steering, and the other (k2) will multiply the measured distance to control the speed.

The optimal value for kis 5. The optimal value for kis 10kis set so that for any distance value greater than 10, the resulting power level of the drive motors will be greater than 100%. Not to worry, because the EV3 will simply run the motors at 100% power whenever it sees a value that is larger. kis set this way because the tank should only slow down if the beacon is very close; the tank will drive at full power to follow the beacon unless the distance to the beacon is less than 10.

values are arbitrary numbers, meaning they can be adjusted to suit the wishes of the programmer or the constraints of the hardware. A larger value will mean the robot makes larger corrections relative to the measured error; a smaller value would mean the robot makes smaller adjustments. Try experimenting with different values to modify the performance of the tank and see whether you prefer a different than the ones suggested here. 

To incorporate these values into the program, add a math block after the new sensor block and set its mode to multiply. Drag a data wire from the heading output of the sensor block and plug it into the input a of the math block. In the b input, enter a value of 5, the value we set for k1.

These data wires are yellow, which indicates that the data type is numerical. As the name implies, these data types deal with some kind of number value.

Take out a second math block and set its mode to multiply as well. Place it after the first multiplication block. Drag out a data wire from the proximity output of the IR sensor block and plug it into the a input of the math block. Enter 10, the value we set for k2, into the b input of the math block.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.202.187