Motobox ©


Motobox is a generic motor driver project that has been  published in Elektor Electronics (July/August 2007 Issue). The aim of this web page is to give more information and the atest updates about the project. It will also complement the article by adding more information about the use of MotoBox. For construction and initial testing of the project please refer to the original Elektor Article. If you have arrived at this web page via a search engine and you interested about the project please email the author.


Motobox Specifications

  • Drives 3 types of motors
    • DC motor
    • Servo Motor
    • Bipolar Stepper Motors
  • Motors actuated using the serial port, 9600,8,N,1
  • Up to 13.8V supply for motors
  • Easy to use command set
  • Current monitoring, up to 2A per channel for DC, servo motor and stepper motor
  • LED indication of operation, green ok, red error

For the full article about MotoBox please purchase the magazine or follow this link.

For businesses who wish a more advanced and customized version of MotoBox, please email the author on

The latest MotoBox Hex file can be downloaded from here

Command set

MotoBox has a command set of 36 command covering single motor control as well as the ability to control 2 different motors at a time. The following sections give detailed step by step instructions on how to operate each type of Motor.


MotoBox operates using an RS232 system. Upon the module being switched on the command ‘I is sent back on the serial link indicating successful initialization. Commands are sent as text commands to the controller which is then converted into the relevant motor signals. uccessful commands are acknowledged by an A and in the case of an erroneous command an ‘E‘ is sent back. Commands are executed immediately upon reception. Commands are not queued at the controller and acknowledgement is sent back only after a successful execution of the command. The software issuing commands to MotoBox should always wait for the acknowledgement to be received before sending the next command.

Stepper Motors

Commands used to control stepper motors

Command Description
ST1FOR Stepper 1 forward
ST1BAK Stepper 1 backward
ST2FOR Stepper 2 forward
ST2BAK Stepper 2 backward
STBFOR Both Stepper Forward – simultaneously
STBBAK Both Stepper Backward – simultaneously
STSYNC Get steppers both in same position in case of slip
ST1FXX Move Stepper 1 XX (999 steps max) positions forward
ST1BXX Move Stepper 1 XX (999 steps max) positions backward
ST2FXX Move Stepper 2 XX (999 steps max) positions forward
ST2BXX Move Stepper 2 XX (999 steps max) positions backward
STDELX Configure stepper motor delay
DC1OFF DC Motor 1 OFF / Stepper 1 off
DC2OFF DC Motor 2 OFF / Stepper 2 off
DCBOFF DC Both Motor OFF / Both Steppers off

MotoBox uses a half wave technique to drive the stepper motors. Steppers can either be moved forward or backward individually or switched off. Note that the command used to switch off the stepper motor is the same as used in switching off the DC motor. Also the module could be programmed to move a single stepper motor several steps on after the other. To this effect the ST1FXX range of commands are used. After issuing these commands 3 characters in the form of xxx must be sent to the module as to the number of steps to turn. Fro example to turn 25 steps one has to issue ‘025’ as the module will only accept 3 characters.

There is also the facility to turn both motors simultaneously. The STBFOR and STBBAK commands will turn both stepper motors one step at a time simultaneously. Until now no facility exists to turn both steppers a number of steps at the same time. This has to be done by the controlling software by using a FOR loop. If one of the steppers slips the motor phases can be got back into synchronization by the use of the STSYNC command.

Advanced users may customize the time the phases are switched on especially for the use of multiple commands. By default this is set to 20ms to allow the currents in the motor to stabilize before being changed. This value may be changed to adapt the module to different type of motors and hence have better control over the module.

DC Motors

Commands used to control DC motors

Command Description
DC2FOR DC Motor 2 ON/forward
DC2BAK DC Motor 2 ON/backward
DC1FOR DC Motor 1 ON/forward
DC1BAK DC Motor 1 ON/backward
DCBFOR DC Both Motor forward
DCBBAK DC Both Motor backward

DC motor driving is very easy and straightforward. MotoBox uses bridge switching in order to run the DC motors forward and reverse. Currently MotoBox can drive 2 DC motors each rated at 2A, the maximum current for each driver. Current is always monitored during operation. If the current is above 2A the motors are switched off. This means that if a motor stalls but still consumes less than 2A, MotoBox cannot detect this condition.

The DC motors can be driven simultaneously by using the DCBXXX command set. This will activate both motors instantaneously. It is advised that decoupling capacitors are attached from the lead to the motor’s body and between the terminals near the motor to reduce interference. MotoBox hardware filters off any a.c. components generated by the DC motor during operation thus only the d.c. current is monitored.

Servo Motors

Commands for this section

Command Description
SV2FOR Servo 1 forward
SV2BAK Servo 1 backward
SV2MID Servo 1 Middle position
SV2HLD Servo 1 Hold
SV1FOR Servo 2 forward
SV1BAK Servo 2 backward
SV1MID Servo 2 Middle position
SV1HLD Servo 2 hold

Servo motors are treated differently than the other types of motors. As soon as a servo command is issued a timer routine is setup by the software that provides a pulse to the servo motor every 20ms. There are 36 steps, 18 in each direction to control the motor, which translates to a 5° for each step. The software has been written in a way that if 2 servo motors are being used they are actuated simultaneously. Whilst MotoBox is receiving commands the servo part is turned off. Due to command reception and processing this may mean that the servo may miss a pulse before being actuated again. Also each driver can actuate two servos at the same time with the same position and also drive and monitor the current consumed by each servo.

The only way a servo motor can be turned off is by shutting down the L298 drivers.

It is important to note that once a servo command has been sent the timers cannot be disabled and  MotoBox must be reset.

However it is possible to use a servo motor and a DC/Stepper motor at the same time.

MotoBox protection

Commands in this section

Command Description
AMSTOP Emergency stop. Stop All motors. E.g. OverCurrent
MTYPEX Transmit Motor type back
AMONXX All Motors ON
MONOFF Do not monitor current consumption
CMONON Monitor current consumption
RESUME Enable Motors after overcurrent condition

MotoBox will monitor the current consumed by each overall driver in order to provide a basic level of protection to the module. This is
limited to 2A per channel and the software will switch off both controllers immediately if any of the controllers experience an over current condition. It will than issue an ‘MBS’ command and will only resume operation when the command ‘RESUME’ is sent to the module. The command will turn off the current detectors for the next 200ms to allow the controlling software to issue another command to try and unlock the motor. Take the following situations:

  • The module is being used to control the motion of a robot and the robot wheel got stuck resulting in too much current being consumed by the module. The controlling software has the chance to resume operations and immediately send the wheel in reverse to get it unstuck. If this is successful the module will report correction operation and the fault has been put right.
  • A short circuit in one of the motor windings has occurred and the module has shut off itself. If after the module has been resumed a second short circuit condition has been detected than it can assumed that one of the motors has suffered some damage and needs to be inspected.

Also current monitoring in the module can be switched off. Although this feature is available it is not recommended to be used. If during operation the controlling software wants to know what type of motor is being driven an ‘MTYPEX’ command may send and it will return the current type of motor used, according to the last issued command. The supported list is as follows :

No motor     ‘N’
Stepper     ‘S’
DC motor     ‘D’
Servo    ‘R’

Full Command Set for MotoBox