Arduino Pulse Generator for Stepper Motor

Arduino receives from Raspberry Pi a required number of pulses. Arduino then generates real-time pulses for the stepper motor controller. Pulses are generated in compliance with the predefined acceleration / deceleration rate, maximum speed of the stepper motor and minimum duration of the pulse. After completion of the generation, Arduino waits for another request from Raspberry. Has anyone developed this solution and can you share it? My intention was to generate pulses for the stepper motor controller (e.g. TB6600) using Raspberry but due to its non-real time nature, the jitter of pulses is too high. Therefore I would like to outsource generation of pulses to the more suitable hardware like Arduino. Thank you, Arduino experts. Paul

Look into the stepper example codes in the IDE.

I have almost no experience with stepper motors. Still, it seems very strange to me that with a fast microcontroller like the RP2040 you don't get good control of the motor steps and you have to use an additional microcontroller. Even the RP2040 has 2 cores and it seems a good idea to have the first core process your program and the second core control the motor. What will the experts say?

RP2040 is an MCU, but Raspberry Pi is not and is a very different thing. Typically it runs a flavor of Linux. It is possible to do "real time" in Linux, but it might require writing a device driver, and/or installing kernel extensions, neither of which is easy.

It seems that it is not uncommon to hand off low-level control to a Pi "hat". The principle would be the same with an Arduino as external controller, just a question of choosing UART/SPI/I2C and then the Arduino side is quite straightforward.

Be aware - any single-celled MCU will have, for example, serial interrupts for receiving characters. By very nature, those will disrupt your timing. Attempting to disable interrupts will work, but if async/unsolicited commands are expected, you cannot shut off interrupts for longer than a character time, unless you implement a protocol that holds off communication until sensitive timing is complete.

The Raspberry Pi is based on the RP2040 and I wouldn't say they are completely different things. Maybe Linux is used but it's not mandatory and also some use a variant of Python and others like me use the Arduino IDE to program the Pi Pico. The OP didn't say what they use for programming but in any case the hardware base is a 2 core microcontroller. It's more strange to me to add another microcontroller and I think it would be harder to get everything to work together properly. It's true that the OP doesn't say which Raspberry Pi is using but I think the RP2040 is the weakest microcontroller in the series.

Raspberry Pi is a brand name and there are a lot of different boards from this brand nowadays. If someone talks about 'Raspberry Pi' mostly the small LINUX board ( which was the first board by this brand ) is meant. The last version of this single board computer is Rapberry Pi 5.
You must distinguish between Raspberry Pi 5 and Raspberry Pi Pico. Despite the very similar name, these are very different things. The Raspberry Pi 5 is a small LINUX computer, while the Raspberry Pi Pico is a microcontroller board based on RP2040 or RP2350 ( more comparable to an ESP32 board ). Pi5 and Pi Pico have nearly nothing in common. And there are a lot of other very different boards produced by the Raspberry Pi company.

No, the Raspberry Pi series is based on a Broadcom SOC.

From https://www.raspberrypi.com/products/raspberry-pi-5/

Raspberry Pi 5 features the Broadcom BCM2712 quad-core Arm Cortex A76 processor @ 2.4GHz, making it up to three times faster than the previous generation. With RAM variants up to 16GB, this is the fastest, smoothest Raspberry Pi experience yet.`

You are talking about the Raspberry Pi Pico https://www.raspberrypi.com/products/raspberry-pi-pico/

The Raspberry Pi Pico series is a range of tiny, fast, and versatile boards built using RP2040, the flagship microcontroller chip designed by Raspberry Pi in the UK

It's clear from the OP that they meant the Raspberry Pi, not the Raspberry Pi Pico.

Unfortunately, Raspberry Pi made the same mistake that Arduino made, and call their company and first product "Raspberry Pi". Then they introduce new products also called "Raspberry Pi xxx", and it leads to perennial confusion. Let's not add to the confusion by getting confused between completely different products.

I guess I will use grbl for my purposes. It's quite a complex control package but it should manage perform simple things too. Take Arduino Uno, upload grbl firmware, hook up to Raspberry Pi serial and send g-codes from Python to serial.