Steering of FreeRover is done by means of a rack and pinion system. The rack is made out of 2 worm gears. The pinion is a 12 tooth gear that is connected to a NXT motor through a gear train. I want FreeRover to be symetrical. That is why the NXT motor is placed along the length axis of the car.
There are two things I need to know . First, what is the maximum amount of rotation the NXT motor can make (number of encoder ticks) without the pininion (wheel gear) loosing touch with the rack. And second, what is the angle of the front wheels given the amount of rotation of the steering motor.
The maximum rate of freedom of the steering rod with the 2 worm gears is about 2 studs from the center to either left or right. At its maximum the pinion (12 tooth gear) begins to loose touch with the rack (2 worm gears), beond this point the pinion does not have any contact with the rack and all control over the steering is lost. That is why I need to know how much I can make the NXT motor rotate. Let’s start with the rack. Each worm wheel has 5 teeth (the singel spiral makes 5 turns around the axis), so 5 teeth is the maximum for the rack. The pinion has 12 teeth. It’s maximum rotation is 5/12. The pinion is connected to a 20 teeth gear, it’s maximum is also 5/12. This gear is driven by a 12 tooth gear. The maximum rotation of this gear is 20/12* 5/12. From there on, I used only 24 tooth gears to the motor, these can be ignored. So the maximum rotation of the motor equals 20/12*5/12*360 = 250 encoder ticks. If the steering mechanism is pointing straight forward and I rotate the motor for 250 ticks it will be pointing full left (or right).
A nice tutorial about lego gears can be found here.
Based on this calculation I coded a function that takes an angle as input and drives the steering motor accordingly.
I also want to know what angle the wheels are making given a number of encoder ticks. The length of the steering arm is given (2 studs). The steering rod goes one stud sideways for each 125 encoder ticks of the steering wheel. This gives us the length of two sides of an imaginary triangle, the hypothenuse (2) and the opposite (encoderticks / 125). The angle of the steering wheel equals the arc sinus of encoders ticks / 250.
I made a function that returns the angle of the front wheels.