I am currently trying to control multiple Digipots over SPI, they work independently and while connecting two of them, but as soon as a third one is connected it fails.
I am using the Mega R3 with hardware SPI.
The Digipots are MCP 41HV31 10k
I dont have an oscilloscope to measure impedance.
I intend to use 6 Potis to control seperate voltage regulator circuits, so i soldered a crude splitter to break up the spi pins for each chip.
I can use two chips without problems (Regardless of order/combination), but as soon as i connect a third wire (with or without chip connected), at least one of the potis stops working correctly.
My Guesses:
- Since it does not matter what position the Potis are connected i am assuming that it is not a software problem.
- The wire length does not change the situation so a problem with wire impedance/capacitance seems unlikely (though i cannot measure those and i do not fully understand them so i might be wrong)
- I tried with different SPI Speeds (5 - 10 MHz), but no change.
- I am guessing that it is some problem with Signal reflections since the problem occures even if i connect wires that have no further connection.
Is this problem known, or are there any trubleshooting steps i can still take?
If i cannot fix it i will try to use multiple SPI connections over Software SPI, but i havent gotten to that yet.
Any answers are appreciated.
Software, in case i overlooked something:
if(Serial.available()){
int pct = Serial.parseInt(SKIP_ALL, '\n');
int expected=50*(pct/100.0);
Serial.println("Set Segments to "+String(pct)+"% ("+String(expected)+")");
for(int i=0;i<SEGMENT_COUNT;++i){
int wiper=0;
int tryNo=0;
for(;tryNo<5;++tryNo){
wiper= trackSegments[i].SetPercentage(pct);
if(wiper==expected)break;
delay(5);
}
trackSegments[i].Write();
Serial.println("Seg "+String(i+1)+"\tWiper: "+String(wiper)+"\tCS: "+String(trackSegments[i].CS)+" ("+String(tryNo)+")");
delay(10);
}
}
SetPercentage calls WiperSetPosition of the MCP41HVX1 Library, where WiperGetPosition is called.
byte MCP41HVX1::WiperSetPosition(byte byWiper)
{
digitalWrite( __nCSPin, LOW );
SPI.transfer( 0x00); // The command for wiper set position
SPI.transfer( byWiper); // The write command expects a second byte which is the value for the wiper
digitalWrite( __nCSPin, HIGH);
return( WiperGetPosition());
}
byte MCP41HVX1::WiperGetPosition()
{
int rc = 0;
digitalWrite( __nCSPin, LOW );
rc = SPI.transfer16( 0x0C00); // The command for requesting the wiper position. The second byte sent has no useful info but it request 2 bytes sent and responds with 2 bytes
digitalWrite( __nCSPin, HIGH);
return( rc & 0xff); // The wiper position is in the low order byte so & with 0xff to remove the extra info.
}
Digipot: https://ww1.microchip.com/downloads/en/DeviceDoc/20005207B.pdf
Library: GitHub - gregsrabian/MCP41HVX1: Class for control of the MCP41HVX1 family of digital potentiometers
Update:
I built the circuit on a breadboard again and managed to get 4 digipots working (all that i have working independently).
I am pretty confident now that the issue is somewhere in my soldering or the attached voltage regulator circuit.
I tried with a lower frequency. With the soldered circuit it didn't work at all under 5MHz, but with the breadboard it works on any frequency up to 10MHz (Not sure if there is much stability difference, i am using 10KHz for now).
Since it works on the breadboard i will look at the soldered circuit boards and replace them piece by piece, to try and figure out what is going wrong.