Joysticks

Joysticks are fairly simple in principal. There's plenty of information about them on the web, and I shan't duplicate it all here. What I would like to do is just take a closer look at them, and discuss the real-world problems they have in practice.

The classic Arcade joystick

This uses the stick to close switches according to the direction. This is trivial to implement, but not suited to fine control.

The classic PC joystick

This uses the stick to adjust two variable resistors. Minimum resistance (zero) when the stick is top left, maximum when bottom right. These then form the R parts of RC monostables to generate pulses whose duration is directly proportional to resistance. The processor checks the time at the rising and falling edges, and the difference is proportional to the position of the stick.

Practical problems

In the real world, resistors and capacitors are imperfect. The cheap potentiometers and capacitors in typical joysticks and games ports are more so than most. Fixed resistors are typically 1% tolerance, variable resistors are typically 20% tolerance. Therefore there is little point in manufacturers paying for high-tolerance capacitors. They just use cheap ceramic caps, typically 10% tolerance.

The poor tolerance is usually countered by a calibration procedure where the user is asked to move the joystick to the extreme positions so that the processor can apply scaling factors to suit.

Another problem is that the processor has to watch the pulse for the entire length of the pulse. Assuming this is one or two milliseconds, it is not much for a one-off measurement. But if you want the joysticks position for every video frame (20 milliseconds or less), then it is a significant fraction (about a tenth) of the processor time.

Practical values

Most web pages concur that the resistances range from 0 to 100K. However, typical joysticks have an angular range of 60 degrees. Typical potentiometers have an angular range of 270 or 300 degrees. So you would actually order pots between 450K and 500K, then mount them so that only the first 60 degrees are used.

Applications

A typical application is a computer game. In this case, the simple RC timing system is okay because the computer can apply adjustments using software.

A more demanding application is radio-control systems. Nowadays these have microcontrollers, but before that they had to do without. It is a testament to early radio-control pioneers like Micron that they managed to implement a very practical system without any silicon chips at all!

Each servo channel expects a width-modulated pulse varying from 1 to 2 milliseconds, at about 20 ms interval. Radio control systems send the pulses sequentially, with a longer synchronisation pulse to identify the frame.

Potential solutions

Although potentiometer tolerance is pretty bad, the linearity is much better - typically 1%. So if you connected either end of the potentiometer to GND and VCC, the wiper voltage would be within 1% of half VCC at the mid rotation - whatever the absolute end-to-end value.

This now demands a way of measuring voltage rather than resistance. An A to D converter is more expensive than a 555 timer. One way round this is to have a compare the axis voltage with a ramp waveform. The comparator ouput will be a pulse length proportional to axis voltage.

One can generate a ramp by feeding a constant current into a capacitor. However we still have the problem that a cheap ceramic capacitor is typically 10 or 20% tolerance. Medium-cost caps are typically 5% tolerance. If you have several axes you can save money by using one expensive close tolerance capacitor for each axis in turn.

Another way to create a ramp is to use a counter driving a DAC. A DAC is usually cheaper than an ADC.

  5V  
  |  
00-10K 500K <--- Vcontrol (1V5 +/- 0V5)
10-20K
20-30K
30-40K
40-50K
  |  
  GND  

Adjustability (trimming)

The main axis adjustment is the 'centre' setting. This can be done by adding a parallel potentiometer. Adjustment is typically about a tenth of the range, so one can either use a trim pot that is ten times larger resistance, or add a resistor between the two wipers.

The other axis adjustment is the 'throw'. This varies the range of the stick control. You can do this with an op-amp circuit but it is much simpler to use the circuit below. This uses another parallel pot to reduce the voltage across the main pot. Notice the extra fixed resistors. These are essential so that the 'throw' pot cannot short VCC to GND.

VCC --- 10K -+- 100K(main) -+- 10K --- GND
        | +--- -(- --- --- --- ---> V control
        -+- 100K(throw) -+-        
  5V  
  |  
  10K  
00-10K 100K   100K <--- Vcontrol (1V5 +/- slightly less than 0V5)
10-20K
20-30K
30-40K
40-50K
  10K  
|
  GND  

Trimming can be done with linear sliders. These are not limited by angle, so you would order 100K sliders. These are used as variable resistors. As their resistance falls, so does the voltage span across the main pot.

In practice, trimming is usually done by a mechanical linkage that rotates the body of the pot with respect to the rotor. This is is cheaper than the extra pot method, and it is easy for joystick manufacturers to do.

Cost

It is worth noting that cost can vary a lot. A single pair of carbon-track pots are cheapest. If you have pots to adjust the throw and trim of each axis, then this triples the cost. Cermet- or plastic-track pots are harder wearing, but are only worth the extra cost if the joystick is heavily used. The position control pots get the most wear, while the adjustment pots are operated less often. Comparative costs:

265° electrical 295° mechanical (RS 410-413, linear conductive plastic, £2.00 plus VAT)
270° electrical 300° mechanical (RS 168 314, linear cermet, £4.48 plus VAT)

It looks like carbon-track pots tend to go up to 100k, while cermet pots tend to go upt to 1M.

Voltage-based control can use a wide range of resistance values.

Future

In 2004, I upgraded to a laptop PC. This has no RS232 or joystick ports. The market trend is toward USB as a common interface for PC peripherals. It will become increasingly harder to find non-USB joysticks as time goes by.