Returning the steering to center

The final MyBlock is crucial to the car steering program. This MyBlock returns the steering mechanism to the center position regardless of what position it is currently in. This automatic return-to-center is a signature feature of the Falcon's programming.

This MyBlock starts by checking the position of the steering motor  A. To be more specific, it actually first checks to see if the motor is in the left position; if this check returns false, then it checks to see if the motor is in the right position. If this returns false too, then the steering is already centered and no action is necessary. 

The MyBlock first checks to see if the wheels are turned to the left (positive direction) by testing whether or not the degree value on motor  A is greater than positive three (+3) degrees. The programming for this check looks like this:

Setting the comparison value to 3 sets up a tolerance in the program, meaning that the MyBlock is satisfied when it brings the steering motor within three degrees in either direction of the center. You may wish to experiment with different tolerance levels; a smaller value would increase the precision of the steering, but could make it too sensitive. If you decide to change the tolerance, make sure that you change this value everywhere it appears.

If this check returns true, the wheels are currently steered left (positive direction), so the motor must rotate in the negative direction to bring the wheels back to the center. Within the true case of the switch, set up a loop (Motor Rotation | Compare | Degrees, < | 3, port A) and a medium motor block (On, -50 percent power, port A) such that it turns the steering motor to the right until it is within three degrees of the center:

If the false case of the switch executes, then the steering is not in the left position. The program will now use a similar procedure to check if the steering is in the right position. It measures the degree position using the motor encoder, checks to see if it is less than -3 degrees, and executes the corresponding case of a logic switch:

If this check returns true, then the wheels are currently steered right (negative direction), and the steering motor must turn in the positive direction to bring the wheels back to the center. Set up the loop (Motor Rotation | Compare | Degrees, > | -3, port A) and the medium motor block (On, 50 percent power, port A) in a similar manner to the way you set them up before. Since everything is in the opposite direction, you must negate all number values and flip the inequality sign:

If this second switch returns false, then the steering is in the center and does not need to be adjusted. Simply shut the motor Off:

Finally, use the MyBlock Builder to save this section of code as a MyBlock called steerReCenter.

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

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