There is a lot of information online for SPI bus termination, but my situation is a little bit different. I have created a system with the intention of 'plug and play' IMUs. Although the main electronics (Nucleo-F446RE) needs to be reset after each addition/removal of IMU to allow for reinitialising, the concept has shown to potentially work in ideal situations.
However, finding the best combination of resistors in series for bus termination has turned into a headache because of my unorthodox setup. There can be anywhere between 1m of SPI line, to 4m, depending on whether I have one or four IMUs connected, respectively. The system has been made to be as user friendly as possible, and the 1m cable length is necessary due to the intended application of IMU placement:
- Each IMU has 7 lines (3.3V, ground, clock, MOSI, MISO, CS, interrupt) and has a 1m of shielded cable connected.
- A 7 pin plug is connected to the other end of the cable, which plugs into a matching 7 pin socket. The socket is mounted in a 3D printed housing, which also houses the Nucleo.
- From the socket to the individual pins of the Nucleo is ~10cm of unshielded multi-core conductors. These are the same conductors from the wiring listed above, although not contained within its shielded insulation. Because of space constraints and the number of Nucleo pins the wiring is attached to, I was not able to use shielded wiring within the 3D printed housing.
- Appropriate lines are grouped within the housing as they go to a single pin on the Nucleo (3.3V, ground, clock, MOSI, MISO), but each CS and interrupt line is going to a separate Nucleo pin. Despite being grouped, each IMU has it's own ~10cm of unshielded line (the lines are grouped just before being soldered to the pins).
- SPI clock speed tested at 5.625Mbps and 2.812Mbps. Sampling the IMUs at 1.66kHz using their data-ready interrupts to read data. Ideally I'd really like the faster clock speed, but may be able to get by with the 2.812Mbps speed.
I have given copious amounts of details, as in my experimentation this all seems to be important. The issues that I am seeing are that either some or none of the IMUs are initialising in different configurations (e.g., I have all four IMUs connected, but only two or three will initialise). I have also seen devices initialise, but after a few seconds stop responding. I have also seen seemingly successful initialisation, but there will be a lot of digital noise, square-wave responses, or otherwise bad data. To make my problem harder to diagnose, the combination of IMUs connected alters the issue. One IMU connected may respond fine, two and three as well, but four will cause issues. Likewise, maybe I can only connect two IMUs before issues appear, or I will connect four and only two will respond, despite three working seemingly well before the fourth IMU is connected.
I have drawn a quick ASCII image on my setup, and have listed what I believe to be relevant points where termination resistors can be attached, as shown in {x}:
1m shielded cable ~10cm unshielded line
[IMU 1]{1}======================{2}[plug][socket]{3}-----------------------------{4}[ ]
[ ]
[IMU 2]{1}======================{2}[plug][socket]{3}-----------------------------{4}[ ]
[ Nucleo ]
[IMU 3]{1}======================{2}[plug][socket]{3}-----------------------------{4}[ ]
[ ]
[IMU 4]{1}======================{2}[plug][socket]{3}-----------------------------{4}[ ]
Originally, I placed a 100ohm resistor on the clock and MOSI lines at the leaving point of the Nucleo (point {4}), and a 100ohm resistor on the MISO line at the connecting point of the IMU (point {1}). When one IMU was connected, this seemed to work fine. But once four IMUs were connected there is collectively 400ohm on the MISO line, which seemed to be too much and caused the above-mentioned problems.
Next, I tried removing the MISO resistors from all the IMUs at point {1}, and placed a single resistor at the same place as the other resistors, at point {4}. This sporadically worked. Originally 100ohm appeared to work, but I have also tried 22, 47, and 68ohms, and a combination of each when monitoring the lines with an oscilloscope. I have also gone as high as testing 300ohm resistors, but after that the signal becomes too saturated.
Finally, where I am now. I have connected a 22ohm resistor on the clock, MISO, and MOSI lines at the Nucleo (point {4}), but also each IMU has their own 22ohm resistor on the clock, MISO, and MOSI lines at the IMU (point {1}). If one IMU is connected, each line will have around 44ohms termination, and that will increase by 22ohms for each connected IMU.
The reasoning for my placement of the resistors at these specific points, is because I had read that clock and MOSI should be terminated at the source, and MISO at the sensor end, but that has pretty much gone out the window through my numerous iterations of testing. There are too many parameters with each connected IMU for me to trial-and-error my way through this.
I would very much appreciate some theoretical know-how on how to solve my issue. I have worked with SPI before, but such short lines that I never had to deal with termination. In hindsight perhaps SPI wasn't the best choice, and I'm well aware that up to 4m is REALLY stretching the limitations, but I would love some help from professionals.
My lasting idea is that perhaps I should be placing the termination resistors in the middle of the lines, perhaps at the plug or socket points ({2} or {3}). Maybe resistors in series are not the best strategy and someone has another suggestion? Maybe someone can help me understand the numbers behind the resistor values and cable impedance so I can select the best resistors rather than a very long-winded experimental method.
Thanks very much in advance for any help!