I'm trying to get a Chinese 20A DC Motor Speed Controller working with a MCP42100 Digital Potentiometer. The analogue potentiometer supplied was 100kOhm. I have programmed my arduino with the following code:
#define DATAOUT 11
#define DATAIN 12 //not used
#define SPICLOCK 13
#define SLAVESELECT 10
#define NOTEON 9
int potValue = 255;
float potInputValue;
void SPIInitialize()
{
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK, OUTPUT);
pinMode(SLAVESELECT, OUTPUT);
digitalWrite(SLAVESELECT, HIGH); //disable device
SPCR = (1 << SPE) | (1 << MSTR);
clr = SPSR;
clr = SPDR;
delay(10);
}
char SPITransfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1 << SPIF))) // Wait the end of the transmission
{
};
return SPDR; // return the received byte
}
//--- MCP42100 code
byte SetPot(int address, int value)
{
// Slave Select set low to allow commands
digitalWrite(SLAVESELECT, LOW);
// 2 byte command
SPITransfer(0x10 + address); // 0x10 = 'set pot' command
SPITransfer(value); // Value to set pot
// Release chip, signal end transfer
digitalWrite(SLAVESELECT, HIGH);
}
//--- Application code
void setup()
{
SPIInitialize(); // Initialize the SPI interface
Serial.begin(9600);
delay(25);
Serial.println("Type a resistance between 0-100 kOhms above.");
}
void loop()
{
if (Serial.available() > 0) {
// read the incoming byte:
potInputValue = Serial.parseInt();
float potValue = (potInputValue / 100.0) * 255;
Serial.print("Value: ");
Serial.print(potValue);
Serial.print(", Resistance: ");
Serial.print(potInputValue);
Serial.println(" kOhms");
SetPot(1, potValue);
}
}
Here is a picture of my setup:My setup
Currently at a resistance of 0 kOhms the motor runs at full speed, as it should do and this is how it reacts with the analogue potentiometer. At a resistance of 100 kOhms, the motor (in this case a computer fan) still has enough juice to spin, until I stop it with my finger, but then it doesn't spin without a little push. With the analogue potentiometer, at 100 kOhms the motor received no juice to spin.
Here is a link to the speed controller: http://www.ebay.co.uk/itm/301366805277?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
The speed controller appears to use a 555 timer.
What am I doing wrong with the digital potentiometer to make it so it doesn't behave the same way as the analogue potentiometer?
-
2You haven't told us anything about the motor controller or what sort of inputs it expects, or given us a schematic, so I don't see how anyone could really answer this.Nick Johnson– Nick Johnson2015年07月21日 10:30:50 +00:00Commented Jul 21, 2015 at 10:30
-
I'd suggest using a motor driver board that was explicitly designed to be interfaced with from a MCU - rather than trying to jury-rig this one. Alternately, you could use a DAC on the middle wire of the potentiomter, instead of trying to use a digipot.Nick Johnson– Nick Johnson2015年07月21日 13:24:19 +00:00Commented Jul 21, 2015 at 13:24
2 Answers 2
The MCP42100 does not appear to be an appropriate digital pot for this application.
Without a schematic of the motor controller it is hard to tell, but a good guess would be that the digital pot is seeing voltages higher than the supply voltage you are feeding it, and higher than the maximum supply voltage of the digital pot (5.5V; 7.0V abs max). I don't see a voltage regulator on the motor controller board, nor would one be necessary for a low-end design. Probably just a PWM using a 555, as you say.
To make this work you probably need a different type of digital pot - one that can accept logic level inputs and has a higher supply voltage (12V + some margin). You also typically actually have to feed it the higher supply voltage (and be careful that nothing shorts and ruins the micro board).
Otherwise the input protection networks on the digital pot conducts more current than you would expect.
-
I'm not sure such a digipot exists, and a DAC is probably a better choice anyway.Nick Johnson– Nick Johnson2015年07月21日 13:25:37 +00:00Commented Jul 21, 2015 at 13:25
-
Hi, @NickJohnson. I don't think a DAC (other than maybe a 4-quadrant multiplying DAC that can accept a 12V reference) will work. This kind of circuit generally uses the pot resistance to actively charge and discharge a capacitor- it does not simply accept a control voltage. Such digital pots certainly exist (eg. AD5290) and there are others from AD and Maxim.Spehro 'speff' Pefhany– Spehro 'speff' Pefhany2015年07月21日 13:48:50 +00:00Commented Jul 21, 2015 at 13:48
If you look at the MCP42100 data sheet http://www.microchip.com/, on page 4 you will see the details for your unit. Notice that the actual resistance will be in the range of 70k to 130k.
So the reason that you are getting different results is (probably) due to your having a digital pot with a resistance somewhat lower than the physical pot you used.
-
Measuring the digital potentiometer with a multimeter reads a value between 0 to 100kOhmsJosephFTaylor– JosephFTaylor2015年07月21日 11:53:57 +00:00Commented Jul 21, 2015 at 11:53
-
What, exactly does the multimeter measure on the digital pot at 100%, and what, exactly does the multimeter measure on the physical pot at 100%?WhatRoughBeast– WhatRoughBeast2015年07月21日 12:00:45 +00:00Commented Jul 21, 2015 at 12:00
-
The analogue reads 0Ohms at minimum and ~104kOhms at maximum. The digital potentiometer reads ~0.01kOhms at minimum and ~103.7kOhms at maximum.JosephFTaylor– JosephFTaylor2015年07月21日 12:06:55 +00:00Commented Jul 21, 2015 at 12:06