Tag Archives: stepper motor driver

Stepper Motor Controller Rev B

Looks almost like the first version

This board may look familiar to some of you. Because at first glance, it looks just like its older brother described here: Dividing Head Controller. But many things have been improved in Revision B.

Changes are only visible from the back side

It has also found new use cases. Depending on how it is programmed, it can be applied wherever a stepper motor needs to be driven from a user interface or PC. So while it was first designed specifically to drive a dividing head, it is actually quite universal.

Re-designed power supply on the left

Now what’s new? First of all, the power supply has been improved to accept input voltages in the range of 6 – 60 volts instead of 6 – 30 volts previously. For me, this was one of the main reasons for the upgrade. The stepper motor I’ve used for the dividing head lacked a bit more torque at higher RPMs when operated from 24V. This new version has allowed me to use a 48V supply which has solved all the torque problems.

A more powerful microcontroller on the left and the new flash chip on the right

The other main upgrade is a more capable microcontroller, a PIC18F47J53. Together with a 32Mbit flash chip, this allows for a USB bootloader. It enables firmware updates without any specialized hardware or software. Any PC with a USB port will do, no matter the operating system. Watch this video for a demonstration of how it woks.

Since the stepper controller behaves just like a USB drive when connected to a computer, it also allows users to customize their device by simply editing a config file that resides on that drive.

Besides the fan output, there is now also an output for a mechanical brake. But despite the labelling, these are simply open collector outputs, with flyback diodes included, capable of driving around 1 amp. So depending on the software, they can be used for any other purposes.

Three devices during programming and testing

The remaining features are unchanged: There is still a 4 x 20 characters LCD display and two nicely hardware-debounced rotary encoders. There is still a buzzer, EPROM memory, reverse-polarity protection, an on-board temperature sensor and an input for an external temperature sensor (or any other analog input signal in the 0-3.3V range).

Desktop application for the dividing head

And there still is that USB port. But with the USB bootloader and the config file, this USB port has become much more useful. And I’v also spent some time writing software so that the device can be controlled from a (Windows) PC.

A different desktop app for a different use case. But absolutely identical hardware.

And as I’ve mentioned, the board has found new use cases that use application-specific software but absolutely identical hardware. And the modular design of the software allows for the most of the software to be re-used so you don’t have to re-invent the wheel whenever you have a new application for this device. You don’t have to re-do all the heavy lifting required for USB or smooth motion control. A few changes to the user interface and the corresponding API will typically cut it.

All the hardware and software is open source, ready for you to use, improve and adapt. It’s all on GitHub so let me just share the various repos:

Hardware:
https://github.com/soldernerd/StepperMotorController

Bootloader:
https://github.com/soldernerd/StepperMotorController_Bootloader

Firmware:
https://github.com/soldernerd/StepperMotorController_Software_RevB

Desktop applications:
https://github.com/soldernerd/RotaryTableApp

RaspberryPi Robot

It’s been almost two years since I did (or at least started) this project but I never sat down to document it. That’s what I want to do today. As the title says it’s about a little robot based on a RaspberryPi. Like many of its kind it is driven by a pair of stepper motors each driving a wheel directly attached to the respective motor axis. At the back there is another smaller, pivotable wheel to keep the robot in balance.

Here’s a video of the finished robot in action, running a simple demo program demonstrating the various functions.  By the way, I’ve started a youtube cannel to share these kind of videos. I’m not really a video guy so this text and photos blog will stay my main medium but some projects like this robot, videos are a welcome addition.

Yes, I’m well aware that many similar designs already exist out there I could just go out and buy a kit like this. But making my own sounded more interesting so when I was looking for a Christmas present for my godson of sorts I did just that.

Above is a close-up of the main PCB that I’ve designed and built for this project. The idea is simple: There is a PIC16F1936 microcontroller that communicates with a RaspberryPi over I2C. The PIC then handles all the low-level details of controlling a pair of Allegro A4982 stepper drivers. These work at up to 35 volts, handle up to 2 amps of current and can hence drive much more powerful motors than the relatively small NEMA 17 size motors I’ve used here. They are easy to use and feature microstepping up to 16th steps.

Besides the two stepper drivers there is a ULN2803 providing 4 power outputs capable of driving up to 1 amp each. The ULN2803 includes free-wheeling diodes so these outputs could be used to directly drive somethingn like a relay or a DC motor. But at least for now these outputs drive some RGB LEDs at the front as well as a buzzer.

The original idea was to power the RaspberryPi  from the 5V linear regulator on the board and then draw the power for the PIC from the RaspberryPi’s 3.3 volt rail. Since the PIC uses only a few milliamps that’s entirely possible.

Unfortunately I haven’t given that setup a lot of thought before building the board. Of course, when powered from something like 12V, the LM2931 regulator gets way too hot when powering a RaspberryPi that pulls a few hundred milliamps. So I’ve sacrificed one of my solar charger RevC boards that includes two very powerful USB charging outputs.

During testing and debuggin I’ve used a small 12V AC/DC converter screwed to the bottom side of the robot. Once more or less completed I’ve changed the power supply to an old 3-call (11.1V) LiPo battery from a RC helicopter. It’s no longer fit for flying but still adequate to power this thing for a few hours.

The entire structure is laser-cut from 5mm medium-density fiberboard and held together with M2.5 torx screws with square nuts. M2.5 square nuts measure precisely 5x5mm so that goes together rally nicely. I’ve added and changed a few things as I went along, drilling extra holes to mount the blue PCB for the power supply, the LEDs, to hold the battery in place and some other things. But the structure as such works very nicely. It’s relatively simple if you have some place to do laser cutting (try your local fab lab…) and is inexpensive and sturdy.

The weels are laser-cut from the same material and are sized to measure precisely 200mm in circumference. That’s handy since the steppers feature 200 steps per rotation. 

 

That’s about it, most of the relevant files are on github. The OpenSCAD files for the laser cutting are not so just let me know if you’re interested in them. I’m happy to share them, too. Here are the links for the software and hardware, respectively.

As always, I welcome any thoughts or comments.