Rotary Switch Resistor Ladder - turnracing/turnracing-diy GitHub Wiki

These are commonly used with Rotary Switches in order to connect its many pins to a single analogue input on your microcontroller.

They function by connecting identical resistors in series with each input connected in between, below is an example of how this should look for a 12 position rotary switch in a schematic, PCB and the code.

schematic_resistorladder

Note that the example uses a 12 position single pole rotary switch and therefore requires 11 resistors. It's recommended to use 1K Ohm resistors as they keep the voltage readings easy to work out.

Pin 1 of the rotary switch connects before the first resistor, leaving pin 12 to connect after the 11th resistor.

You then need to connect GND to pin 1 and VCC to pin 12 and COM to the common pin on the rotary switch.

Below is an example of a resistor ladder PCB,

pcb_resistorladder

These are then broken out to a header or connector, this creates a varying voltage reading that is readable through the common pin that is connected to a single analogue input on your microcontroller.

You will then need to convert this reading in your code to be read as 12 inputs (in this example).

The easiest way to utilise these is with an STM32 Blue Pill and FreeJoy,

See FreeJoy

See Axis to Buttons

To use this with other microcontrollers you will need to create your own code - this will be covered in detail in the future.

What you need to do is work out what the value range will be for each rotary position. To work this out you need to...

(current value)/(analog resolution)*(number of positions)

Remember that you need one less resistor to the number of positions, ie.

  • 12 positions, 11 resistors
  • 11 positions, 10 resistors
  • 10 positions, 9 resistors...