Hi Verdris,
Good to have you here!
How long is too long, and how long is shortened?
In simple terms there are a few things happening when the leads get longer.
- the signals take longer to get to the other end. If all the data is in one direction this may never be a problem, but if the data is being transferred in both directions (e.g. you are supplying a clock to clock data out of a remote sensor) then the round trip delay could become a problem when the received data arrives too late to be clocked into the master's circuitry.
- the resistance of the cable will attenuate the signals as they travel. If the resistance is too high, the signal arriving at the other end may not be large enough to register as a high logic level.
- the capacitance and inductance of the cable will act as a filter. The nice square signals will become "R-C" curves. This can cause two issues
- the signals may be filtered so much they don't have a chance to reach a logic high before they start to fall back down again for the next clock edge.
- the slowly rising/falling edges may be detected as more than one edge (two or three clock edges for the price of one).
- the cables will pickup more electrical noise from other sources. Mains noise (50 or 60Hz) is an obvious source of noise, but there may be other sources where you are. On its own, the devices might be tolerant of this noise, but adding noise to a slowly rising signal can be detected as several pulses.
One really simple thing to try is to turn down the SPI clock speed, this will allow more time for the signals to propagate.
Other fixes may be to use screened cable, amplification of the SPI signals or using a transceiver chip to drive the lines.
Hope this helps - Paul