doing a research to build my own steering wheel wired remote control for my Pioneer headunit, i’ve found this very interesting post, where the MCP4131 is used.
Looking at the code, i didn’t find out how to define the MCP4131 output resistance like the following piece of code.
// send command to car stereo, below values are for Pioneer head units
SPI.transfer(0);
switch(currButton) {
case VOL_UP: SPI.transfer(21); break; // 16kOhm
case VOL_DN: SPI.transfer(31); break; // 24k
case PREV_TR: SPI.transfer(14); break; // 11k
case NEXT_TR: SPI.transfer(10); break; // 8k
case MODE: SPI.transfer(2); break; // 1.6k
case MUTE: SPI.transfer(4); break; // 3k
default: SPI.transfer(0); break; // nothing
}
Where can i find the formula or the explanation in how 21 = 16K, 31 = 24K, 4 = 3K by SPI.transfer(code)?
I THINK those numbers represent the value of N (the number of steps). I assume the person used the MCP4131-104 which is a 100kOhm device with 129 steps (from 0 to 128) to calculate those values.
bool MCP4261::setValue(uint8_t pm, uint16_t value)
{
if (pm >= _pmCount) return false;
if (value > _maxValue) return false;
_value[pm] = value;
uint8_t value1 = MCP4261_CMD_WRITE | (pm << 4);
if (value > 0xFF) value1 |= (value >> 8); // high bits
writeRegister2(value1, value & 0xFF);
return true;
}
WriteRegister2() sends 2 bytes over SPI,
the first byte contains the potentiometer index (0) + the WRITE_CMD (0) code, which therefor is always zero (0) for the MCP4131.
That is your ``SPI.transfer(0); line
The second byte is the potentiometer position, typically 0..128
As you have a 100K digipot one step is 100K / 128 ~~ 781.25 ohm per step
e.g. 31 * 781.25 = 24.2 Kohm
Or if you want 75 Kohm => 75000.0 / 781.25 => 92 ==> SPI.transfer(92);