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.05k stars 19.16k forks source link

[FR] IO pin Multiplexing #9673

Open Iamturbo1978 opened 6 years ago

Iamturbo1978 commented 6 years ago

I'm just throwing this idea out there

With the increasing number of advancements in 3D printing hardware, I think we could hit a wall when it comes to Arduino IO pins. For example, I have an Azteeg x3 PRO with a VIKI2 display and (6) TMC2130 stepper drivers. That is a total of 8 parts on the SPI bus. I have run out of easily available (no soldering) IO pins on my board to add additional hardware.

So my thought was to multiplex the chip select pins with either a logic decoder (a 3:8 decoder for example), or use a shift register. If a shift register is used, it could also be used to control the stepper motor enable lines. I would say any Adrunio output pin that does not need a fast response (using the term lightly) could be controlled by a shift register instead of taking up an Arduino pin.

Maybe there is something already in Marlin, and I just don't know about it.

Thanks Anthony

tcm0116 commented 6 years ago

I've actually been thinking about doing something like this. The issue is that the CS pins are actually enabled/disabled in the TMC2130Stepper library and not within Marlin itself. As such, this capability would have to be incorporated by @teemuatlut into the TMC2130Stepper library directly.

teemuatlut commented 6 years ago

A bit niche but not unreasonable. Perhaps the interface could be something like

TMC2130Stepper stepperX(dataPin, clkPin, latchPin);

// Tell the library instance the current value in the shift register.
stepperX.shiftRegister(value_held_by_Marlin);
// Library bit bangs the new register value and latches it.

Then Marlin could read back the shiftRegister value but that should be optional as the library will toggle the CS pin LOW and then back HIGH again, meaning no change happens.

archi commented 6 years ago

I would "tentatively" second this - I'm planning (long term) to do some work on a cheap 32 bit board and would like to add good support for TMC2130 and similar, but the MCU (STM32F1) doesn't have enough IO pins without using some tricks - though I would use a 16 port I2C I/O expander instead of a shift register. Those can be programmed to send interrupts via a separate pin, which might be useful if endstops are "hidden behind" that IC.

Endstops would also need some demultiplexing in software [pause program/movement, get registers from the expander via I2C, figure out which endstop changed state, continue program/movement as appropriate]

Shawnb03 commented 6 years ago

Please take a look at this board and tell me what you think. It has the same exact footprint as the Mega 2560 and the Arduino Due. It also comes with a ethernet port and a ton of extra pins that possible could solve this problem.

Here is the link to it. I am only posting this because I am interested in checking this out and giving it a try.

https://www.digikey.com/products/en?mpart=ATSAME70-XPLD&v=150

archi commented 6 years ago

@Shawnb03 That's directed at whom? In case you asked me to take a look, I wouldn't personally compare a 37US$ board with those <3US$ STM32F1 boards. Of course it's always possible to use a more expensive IC with more IOs ;-)

Shawnb03 commented 6 years ago

It was really just a open comment. I am just looking for peoples opinion on this idea of mine. I would love to try this board out, due to it having massive power to run pretty much anything 3D Printer related.

Bob-the-Kuhn commented 6 years ago

FYI - the Due's processor already has a hardware mux function for SPI selects. It'll put out a 4 bit code on I/O pins so it can drive up to 15 SPI devices off of the hardware SPI.

I'm hoping to see LPC1778 based boards come out. More I/O pins and lower cost than the LPC1769/17678 along with EEPROM.

Bob-the-Kuhn commented 6 years ago

@Shawnb03 - the problem with a board like that is hooking up all the I/O. You're money ahead to select an existing controller with the features you want.

As to processing power, I haven't heard any computing power complaints about any of the 32 bit processors.

Shawnb03 commented 6 years ago

@Bob-the-Kuhn, Sir, thank you for everything you have done with developing Marlin. Thank you for your input on this matter. I was interested in this card mainly because it had the Due Footprint, but it also had the Ethernet port which the current Due does not. Plus having a lot more IO pins.

But maybe you can help me with a problem that had gotten me plagued. I currently have the Arduino Due, and a RADDS v1.5 board. I am running 5 TMC2208 stepper motor drivers. I am pretty sure that the RADDS Board has at least 3 available UART ports that are not being used (I think) and thats a huge I Think. I would love to be able to ulitize all the features that are on those little monster stepper drivers, but I cant het the damn things to work with the UART. Hinse, the reason why the card that I mentioned caught my eye. I am sure you understand now. The RADDS board is around 55 to 75ish dollars. The Due board is around 40ish maybe less at some places. Then saw this board that has a Due footprint plus all the extra IO pins, little light bulb lit up.

Now does my question make more since about the board. But my problem is, where in heck do I hook up the TMC2208 UART to the RADDS board. I have looked and looked. I have found 1, but the other two have completely ghosted me. Please help

Bob-the-Kuhn commented 6 years ago

The Due has four total UARTs of which one is dedicated to the USB programming port. The others are on logical pins 14-19.

According to the RADDS schematic I have, only one of the remaining three are available. The I/O pins for the other two are dedicated to other functions on the board. The pins_RADDS.h file confirms this.

radds

boelle commented 5 years ago

@thinkyhead if this is a feature request (hard to judge) maybe add the label?

boelle commented 5 years ago

missing label

gDanix commented 3 years ago

I would like to resucitate this FR, because it would be really useful to have a shift register with all the mostly-static, output-only things connected there: RGBW leds (4 pins), beeper, driver's EN pins, BLTouch servo pin (maybe?), etc...

I've taken a look at the code, and maybe it can work by modifying the FastIO's _WRITE(IO, V) macro to include a new case in the conditional to manage the shift register by writing values in one pin, and clock pulses in another pin.

Could this work? After "calling" WRITE it's assured that the physical pin is already updated, or it's expected to be a delay?

enwi commented 2 years ago

I also have a lot of interest in this feature. I designed a Pick and Place machine PCB using the ESP32 to control everything. Due to the limited IOs I had to add 4 shift registers to be able to control 6 TMC2130 motor drivers and an additional 4 MOSFET outputs. It would be awesome to be able to use Marlin to control my PnP.

enwi commented 2 years ago

Okay I think for the ESP32 platform this is not a huge deal, when you are just using the Step/Dir interface, because apparently shift registers are already supported by Marlin for ESP32. Good that I designed the board to work with both SPI and Step/Dir

hsyngndz85 commented 2 months ago

The output pin for esp32 has been resolved. I wonder if input multiplexing has been solved? It would be better to use endstops and external inputs.