Introduction: Simple Manual Arduino 4 Axis Stepper Motor / 16 Channel LED Power Controller

Supplying power to motors and LEDs is not always just a case of connecting to a battery and flicking a switch. Sometimes we need to control the speed of motors and be able to dim LEDs for a romantic mood effect, which is often achieved by pulsing the motor / LED with a voltage at a specific frequency (PWM). If we tried to run the motor directly off a PWM pin on an Arduino we would soon smell the tale-tale scent of burning silicon and maybe even see a small flame being emitted, which is obviously a bit of a fire hazard!

The controller needs to not only pulse the motor windings with the Arduino, but also needs to bring current in from a fairly robust auxiliary power supply. This is achieved by using a set of 4 integrated circuits containing power transistors, resistors and diodes, all in contained within the four neat little packages.

A manually controlled lighting system is great for setting moods, where you can get exactly the right lighting level for a romantic evening, but stepper motors have some seriously useful applications and to be able to control them manually, without using a computer, effectively gives you an incredible level of precision control, quite literally, at your finger tips.

Some engineering and medical jobs need to be done on a high precision microscopic level. Maybe you want to accurately place miniature components on a circuit board or perform a high precision surgical operation or experiment with genetic engineering under an electron microscope?

Some jobs are just too small and delicate to be done by hand without assistance from a machine. For example, this controller could move a surgeon's scalpel to 1/100 th of a mm accuracy (or better) using your fingers.

But the best thing of all is that it's incredibly easy to build - A reasonably clever 12 year old would have no problems building this controller - perfect for any budding brain surgeon! There are no SMT components to solder, no complicated programming, no software drivers to drive you crazy - just a few cheap components, most importantly the STMicroelectronics L293E, and an Arduino Mega or Due.

Just because this design is simple does not mean that it's not incredibly useful. It can be used to control a16 channel lighting system with a honking great 1A per channel - yes that's 16A total - and as a general purpose slider / rotary pot / toggle switch / push button Arduino interface and for precision control of stepper motors.

So, the next time you go in for a frontal lobotomy, your surgeon may well be using one or two of these controllers and a couple of Arduinos to not only do the surgical operation but also to control the mood lighting for a nice relaxing environment!

Step 1: Features

  • 2 x Power Supplies 7-32V to 0.8-28V 12A 300W FK mounting holes
  • 1 x Arduino Mega or Due
  • 16 x channels for LEDs
  • 4 x stepper motors
  • 1 x 13A relay4 x slider pots
  • 4 x rotary pots
  • 12 x toggle switches
  • 12 x push button momentary switches
  • Drill holes for mounting 4 x 20 LCD
  • Drill hole for accessing SPI socket1 x LED

Step 2: How It Works

The example I'm going to give here is for powering stepper motors, since that was the main thing that I personally needed to do.

As I said earlier, we could power the motor directly from the Arduino PWM pins if it was small enough, but in the real world we need to use the low current signal from the Arduino to trigger transistors to allow a high current, high voltage synchronised signal from an auxiliary power supply. Ultimately, it just boils down to a simple transistor although there are diodes and resistors in the chips to facilitate this. Let's not go into too much detail!

Step 3: Components

Step 4: Soldering Instructions

The board is very easy to solder, but there are a few non critical mistakes on the PCB:

  • Rotary potentiometers upside down - cosmetic
  • Toggle switches upside down - cosmetic
  • Lug mounting hole for slider in wrong place - non-critical
  • Board outline doesn't follow USB and power sockets properly - cosmetic
  • Schottky diode missing between 12v supply and Arduino Vin, which was supposed to prevent the Arduino trying to accidently run the motors through it's own power supply - non-critical but potentially damage could be done to the Aduino due to user error.
  • LED resister incorrectly labelled as 10K and should be 1K - non critical.

All component outlines are shown on the board and there are jumpers to solder in depending on whether you use an Arduino Due or Mega. I put this in as I want to use this same PCB to control a software defined radio sometime in the near future which needs 3.3v SPI.

There is a circle on the board which says 'DRILL 20mm' - ignore this as it's for access to the SPI pins.

So just solder on the headers for the Arduino and the other components and jumpers and go to the next step.

Step 5: Arduino Code

The Arduino code is incredibly simple, with some strange looking oversampling for preventing the motors from vibrating:

void sampling()    //Oversample the slider readings to avoid motor vibration.
{
   i=0;
   val =0;
   smallVal=0;
while(i<100)
{ 
  val = analogRead(14)*multiplierLarge +val;
  smallVal = analogRead(15)*multiplierSmall +smallVal;  
  i++;
}
  val=val/i;
  smallVal=smallVal/i;
  totalVal=val+smallVal; 
  totalValInt=totalVal.toInt();   
}
There's also some default settings in the main loop to stop overheating problems:
  if((switchOneVal==HIGH)&&(switchTwoVal==HIGH)&&(switchThreeVal==HIGH)&&(switchFourVal==HIGH))
  {
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
  digitalWrite(9,LOW);
  digitalWrite(8,LOW);
  digitalWrite(7,LOW);
  digitalWrite(6,LOW);
  digitalWrite(A0,LOW);
  digitalWrite(A1,LOW);
  digitalWrite(A2,LOW);
  digitalWrite(A3,LOW);
  digitalWrite(A4,LOW);
  digitalWrite(A5,LOW);
  digitalWrite(A6,LOW);
  digitalWrite(A7,LOW);
  }

The full code is attached as a file.

Step 6: Operation

WARNING:
Never operate the controller board with the USB cable connected to a computer.Never connect the external DC supply with the USB cable connected to a computer.

Since I'm not a qualified brain surgeon, I used the controller board to operate a small pick and place machine as shown in the video above.

A bit of trial and error is needed to find the right connections for the stepper motor.

  1. Press the black push button switch labelled 'U' on the board and the red LED shown illuminate. This is the 'Travel reset button'.
  2. Whilst holding either Q,R,S or T buttons, move the left hand slider. This is for fine movement and one of the stepper motors should move.
  3. Experiment with the other 3 stepper buttons until you know which one does what.
  4. The right hand slider is for coarse control and the far left rotary pot is for speed control.

Step 7: Final

Whatever you choose to do with this board, have fun and let me know what you create.

Robotics Contest 2017

Participated in the
Robotics Contest 2017

Power Supply Contest

Participated in the
Power Supply Contest

Lights Contest 2017

Participated in the
Lights Contest 2017