stacking arduino's?

is it possible to stack an Uno on say a Mega2560 piggy back style, have separate programs running on each of them and using outputs from one for inputs of the second one. I'm trying to run a NEMA34 stepper motor using cl86t drive. I would like to use one to strickly only operate the motor and the second to perform the math and control the first one. reason being, the pulse on time duration is from 1000 to 3000 microseconds and the off time is one to three microseconds. the Mega runs the motor well enough, but when I start adding more responsibility to it, it seems to slow things down?

CL86Tdriver.pdf (452 KB)

In a stack each Uno pin will be connected to a Mega pin, so that you can drop the Uno and use one sketch for the Mega.

It is a common beginners mistake to think of using two Arduinos to solve a problem. Most of the time one Arduino is enough if you get the program right.

If the Mega really isn't powerful enough then you need a more powerful Arduino, not 2 of them.

to answer your first question.
yes, you can stack microcontrollers.

that being said, you would want to do that when doing so plays to the strenghts and improves your application.

I think that the overhead of two talking would not be an improviment, but rather increase the delays.

Maybe your code is not optimized ?

Oone option might be to get a faster processor. there are a couple options that should be on the table.

the Teensy might be more than enough for your application

the ESP8266 if you do not have a lot of drivers and inputs.

the EWSP32

and the blue pill / red pill / black pill

all of which can use your code, hopefully, without much modification

Teensy LC (for Low Cost) runs at 48MHz. Maker is PJRC.com. They have faster ones, the Teensy 3.6 OC's to 240MHz. All are Arduino-compatible (can code with Arduino IDE).

Be aware that the pins are more delicate than AVR pins, don't control exactly the same if you are banging register bits instead of using the much slower Arduino digitalWrite() function.

Your wiring would need to change for 3.3V control and less current than AVR pins can give/take.

JIM_W:
he pulse on time duration is from 1000 to 3000 microseconds and the off time is one to three microseconds.

A timer interrupt should have no problem keeping that running smoothly in the background.

the Mega runs the motor well enough, but when I start adding more responsibility to it, it seems to slow things down?

It seems you forgot to post some very important things about your project. Your actual code, for example.