The easiest way to skyrocket your YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

Smooth stepper motor control with two Arduinos using the Accelstepper library

Follow
Curious Scientist

In this video I show you how control a stepper motor via a slave Arduino. The role of the slave Arduino is to reduce the load on the master MCU which is introduced by the stepping code. The stepper motor has to be stepped with a certain frequency, therefore at each step the MCU becomes busy. We can put tasks between two steps, but if the task becomes too time consuming (too long) then it interferes with the stepping and it increases the delay between two steps. When this happens, the speed of the stepper motor becomes uneven due to the uneven delay between the steps. This can be heard as “hiccups” or some sort of hammering noise.

My idea is actually very simple. Let’s build a system with two microcontrollers: a master and a slave MCU. The master communicates with the computer and all the other hardware while the slave only receives the commands from the master and controls the stepper motor. With this solution, the slave’s only job is to take care of the stepper motor and to send a feedback to the master after the job is finished. Thus, the slave is not (over)loaded with other tasks and the motor runs smoothly. Considering the fact that an Arduino Nano cost $35, it is a good investment.

I have been using this solution for a while in my DIY tensile testing machine (   • Tensile tester project  ) and it works perfectly. The stepper motor control is done with the AccelStepper library. In the tensile testing machine, the master Arduino continuously communicates with the computer, reads and processes the data of a load cell and a DRO and communicates with the slave which only takes care of the stepper motor.

In this demonstration I show you an idea about how to send commands from your computer to the slave Arduino, how to control a stepper motor with the AccelStepper library and how to send some feedback from the slave to the master after the issued task is finished. If you understand this example well, you can build many cool and complex stepper motor related projects.

Please don't forget to subscribe to my channel!

Source code and schematics: https://curiousscientist.tech/blog/st...

If you want to support my work, please consider buying the parts using my affiliate links:
https://curiousscientist.tech/tools

posted by bmt04d2