Use DC motor/encoders as stepper motors with step/dir signals - work in progress

I don’t know if this is of interest to anyone but I saw a guy make a vertical cnc wall painter using old drill motors, custom optical encoders using tape strips and a bunch of custom software. It was a great hack but it felt like it might be more useful if all the existing software out there could be used to control this thing instead of the custom software and workflow. So I figured the machine would need something which could handle being commanded from standard buffer based cnc controllers which predominantly rely stepper motors and because this thing is big, and can be even bigger, large motors might be handy and geared motors even better so when unpowered the machine head won’t fall.

I ran across a project which hacked an old 2D printer in this way which relied on a few Arduino shields but felt direct control of the venerable L298N h-bridge might be better. So I hacked his code to use the L298N library.

The original project was forwarded to me by a friend and can be found here:

My repository for the Arduino Mega 2560 firmware is here:

Any feedback would be great.


This is now functional and soon I’ll post a link to a demo video but I’ll probably do another Fitzing drawing and reconfigure the demo so that it uses 2 L298N h-bridges. I’ve mentioned to a few friends what I was doing and they didn’t get it or its value until I explained how it scales to any size h-bridge and motor and their response was regarding the low 2A per channel of the L298N which is in the same ballpark as stepper motor drivers. By setting up a drawing with two L298Ns each configured for parallel operation( 4A capability ) it might make a better demo. I have powered automotive windshield wiper motors with an L298N in the 4A/parallel configuration in a high power servo project.

Another direction for this is to port it do another chip/board which has enough interrupts like maybe a Leonardo/32u4 or Teensy2 and a much smaller footprint than the large Mega2560 board.

1 Like

I purchased some Tarocco Tarocco | Crowd Supply boards a few years ago, excited to have open hardware servo control, then found out that the firmware could only be modified using a janky proprietary windows IDE. Also as far as I can tell further maintenance disappeared: GitHub - ottoragam/Tarocco: Closed Loop Motor Controller

The ODrive boards are nice, quality, much more capable, but are all two-channel for some reason and are $149-$199 depending on configuration.

Servo motors have much higher torque than stepper motors for the same current. That 2A will go head to head with a lot more current in a stepper! :relaxed:

Consider including a Returned Energy Dump on your board? It’s just a few parts and will save your L298Ns if your load stops suddenly, like software misconfiguration causing you to crash into a limit.

I have no plans to make a board specifically for this and by providing the firmware in a repo means anyone can make these. I plan on getting it down to one Arduino Pro Micro(32u4 based) to handle 2 motor/encoder setup and some L298N modules come with flyback diodes onboard. It uses a few Arduino libraries and so anyone on any OS can load the Arduino IDE can build or even develop it further.

Not sure how much stalling is going to happen on a geared motor setup and when you can get 4 of the L298N modules with flyback diods for $11 a bunch of motors can be used.

It’s good to see there have been commercial versions of this stuff but figured there would be more of it at the DIY level but maybe there’s little need outside of things like Maslow CNC and vertical paint spraying machines.

1 Like