6

I'm designing a switched-mode power supply. I need to give my users the ability to set a voltage setpoint, with a range of approximately 200-800V, and at least 4V of resolution. This needs to be a hardware solution that feeds into my microcontroller. Cheap and simple and hard for the user to screw up are the goals. My predecessors have used potentiometers, which make it impossible to know what you've actually set without running the system. I don't have a display to work with, just a couple blinky lights. Not really the most effective way to identify a voltage like this.

I'm thinking of using rotary switches. Three rotary switches, and an appropriate combination of resistors, should let me translate the setting of the switches to an analog voltage. In my ideal world, 000 translates to no voltage, 999 translates to 3.3V, and every setting in between scales linearly. Alternately, I could use twelve digital inputs to read the same information, but I'll need an I/O expander for that.

I'm sure I'm not the first person to consider something like this. Is there a canonical way of doing this? If I go the analog route, how many resistors am I going to need? How many different values? Or is there an obviously better way to address this problem?

Stephen Collings
  • 17,373
  • 17
  • 92
  • 180
  • 1
    What an interesting question... On the edge between EE and UI design. – Dzarda Jan 29 '14 at 17:08
  • 2
    You need to think very carefully about what happens if the user moves the switch while the supply is turned on, whether the switches are make-before-break or break-before-make. – Joe Hass Jan 29 '14 at 17:38
  • 1
    @JoeHass the switches would only be read once, at power-on, so no concerns about them changing at run-time. – Stephen Collings Jan 29 '14 at 17:47

3 Answers3

2

If you wire all three switches to give a single analog output, you require 0.1% resolution. Since common precision resistors are 1%, and ADCs typically have a couple of counts of uncertaintly, I don't think this technique is practical.

However, if you wire each switch independently to an ADC input, with resistors selected to give evenly spaced voltages, it would be much easier to get reliable readings, and would even work with 5% resistors.

You could use three ADC inputs, or a single ADC with analog switches to read the input switches one at a time.

Peter Bennett
  • 57,014
  • 1
  • 48
  • 127
2

This is a very non-linear problem. Rather than solve it directly, I've brute-forced it with a spreadsheet. I assumed a BCD rotary switch wired as below, and manipulated the ratios of the involved resistors until I got the most linear solution. Then I took those values and found the most easily available 1% resistors that matched. The below is R^2=.9989.

schematic

simulate this circuit – Schematic created using CircuitLab

As Peter Bennett rightly points out, trying to multiplex three of these switches into a single A/D pin with an adding op-amp would require .1% resistors, which probably puts me into SMT-world. Probably not a jump I want to make on this particular project. If you just have one of these switches, and three A/D pins, 5% resistors are fine. Best values I've found there give R^2=.9984:

  • R1: 75k

  • R2: 39k

  • R3: 20k

  • R4: 9.1k

  • R5: 1.5k

Stephen Collings
  • 17,373
  • 17
  • 92
  • 180
0

If you have 2P10T rotary switches, there's a fairly straightforward hookup you can use that requires only two different resistor values. And if you really want to build it with just a single resistor value, you can construct R12 and R24 this way.

schematic

simulate this circuit – Schematic created using CircuitLab

For the "hundreds" and "tens" stages, there are twelve taps associated with the string of 11 resistors, but each of the two switch poles (represented by the ganged arrowheads) can only connect to 10 of them. For the "units" stage, only 10 resistors and a single pole of the switch are required.

Note that the middle stage can be replicated if you want additional decades of resolution.

Note also that the "units" stage could be replaced by a simple 100K potentiometer for continuous rather than stepwise adjustment.

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393