Going into this build season, we wanted a simple way to operate motors on prototypes. Before we went mostly brushless in 2020, we’d hook up prototypes to the Talon SRX’s on a kit-bot, but that was always a little clunky. For 2020 prototyping, we ran Neos’ SparkMax controllers on a janky SB50-to-PowerPole cable without overcurrent protection, each controller hooked to a laptop to run the Rev application. For efficient and safer prototyping we needed a better solution.
For prototyping complex assemblies, we knew we needed to run multiple motors at once. Commercial single-channel PWM solutions, like the Thrifty Throttle, were not cost effective in a 4-channel configuration. At the other extreme, we could have built a mini-control system around a Rio and done full-up control of however many motors we wanted, but we didn’t have a spare Rio nor did we want the complexity of needing robot software and a driver station just to run motors.
Fortunately for us, capable microcontrollers are ubiquitous and cheap! We settled on a 4-channel solution, which could be run on a standard Arduino Nano. To keep complexity down, there’s a simple set of physical controls: each channel has a button to toggle it on and off, an LED to show its state, and a center-detent slider for speed control. While this is overall a pretty simple build, we’re sharing it here in hopes it may be useful to other teams, either to build as-is or as a starting point for a different variant.
Control Board
Here’s the schematic of the control board. Note that pins 2 & 3 on JP1 through JP4 are reversed; the PWM signal should be on the third, not middle, pin.
And here’s a picture of the board, which one of our students built with point-to-point wiring on a stock prototyping PCB:
Arduino Code
The control software is a quick sketch of around 100 lines:
Mechanical-Advantage/MotorTest/blob/main/MotorTest.ino
#include <Servo.h>
#include <Wire.h>
#define MAX_CHAN 4
#define PWM_OFF 1500 // pulse width for stopped
#define PWM_MIN 1000 // pulse width for maximum reverse
#define PWM_MAX 2000 // pulse width for maximum forward
Servo myservo[MAX_CHAN];
bool channel[MAX_CHAN];
int buttonState[MAX_CHAN];
int lastButtonState[MAX_CHAN];
// These arrays hold the Arduino pin identifiers for channels 1,2,3,4 in order
const int buttonPin[] = {8, 10, 11, 12};
const int ledPin[] = {A0, A1, A2, A3};
const int sliderPin[] = {A4, A5, A6, A7};
const int pwmPin[] = {3, 5, 6, 9};
unsigned long debounceTime = 0;
This file has been truncated. show original
This uses the standard Servo library for generating the PWM signals; this works very well for driving FRC controllers’ 1000uS to 2000uS pulse width inputs. Channel state is toggled based on debounced reads of the buttons. The software continuously scans the analog sliders and scales the values to the appropriate PWM value.
Power Distribution & Motor Controllers
Of course, the control board is only half the solution; we need motor controllers and a safe way to power them. For four channels, we used these power bus bars
and a set of cheap automotive-style self-resetting 40A breakers.
You can, of course, use whatever controllers you wish. Initially we built the board with two Spark controllers for brushed motors, and two SparkMax controllers for brushless. This allowed us to use either motor type without having to switch modes on the SparkMax’s; we feared that if left in the wrong mode we could easily damage a motor. Almost immediately, of course, we needed to run a prototype with 3 Neos. That wouldn’t be the last time, so we added two more SparkMax’s; with PowerPoles on both the Sparks and the SparkMax’s, it’s quick and easy to use either type (though it made the wiring look less neat than in the original build). The four PWM outputs on the control board can likewise be plugged into whichever controller is needed.
Final Product & Usage Notes
Here’s the finished build. It’s perhaps not the prettiest thing in the shop, but it is very functional and adaptable.
Some prototypes need motors running at the same speed; a Y cable can be used to run two controllers from one channel. Sometimes those motors need to rotate in opposite directions. Brushed motors, of course, easily achieve this by swapping positive and negative leads. For brushless, we use the Rev hardware client to reverse the output on one of the pair and save the configuration to flash.
Cost
The main cost of this rig is in the motor controllers. In our case, we had Sparks in a drawer, and two of the SparkMax’s had previously had a issue of uncertain origin that caused us to flag them as “not for competition use” anyway. A Nano clone was about $5, most of the small electronics parts were on hand, and we spent less than $50 on the rest.
Known Issues
Sadly, we did not include a hyperspace control.