Mixing RC Signals for Robot Drive Control


Mixing RC transmitter signals for robot drive control is easy with out BM011 Dual Motor Quad Servo Controller.  This is a design we’ve been working on for a bit, and the test software and microcontroller firmware are ready to release.  This is a completely open source hardware design.  The BM011 can be used to control two DC motors, can output 4 0.5mS-2.5mS pulses for driving RC servos, and read up to 4 servo channels.  Files should be available on our web site within a couple of weeks.

In the short term, I thought I’d cover a unique test feature of the product and our VB test software.  The BM011 is designed to be controlled via a serial interface.  This allows a separate controller to send simple commands to set servo output pulses, motor speed and direction, and read incoming RC pulses, without using on-board resources.  But if you want to do some testing of the servo signal mixing you can do that with out test software and some mode settings in the BM011.  Using our BM010 USB to serial port module is an easy way to connect the BM011 motor controller to a serial port.


In mixer mode we read the servo pulses on servo input channels 3 and 4 and convert them into motor drive signals.  You can use the test software to simulate RC signals by adjusting the BM011’s Mode register.  To use the software you check “Mix servo inputs 3 and 4…” and “Don’t read servo inputs 3 and 4” boxes  and press the “Update Mode Register” button (highlighted in the software window above).  These first check box tells the BM011 motor driver to use, and mix, the input values from servo inputs 3 and 4 to derive motor drive signals.  The last check box also tells the BM011 not to actually read the signals from the input pins.  This allows you to modify those registers with the serial interface and software.  The end result is that our test software allows you to test a robot drive system without actually using the RC receiver.

You can then use the Servo In 3 and Servo In 4 slide bars to change your motor speeds and test your system.

A little bit about mixing:
With the BM011 the servo input signals are read and converted to 10uS increments (50-250 => 500uS to 2500uS).  Values outside this range are normally set to 0 to indicate a bad signal.  In the mixer mode of operation we set bad signals to 150 to allow the motors to stop. Additionally, the motor outputs run from 1 to 254 with 254 being full forward and 1 being full reverse (127-128 are stopped).  In mix mode the full span of PWM output is restricted.  The equations used to mix the signals are shown below.  This is C code firmware for the PIC16F1829, and the entire source code will be posted online when the product is ready for resale.

    // Mix mode uses servo in channels 3 and 4 to create drive
    // signals for motors 1 and 2
    if (MODE.Bits.MIX_MODE)
        // handle special case of bad signal
        ServoMix3 = (int)NV.Bytes.Servo_In3;
        if (ServoMix3 == 0) 
            ServoMix3 = 150;
        // limit servo input values to 100-200
            if (ServoMix3 > 200)
                ServoMix3 = 200;
            if (ServoMix3 < 100)
                ServoMix3 = 100;
        ServoMix4 = (int)NV.Bytes.Servo_In4;
        // handle special case of bad signal
        if (ServoMix4 == 0)
            ServoMix4 = 150;
        // limit servo input values to 100-200
            if (ServoMix4 > 200)
                ServoMix4 = 200;
            if (ServoMix4 < 100)
                ServoMix4 = 100;
        // Servo in 3 signal is used for speed while servo in signal 4
        // determiness turning.
        Motor1 = (150-ServoMix4)+(ServoMix3-150);
        Motor1 = (Motor1*127/100)+127;
        if (Motor1 > 254)
            Motor1 = 254;
        if (Motor1 < 1)
            Motor1 = 1;
        NV.Bytes.Motor1 = Motor1;

        Motor2 = (150-ServoMix4)-(ServoMix3-150);
        Motor2 = (Motor2*127/100)+127;
        if (Motor2 > 254)
            Motor2 = 254;
        if (Motor2 < 1)
            Motor2 = 1;
        NV.Bytes.Motor2 = Motor2;


The firmware above converts allows the CH3 input to control speed and the CH4 to control steering in a skid steering two-wheel robot drive. I’ve added an Excel screen capture to show some of the output values associated with specific RC signals.  Once your mechanical system is tested and you want to use actual RC pulses to control the robot you simple uncheck the “Don’t read servo inputs 3 and 4” check box and press the “Update Mode Register” button.  To make the setting non-volatile you press the “Store Settings in EEPROM” button.


Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.