Let’s Arduino Control Your SmartDriveDuo-10

Cytron’s 1st smart motor driver dual channels is ready! SmartDriveDuo10 is smart brush motor driver, support dual channels, 10A continuous current for each channel. Building combat/sumo robot become easy, choose motor + wheel, get a proper battery, connect it to MDDS10, choose a RC controller and you have a robot !! Do check the User’s Manual for details. However there still have users ask how to control MDDS10 with Arduino. Maybe they want to make their robot smarter? Of cause it can, anything is possible with Arduino. So this is tutorial will help you achieve that.

IMG20170302094352

First of all, we need to set mode for MDDS10 to determine what kind of program to be write in Arduino. So currently we have 3 modes which suitable for that:
1. PWM mode: Independent Both (0b10110100)
2. Serial Simplified: Set baud rate to 9600 (0b11001100)
3. Serial Packetized: Set ID to 0 (0b11100000)

PWM Mode - Independent Both

  1. Program your Arduino with the following codes. Then disconnect Arduino from USB.
    int DIG1 = 4; // Arduino pin 4 is connected to MDDS10 pin DIG1.
    int DIG2 = 7; // Arduino pin 7 is connected to MDDS10 pin DIG2.
    int AN1 = 5; // Arduino pin 5 is connected to MDDS10 pin AN1.
    int AN2 = 6; // Arduino pin 6 is connected to MDDS10 pin AN2.
    void setup()
    {
    pinMode(DIG1, OUTPUT); // Set Arduino pin 4 (DIG1) as output.
    pinMode(DIG2, OUTPUT); // Set Arduino pin 7 (DIG2) as output.
    pinMode(AN1, OUTPUT); // Set Arduino pin 5 (AN1) as output.
    pinMode(AN2, OUTPUT); // Set Arduino pin 6 (AN2) as output.
    delay(5000); // Delay for 5 seconds.
    }
    void loop()
    {
    //   Controlling motor 1.
    analogWrite(AN1, 100); // Set motor 1 speed less than half. Max is 255.
    digitalWrite(DIG1, LOW); // Motor 1 start moving for 2s.
    delay(2000);
    digitalWrite(DIG1, HIGH); // Motor 1 move to another direction for 2s.
    delay(2000);
    analogWrite(AN1, 0); // Stop motor 1.
    delay(1000); // Delay for 1s
    // Controlling motor 2.
    analogWrite(AN2, 100); // Set motor 2 speed less than half. Max is 255.
    digitalWrite(DIG2, LOW); // Motor 1 start moving for 2s.
    delay(2000);
    digitalWrite(DIG2, HIGH); // Motor 1 move to another direction for 2s.
    delay(2000);
    analogWrite(AN2, 0); // Stop motor 2.
    delay(1000); // Delay for 1s
    }
  2. Set switch mode to 0b10110100.
  3. Connect all wires as show as below and last connect battery. PWM MDDS10
  4. Once the MDDS10 and Arduino is powered up (all connection complete), both motor will start running alternately.

Serial Simplified - Baudrate 9600

  1. Program your Arduino with the following codes. Then disconnect Arduino from USB.
    /*
    This example shows how to control MDDS10 in Serial Simplified with Arduino.
    Set MDDS10 input mode to 0b11001100
    Serial data (8-bits): 0bMDSSSSSS
    M: Select motor, 0 for left, 1 for right.
    D: Direction, 0 for CW, 1 for CCW.
    SSSSSS: Motor speed.
    Example: Value in Decimal
    0 or 64 - motor LEFT stop.
    63 - motor LEFT full forward.
    127 - motor LEFT full reverse.
    128 or 192 - motor RIGHT stop.
    191 - motor RIGHT full forward.
    255 - motor RIGHT full reverse.
    Reference Tutorial:
    - Let's Arduino Control Your SmartDriveDuo-10
    Related Products:
    - SmartDriveDuo-10: http://cytron.com.my/c-93-dc-motor-driver/p-mdds10
    - CT UNO: http://www.cytron.com.my/p-ct-uno
    - DC Brush Motors: http://www.cytron.com.my/c-84-dc-motor
    - LiPo Battery: http://www.cytron.com.my/c-87-power/c-97-lipo-rechargeable-battery-and-charger
    URL: http://www.cytron.com.my
    */
    #include <SoftwareSerial.h>
    SoftwareSerial MDDS10Serial(2, 3); // RX (not use), TX
    void setup()
    {
    MDDS10Serial.begin(9600); // Initialize serial
    delay(5000); // Delay for 5 seconds.
    }
    void loop()
    {
    MDDS10Serial.write(32); // Motor left start moving with half speed for 2s.
    delay(2000);
    MDDS10Serial.write(120); // Motor left move to another direction with half speed for 2s.
    delay(2000);
    MDDS10Serial.write((byte)0); // Motor left stop.
    delay(1000); // Delay for 1s.
    MDDS10Serial.write(160); // Motor right start moving with half speed for 2s.
    delay(2000);
    MDDS10Serial.write(224); // Motor right move to another direction with half speed for 2s.
    delay(2000);
    MDDS10Serial.write(128); // Motor right stop.
    delay(1000); // Delay for 1s.
    }
  2. Set switch mode to 0b11001100.
  3. Connect all wires as show as below and last connect battery.serial simplified & packetized MDDS10
  4. Once the MDDS10 and Arduino is powered up (all connection complete), both motor will start running alternately.

