Digital Potentiometer Adapter

Sick of using resistive potboxes? Read On. By Ian Hooper, February 2011



In some recent conversions undertaken at EV Works, the vehicles had "drive by wire" throttles - that is, hall effect accelerator pedals supplying throttle information to the engine management computer, which controlled the engine's throttle body via servo drive. The absence of any physical throttle cable makes it much more difficult to install a conventional potbox as the throttle for the motor controller.

Furthermore we had chosen to use Kelly KDH series motor controller, which only support 0-5KΩ resistive type throttles. Even if it were easy to install a 0-5KΩ potbox in this instance, I'm not a big fan of resistive potboxes due to the fact that they use potentiometers which often wear out and become unreliable in time. I've been a long time advocate of using hall effect throttles instead due to their reliability, even collaborating with a manufacturer to design a hall effect potbox back in 2010.

But in this case a different solution was needed. I was aware of devices known as digital potentiometers, which accept a digital input and output a physical resistance, but had never actually used them so was unsure if they could be applied in this instance. As it happens, they can.

Digital Potentiometer

Digital potentiometers act very much like a normal potentiometer on their output side, with three output pins simulating the two endpoints plus wiper of a potentiometer. Internally they use a resistive network with transistors switched to connect the wiper pin to various points in the network.

The digital potentiometer chosen was the Microchip MCP41010, actually a 10KΩ range (they don't make a 5K version) with 8-bit resolution i.e 256 steps, or 39Ω increments. Being that we'd only be using 0-5KΩ, our resolution would be 0-127, but I suspect that is still far greater than any human's throttle control!

The device takes a SPI (Serial Peripheral Interface) input over three pins CS, SCK and SI. Basically SPI requires an enable signal on CS, a clock signal on SCK, and a synchronised bitstream on SI. The SPI packets are 2 bytes long, the first being the command byte and the second being the desired output from 0-255.

This device is available in DIP8 and SOIC packages. Availability of a DIP package tends to make prototyping and hand-assembly easier, where the SOIC may be used for automated/volume production (if a design ever gets that far!)


Because the digital potentiometer requires a SPI input rather than an analog voltage as supplied by the factory hall effect pedal, and since some analog voltage translation was required (the hall effect pedal was actually giving a range of 0.5V-3.5V rather than the ideal 0-5V), a small microcontroller was used to interface between the two. I opted for an Atmel ATtiny13A, which is one of the smallest AVRs around! A good rule of thumb for microcontroller selection is to use the smallest one that can do the job required, and this application sure didn't need much.

Isolated Power Supply

The digital potentiometer's output pins are non-polarised, but due to its internal design their voltages are constrained to the voltage rails of its power supply.

Since we can't be sure what ground reference the controller uses for it's throttle inputs, we need to isolate the power supply to the digital potentiometer, and reference that ground to one of the two throttle wires.

Astute readers may realise that this does result in a polarised output, since internally a controller uses the throttle resistance as part of a voltage divider and hence one of the controller's throttle wires is more negative than the other. This isn't a big problem; if the device is plugged in backwards, the throttle remains benignly inactive.

Anyway, all that was required was a very small, isolated 5V-5V DC/DC converter. A readily available option is the XPiQ IE505S, a tiny 1W device. At about $10 these aren't cheap - no isolated DC/DCs are unfortunately - costing more than all the other components combined! I'm open to suggestions if anyone can think of a cheaper option.


Since the digital potentiometer is now running on an isolated power supply, we need to also opto-isolate the digital SPI signals between the microcontroller and digital pot. This is pretty simple to do using optocouplers. Fairchild MCT62 devices were chosen, being readily available, inexpensive, and perhaps most importantly I use them a lot and had some on hand.

Schematic and PCB design

By now you probably have an idea of what the circuit is going to look like, and it is pretty simple, but there are few additions to the above components. For the original application, the hall effect pedal already had a 5V power supply which we could hijack to run this device. However in many vehicles (e.g where we have to supply our own power to the hall effect throttle) there would only be a 12V supply handy, so I decided to include a 5V regulator on board and add a 12V input pin. As such the device can be run off either 12V or 5V, whichever is available.

A low pass RC filter with a corner frequency around 16Hz was added to the ADC (Analog to Digital Converter) input to insulate it against noise. The optocouplers needed some resistors for pull up / pull down services on each side. Within reason, lower resistor values speed up optocoupler switching. In this instance 1KΩ resistors seemed to work well (see oscilloscope screen captures in the Photo Gallery section further down).

The following schematic was created: (Click on the image to view a larger version)

And laying it up on a PCB as follows: (Note the two separate ground planes. It's good practice using ground planes in EMI noisy environments - and EVs definitely qualify there!)


The code was written in C, using AVR Studio 4 and the WinAVR GCC compiler. There's not much to it, the basic flow is to read the ADC voltage level from the hall effect pedal, do some translation/scaling of the number, then spit it out as an SPI stream to the digital potentiometer, and repeat ad infinitum.

It's a bit long to list here verbatim, but here's the C file: DigitalPotDriver.c (or scroll down for a link to download the full AVR Studio project).

Development Photo Gallery

(1) Development on prototype board

(2) Initial Schematic Pencil Scratchings

Results and Discussion

So far the device has been successfully tested with Kelly KDH series and CafeElectric Z1Ks, and it should also work with other controllers requiring a 2-wire 0-5kΩ resistive throttle such as Curtis, Alltrax, Logisystems, etc.

There is a possibility that the internal voltage divider used by some controllers with resistive throttles may exceed the 5V rails of the digital potentiometer, thus restricting the throttle range. However this is unlikely, as most modern motor controllers are based around digital microprocessors with 0-5V or 0-3.3V logic and ADC conversion.

So far we have installed one of these devices in four vehicles, in most cases tucked up in the footwell near the hall effect accelerator pedal, with the two throttle output wires going through the firewall to the controller. In one case the device was placed very close to the (Kelly) motor controller and it stopped working. Simply moving it about a foot away from the controller was enough for it to start working again. Presumably there is a lot of EMI switching noise from the controller interrupting communications. A metal case would probably remedy this situation, or just keeping the device away from the controller.

Another "gotcha" is that the minimum resistance of the digital pot appears to be about 60 Ω. For most controllers this isn't a problem; they usually have approximately a 10% deadband (~500Ω) at the bottom of travel. However on one Zilla tested, this 60 Ω was (surprisingly) above the High Pedal Lockout threshold. A rather dirty solution was implemented, using a normally closed relay across the throttle input, switched in parallel with the main contactor. It's dirty because it circumvents the high pedal lockout, which exists to prevent the car taking off unexpectedly on startup if there's a throttle fault, or if the pedal is stuck down. So the solution worked, but as one who prides himself on advocating safety in EVs, it's not something I would recommend!

Build It Yourself

If anyone wants to have a go building one themselves, I've made the schematic and PCB files available (created in Eagle, which is free from CadSoft), as well as the code (written in AVR Studio 4, which is also free from Atmel).

Click here to download it all in a ZIP file


There are no comments for this page yet.


Zero Emission Vehicles Australia © 2023 :: Terms and Conditions, Privacy Policy, Payments and Delivery, Warranty and Returns