MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.14k stars 19.2k forks source link

[FR] Control board using only SPI with shift registers? instead of step/dir/enable pins for each motor #21389

Open djamu opened 3 years ago

djamu commented 3 years ago

Hi all, I'd like to have your opinion about following feature/concept.

I was wondering if anybody ever tried an all/only SPI build of Marlin, using (high speed) shift registers/transceivers ( either 8 / 16 bit ). I'm prototyping a control board like that, as it greatly simplifies board layout, daisy chaining SPI shift registers. Common sense dictates to use buffer IC's, before driver IC's, so why not using an SPI bus? Modern devices like the IMXRT1062 (teensy 4) etc... all feature high speed SPI bus(ses). With those speeds, toggling pins on the shift registers can be quicker than those onboard when using DMA. 80Mhz / Mbs can be achieved, theoretically, without the overhead using 8 8 bit registers, (64 pins), this would be 625kHz on all pins. Which is more then fast enough to drive STEP/DIR pins, and even a localized SPI bus.

I've only glanced briefly at the code, but practically, I think the easiest to achieve this is to map the pins to a Union, toggle bits there and transfer its bytes at a fixed frequency using DMA block transfers.

This is actually a similar approach as to PC motherboards that use high speed serial connections instead of parallel. Aside from the simplified board layout, which is modular in design, one could use cpu's with fewer pins yet fast enough to drive lots of motors / mosfets. I think I'd want to keep the analog in though.....

My coding skills are sufficient, as I can understand most code, but I'd like to discuss the best approach before going there. Currently I have assigned 8 bits I/O / motor / other. ( STEP/DIR/ 4 SPI / enable / endstop ), analog inputs are still routed to main CPU ADC's.

good idea ?

ejtagle commented 3 years ago

This idea was also discussed for the ESP32 implementation of Marlin. The ESP32 has simply not enough pins to control everything, so a SPI bus expander (shift register+latch) was proposed...

djamu commented 3 years ago

Are you referring to #11873 ? as I can't find any other issue / feature request related. Aforementioned is not what I mean.

edited: was just looking into the esp32 code, when I realised this is already implemented using I2S... I feel so stupid now.