Serial Packetized - ID is 0

  1. Program your Arduino with the following codes. Then disconnect Arduino from USB.
    /* 
    * This example shows how to control MDDS10 in Serial Packetized with Arduino.
    * Set MDDS10 input mode to 0b11100000
    *
    * Serial Packet:
    *   1st byte: Header.
    *   2nd byte: Channel & Address.
    *   3rd byte: Speed & Direction.
    *   4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    *
    * For more information, please refer to MDDS10 User's Manual
    * https://docs.google.com/document/d/1ECKsH1WfgZLomwFoPQ8PlkUzVEm88A6Sup9X0wDBHKA/view
    *
    * Reference Tutorial:
    * - Let's Arduino Control Your SmartDriveDuo-10
    *
    * Related Products:
    * - SmartDriveDuo-10: http://cytron.com.my/c-93-dc-motor-driver/p-mdds10
    * - CT UNO: http://www.cytron.com.my/p-ct-uno
    * - DC Brush Motors: http://www.cytron.com.my/c-84-dc-motor
    * - LiPo Battery: http://www.cytron.com.my/c-87-power/c-97-lipo-rechargeable-battery-and-charger
    *
    * URL: http://www.cytron.com.my
    */
    #include <SoftwareSerial.h>
    SoftwareSerial MDDS10Serial(2, 3); // RX (not use), TX
    void setup()
    {
    MDDS10Serial.begin(9600); // Initialize serial
    delay(2000); // Delay for 2 seconds.
    MDDS10Serial.write(85); // Dummy byte for auto baudrate.
    delay(3000); // Delay for 3 seconds.
    }
    void loop()
    {
    // Controlling left motor, direction CW
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write((byte)0); // 2nd byte: Channel = left & Address = 0.
    MDDS10Serial.write(63); // 3rd byte: Speed = half & Direction = CW.
    MDDS10Serial.write(85 + 63); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(2000);
    // Controlling left motor, direction CCW
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write((byte)0); // 2nd byte: Channel = left & Address = 0.
    MDDS10Serial.write(192); // 3rd byte: Speed = half & Direction = CCW.
    MDDS10Serial.write(85 + 192); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(2000);
    // Stop left motor
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write((byte)0); // 2nd byte: Channel = left & Address = 0.
    MDDS10Serial.write(127); // 3rd byte: Speed = 0.
    MDDS10Serial.write(85 + 127); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(1000); // Delay for 1s.
    // Controlling right motor, direction CW
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write(8); // 2nd byte: Channel = right & Address = 0.
    MDDS10Serial.write(63); // 3rd byte: Speed = half & Direction = CW.
    MDDS10Serial.write(85 + 8 + 63); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(2000);
    // Controlling right motor, direction CCW
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write(8); // 2nd byte: Channel = right & Address = 0.
    MDDS10Serial.write(192); // 3rd byte: Speed = half & Direction = CCW.
    MDDS10Serial.write(85 + 8 + 192); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(2000);
    // Stop right motor
    MDDS10Serial.write(85); // 1st byte: Header.
    MDDS10Serial.write(8); // 2nd byte: Channel = right & Address = 0.
    MDDS10Serial.write(127); // 3rd byte: Speed = 0.
    MDDS10Serial.write(85 + 8 + 127); // 4th byte: Checksum = 1st byte + 2nd byte + 3rd byte.
    delay(1000); // Delay for 1s.
    }
  2. Set switch mode to 0b11100000.
  3. Connect all wires as show as below and last connect battery.serial simplified & packetized MDDS10
  4. Once the MDDS10 and Arduino is powered up (all connection complete), both motor will start running alternately.

References

Page

, , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *