steering wheel help FIRST Team 2044

I need help. I’m trying to take a steering wheel (w/o the pedals) and using a chicklet. I want the steering wheel to turn the robot 180 degrees left when the wheel is turned 180 degrees left. So for the right side. But not more than 180 degrees in any direction. The robot is a three-wheel design with two wheels being powered. I want the wheel to turn the robot in a tank form one wheel going one direction and the other going the other direction. Also I want to have a separate joystick next to the wheel to use only with the y-axis and control the forward and backward speed of the robot. I’m sorry if this may seem confusing but any insight on how to fix the problem will be greatly appreciated.

There are a number of ways to work this. Here is one solution:

  1. Install a gyro to give you heading.
  2. Does your wheel really turn 180 degrees? No matter, moving it from neutral to full right or left will give you a value of 127 to 254, or 127 to 0. so you need to convert from the PWM value to degrees which will give a ratio of 127/180.
  3. Now that your program knows what heading the steering wheel wants, put in a simple proportional control to turn to that heading (pseudo code):
    error = (currentHeading - wheelHeading);
    drive (RightSide-error/2, LeftSide+error/2);

As a first approximation this should work, but probably not very well. You wil have to fiddle with it and acount for gyro drift etc. to get it working well.

Actually, your post IS a bit confusing, but starting with the last question first, Speed as in forward or backwards is simply a function of the p1y axis on port 1. a joystick plugged into port 1 will automatically take on this role when using the default code and PWM13 - 16. ( this sounds a lot like a throttle BTW)
The trick comes with the wheel part. A car wheel turns the car as long as it is turned and in a rate proportional to the amount of turn. If that’s all you want, again, it’s done with the default code. but if you want the wheel controlling the X direction and Y the joystick controlling the Y (forward/backward/speed) you need to have the User_routine.c remap the values you want here:

/*---------- 1 Joystick Drive ----------------------------------------------
  *  This code mixes the Y and X axis on Port 1 to allow one joystick drive. 
  *  Joystick forward  = Robot forward
  *  Joystick backward = Robot backward
  *  Joystick right    = Robot rotates right
  *  Joystick left     = Robot rotates left
  *  Connect the right drive motors to PWM13 and/or PWM14 on the RC.
  *  Connect the left  drive motors to PWM15 and/or PWM16 on the RC.
  p1_x = 255 - p1_y;
  p1_y = 255 - pwm05;

  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

Where it says:
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;


  *   This maps the joystick axes to specific PWM outputs.
  pwm01 = p1_y;
  pwm02 = p2_y;   
  pwm03 = p3_y;   
  pwm04 = p4_y;   
  pwm05 = p1_x;  
  pwm06 = p2_x;   
  pwm07 = p3_x;   
  pwm08 = p4_x;   
  pwm09 = p1_wheel;
  pwm10 = p2_wheel;   
  pwm11 = p3_wheel;   
  pwm12 = p4_wheel;   

If you plug the joystick in port1 and the wheel in port 2 then something like:

p1_x = 255 - p1_y;
p1_y = 255 - pwm06;

not sure this is what you’re asking but hope it at least helps.


668 has used a couple of steering wheels, and neither returned the full 0-255 range, we had to scale the output accordingly. To see what your steering wheel returns, add this to your code:

static int debug0_count=0;

// print every ~25 loops to avoid drowning in output. Adjust the constant
// for whatever rate you want:

if (debug0_count++ >= 25)
{ printf("JS1 parms: %3d %3d %3d %3d %d %d %d %d


This code fragment prints every parm you can get from a joystick port. Of course, if you don’t have the wheel plugged into Port 1, change “p1_” accordingly.

You can find all the joystick parms listed in the file ifi_aliases.h.