Rack and Pinion Steering

I bought the Advanced Gear Kits and built rack and pinion steering system for my car that I built. I tried to use the servo module but it didn’t turn the front wheels all the way to left and right. I switched to a motor module but the motor kept on running after turning the front wheels all the way to left and right. I need to put limit switches on the steering system so that power to the motor is cut off after turning the front wheels all the way to left and right. How do I write a program for using the R/C transmitter and limit switches to control the motor?

Presumably You have the programming kit. Here is a real simple outline of what you need to do: if the left limit switch is pressed then stop the motor reverse the motor until the limit switch is not pressed. Repeat the same thing for the right side. If you simply tell it to stop the motor then you won’t be able to turn the other way.

I have the programming kit. What about the optical shaft encoder?

I guess you could use that. The code would be much harder? In order to use that you would likely have to use the digital control buttons on the back of the controller. This means you would have a fixed distance you could turn either left or right. Your code would have to recognize that a button was pressed and then turn on the motor until it had truned far enough, as sensed by the shaft encoder. Then when the button was released turn the same amount of turns back. It could work but I don’t think it would be advisable. Wait and see what others say.

limit switches would be much easier than an optical shaft encoder. here is a sample code that should work:


while 1
  RCcontrol();
  limit_left == GETDigitalIO(<left sensor port>)
  limit_right == GETDigitalIO(<right sensor port>)
  while limit_right = 0 (pressed)
    PWMcontrol(<motorport>, 177) turn motor in opposite direction
    limit_right == GETDigitalIO(<right sensor port>)
  end
  while limit_left = 0 (pressed)
    PWMcontrol(<motorport>, 77) turn motor in opposite direction
    limit_left == GETDigitalIO(<left sensor port>)
  end
end

I’m surprised to find out that the optical shaft encoder doesn’t work the way that I expected it to work:

Turn shaft one way and the number should increase.
Turn shaft other way and the number should decrease.

The number just increases no matter which way I turn the shaft using the encoder test program.

I have to figure out how to install the limit switches so that they don’t interfere with the steering system except for the metal levers mounted on the limit switches.

I used a 36-tooth gear instead of a 12-tooth gear and got the front wheels to turn all the way to left or right without using any sensors. There are 24-tooth gears but they’re made for worm gears.

If you have the programming skills i would recoment using a potentiometer. I have used one with some of my vex stuff before and they work great. You should be able to find a 100k ohm pot at radioshack and if you have a spare pwm cable floating around you could wire to pot up to your controller. Then you can drill out a gear to the size of the knob on the pot and mount that to your steering setup. Personally i made a custom “pot module” that is just two 36 tooth gears sandwiched between two peices of 1 square by 6 square bar. One of the gears and the metal was drilled out fit the pot and i used a bit of hot glue to secure it all.

thefro526, How do you program the pot. I think that the values of a pot go from 0 to 225 and the center position of the pot would be 127.

It should be a 10 Bit Ananlog to Digital (A to D) conversion, giving a digital value of 0 to 1023 for the analog value of 0 to 10,000 (10K) ohms.

There is usually a “deadband”, which will result in no changes in the Digital Value at one end or the other of the “sweep”, on the pot…

I’m currently working on a rack and pinion steering setup myself. The way i plan to do it i’m going to have a 2 wire motor with a built in encoder. I’m planning to have my friend program it so when the joystick is left it will continue spinning left untill it has reached a certian point then stop even if the joystick is still pressed same for steering to the right. i will have to mess around with the values to figure out how far i want the wheels to be able to turn i will post the code after its done along with some pics.