Electrical – Digital Potentiometer controlling DC motor speed problem: voltage won’t step properly

digital potentiometermotorraspberry pi

I'm building a rheometer to measure the viscosity of liquids. I'm using a 4.5-10v DC motor which needs to be accurately controlled by a Raspberry Pi (the speed and torque must scale, so PWM is out).

The circuit

I have been trying to control the motor with a 10k digital pot (MCP4131) in a voltage divider with a transistor to control the voltage through the motor.

In theory, the voltage should (as the pot sweeps through its range, 129 steps) vary between ~2.6v and ~10.5v.

In practice, the voltage only varies between ~7v to ~5v, reaching its minimum after only ~25 steps and then staying constant for the remaining 100 or so steps.

What is going wrong? Is there a better way of doing this?

This has been the bane of my life the last few weeks, any help would be greatly appreciated. If anything is unclear I will clarify as best I can.

EDIT: MCP3141 -> MCP4131

Best Answer

The main problem is you are trying to control a voltage of up to 10.5V with a digital pot that can only handle 5.5V. The MCP4131 datasheet doesn't make it very clear, but the pot only works properly when its terminal voltages stay within the supply rails (Vss to Vdd). If they go outside this range then internal protection diodes will attempt to clamp the voltages to Vss or Vdd.

Another potential problem is that the pot's output voltage drops as more current is drawn from it. Pot resistance varies depending on where the wiper is, so the output will be nonlinear if significant current is drawn. Also as the motor draws more current the transistor will draw more Base current, which drops more voltage across its Base- Emitter junction as well as increasing voltage drop in the pot.

If you want to stick with this design idea then you need to either get a pot that can handle higher voltage, or reduce the pot voltage to 5V and amplify it with an op amp like this:-

schematic

simulate this circuit – Schematic created using CircuitLab

R3 and R4 produce a voltage gain of 2.1, which amplifies 5V to 10.5V. Q1 is included in the feedback loop to compensate for voltage drop across its Base-Emitter junction, ensuring that the motor voltage follows the input voltage linearly. The op amp's inputs draw virtually no current, so the pot's output voltage stays constant even when the motor is drawing high current. The AD820 can output up to 15mA which the BD243 would amplify by ~100, providing up to 1.5A to drive the motor.