When the need to drive a stepper motor arises, one can turn to the microcontroller. For the task, I am currently using M-Duino AR38+ and I have already written something about it a few days back, link here.

Note that an Arduino based controller is suitable for the task because it can generate fast pulses on it's pins, that can be fed directly to the stepper motor driver. And by fast, we are talking 200kHz, which is an upper limit of the driver I am using, an JDK5056S. There are other drivers with this same form factor, being a clones of one or another, with the labels like JK1545, TB6600, DM542, SH-8611A, CW8060 and similar. There is also a slightly more advanced one with the type HSS86. All these are designed to drive stepper motors of type NEMA 23, NEMA 34 and so on.

A 200kHz switching frequency is still slow as the output pulses on AR38+ can probably go up to 4MHz. But 200kHz is fast, compared to for instance RevPi, which can switch it's output pins with the frequency of 200Hz, thus being unsuitable for a stepper motor application.

AR38+ pins with pulse outputs

MDuino supports pulse outputs on these pins, where the ones that are available on AR38+ are shown in bold:

  • TIMER0: Q0.5 and Q2.6
  • TIMER1: Q2.5
  • TIMER2: Q1.5 (Multiply the frequency x2)
  • TIMER3: PIN2, PIN3 and Q0.6
  • TIMER4: Q0.7, Q1.6 and Q1.7
  • TIMER5: Q1.3, Q1.4 and Q2.0

There are two more limitations:

  1. When TIMER0 pulse output is used, Arduino functions as delay(), millis(), micros(), delayMicroseconds() and other in this category stop working as intended, because they rely on that timer.
  2. It is not possible to have different frequency on the pins tied to the same TIMER.

From the list above and taking the above limitations into consideration it is apparent, that without any other additional parts, AR38+ can drive four separate drivers with two different frequencies at the same time. First three being pin 2, pin 3 and Q0.6 sharing the frequency and Q0.7 being the fourth.

Closing notes

Note that Q0.5, Q0.6 and Q0.7 are a PWM/Analog Output pins. Using these for the steppers limits the available pins with the same functionality from six to three, the other three being Q1.0, Q1.2 and Q1.3, this is something to keep in mind.

Also note that Q0.5 was omitted in from the consideration, even thou it is supporting the pulse output, as to not mess with the time related functions. They are not strictly required, but it is unclear to me at this point how they are affected. Having unexpected behavior on something that can even cause harm is not recommended.

Overall, M-Duino 38AR+ is well suited for interacting with the stepper drivers and the overall experience for me is smooth and reasonably documented. Having the Ethernet included in the package makes it a very capable companion for the price sensitive industrial machines.

This is a 82th post of #100daystooffload.

  • https://github.com/IndustrialShields/arduino-Tools40#pulses
  • https://www.industrialshields.com/blog/arduino-industrial-1/post/stepper-motor-speed-control-using-an-arduino-based-plc-and-a-rotary-encoder-64