Creating a system using 4 stepper motors

Hello so I’m current working on a project where I will be modeling the functionality of a capstan ( drum barrel with motor and gearbox ) I’m considering modeling this system with A Nema 23 stepper motor , as well as a Digital stepper Driver. Now this would be 1 capstan , however I need to model 4 of these , should I model each of them using separate boards , and then connect them all to a mother board ?

  • I want to try and implement sensors , to cause these motors to possible stop when something is approaching it , how could you also get these to start up simultaneously ? Should I include a delay in every code to account for this ?

If anyone has a different approach on modeling this , I would love so recommendations. My over all goal will be to get these stepper motors to model the functions of a captan as it rotates on the harbor helping ships to dock.

Each stepper must have a driver of its own. 2 controller pins are needed, per stepper.
"Sensors" is not enough. More specific facts are needed.
There are controllers having enough I/O pins for this project.

If you really want this project to work as you described it, AVOID all use of delay.

1 Like

Hi @nosoulrob,

how much experience do you have with programming languages and in detail programming controllers?

If you have only few or no experience I would recommend to start with a sound description of

  • what you want to achieve,
  • what components are required,
  • how they will be connected ( make a drawing!)
  • how they should work together

and then create a Wokwi (https://wokwi.com/) emulation of your task step by step. Learn how to control steppers and how to program non-blocking functions.

Emulation is a very good start and also great for quick prototyping and testing. You can even integrate sensors into your application. Then move to "the real thing".

In general I would try to code the motor control as generic as possible so that there is one identical code used for all motors and add special features later. That usually saves time and reduces the impact of bugs or necessary changes.

Good luck!

For sensor suggestions, you will need to be more specific. Is "something" a person, a boat, or?

To have a responsive program you must write code that does not block. That means no delay() functions and any for or while loops should be very short (like 1ms or less execution time).

Non-blocking timing tutorials:
Blink without delay().
Blink without delay detailed explanation
Beginner's guide to millis().
Several things at a time.

A good library will help to write the code. My favorite for steppers is the MobaTools stepper library. It is available to install with the IDE library manager. The library uses acceleration and will generate steps in the background.

Do you want coordinated movement with the 4 motors? Maybe something like a GCODE interpreting CNC would help:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.