WIFI Robot Maneuver With MDDS10

WIFI Robot Maneuver With MDDS10

 

Introduction

Building a mobile robot from the scratch is always feels great. Apart from the fun part, there are few things that need be taken care such as voltage required, type of motor, type of tire and also the motor driver. Motor driver is one of the most important device that will effect the performance of the robot. Cytron has a number of different type of motor driver which suite for different purposes. For this project, i have decided to go with the MDDS10 motor driver. So what is MDDS10?

What is MDDS10?

 

screenshot 2022 09 20 at 14 13 25 smartdriveduo 10 40474 800x800.webp webp image 800 × 800 pixels

MDDS10 is the SmartDriveDuo-10 whereby it has the specification of MDD10A which is capable to drive two brushed motors bidirectionally at 10Amps each and with the addition of smart features of MDS40A. The operation mode is configured by the DIP switch on MDDS10. The DIP switch configurations for commonly used modes are printed at the back of PCB as shown in the figure below.

smartdriveduo 10 a3771 800x800 1

Another feature of the MDDS10 is that it can be used to control DC brushed motor with these different signals.

  • RC (Radio Control)
  • PWM of microcontroller
  • Analog voltage of Potentiometer/Variable Resistor
  • UART/Serial command of microcontroller

 

mdds10a overview

Based on the figure above, it shows the simplified view of the function of the motor driver. That's a brief introduction on the MDDS10. The components or devices that are used in this project are as shown in the next section.

Hardware Setup

This are the devices used in this project.

wifi manuveur robot with mdds10 time 0 00 2624

These are the main component used and there are other miscellaneous components used such the grove cable and wire. Below shows how the connection is done between the devices.

 

connecting the components

Once the main connection are done, next can start to connect the motor and the power respectively. For the base of the robot, it is designed using the Tinkercad. Below are the design of the robot base.

 

3d design
The design can be downloaded from the link here : https://www.tinkercad.com/things/d3EJgWYqWzu?sharecode=sJOhjH3zcDGHaK-pXD0_qKOpJzbZKgG_foj1k1r04f4

The next is to assemble the electronic components on the 3D printed parts. And the final look will be like the figure below

 

photo 2022 09 20 17 06 19

Now we can start to code.

 

Coding

For the coding i have to use the Arduino IDE. The first program that we would like to test is the motor driver. For this we use the code below

int pwm_motor_right=6;                //pwm mottor right connect to AN2 at MDS10
int pwm_motor_left=5;                 //pwm mottor left connect to AN1 at MDS10
int dir_motor_right=4;                //direction mottor right connect to DIG2 at MDS10 
int dir_motor_left=7;                 //direction mottor left connect to DIG1 at MDS10


void setup() {
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  delay(1000);      // to make the input data in low.
  // put your setup code here, to run once:

}

void loop() {
  
  analogWrite(pwm_motor_right,255);
  analogWrite(pwm_motor_left,255);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  analogWrite(pwm_motor_right,127);
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  analogWrite(pwm_motor_right,70);
  analogWrite(pwm_motor_left,70);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  analogWrite(pwm_motor_right,70);
  analogWrite(pwm_motor_left,70);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  analogWrite(pwm_motor_right,127);
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  analogWrite(pwm_motor_right,255);
  analogWrite(pwm_motor_left,255);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
  delay(2000);
  
  
}

Once we have verified the first code. Next we want to check the WIFI connection and connecting it to Blynk. For this we use the code below

 

/*
  Connect RP2040 + ESP8266 board to the new Blynk (https://blynk.io)
  
  Items:
  - Maker Nano RP2040
    https://my.cytron.io/maker-nano-rp2040-simplifying-projects-with-raspberry-pi-rp2040
  - Grove WiFi 8266
    https://my.cytron.io/p-grove-wifi-8266-iot-for-microbit-and-beyond
  
  Connections
  - Grove WiFi to Maker port [0, 1]
  
  External libraries:
  - Blynk by Volodymyr Shymanskyy 1.1.0 (Library Manager)
  - BlynkESP8266 (https://github.com/vshymanskyy/BlynkESP8266)
*/

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID   "YourTemplateID"

#include 
#include 

char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#define EspSerial Serial1
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(115200);
  delay(10);

  EspSerial.begin(ESP8266_BAUD);
  EspSerial.println("AT+RST");
  delay(5000);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
  Blynk.run();
}

 

Once we have verified both the code are working, next we can combine the code. Below is the final code

 


#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID   "YourTemplateID"

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>



char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";



int minRange = 312;
int maxRange = 712;

int minspeed = 70;
int maxspeed = 255;
int nospeed = 0;

#define EspSerial Serial1
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

int pwm_motor_right=6;                //pwm mottor right connect to AN2 at MDS10
int pwm_motor_left=5;                 //pwm mottor left connect to AN1 at MDS10
int dir_motor_right=4;                //direction mottor right connect to DIG2 at MDS10 
int dir_motor_left=7;                 //direction mottor left connect to DIG1 at MDS10


void setup() {

  Serial.begin(115200);
  delay(10);

  EspSerial.begin(ESP8266_BAUD);
  EspSerial.println("AT+RST");
  delay(5000);

  Blynk.begin(auth, wifi, ssid, pass);
  
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  delay(1000);      

   digitalWrite(pwm_motor_right, LOW);
   digitalWrite(pwm_motor_left , LOW);
   digitalWrite(dir_motor_right, HIGH);
   digitalWrite(dir_motor_left, HIGH);

}

void moveControl(int x, int y)
{
  if(y >= maxRange && x >= minRange && x<= maxRange)
    {
  analogWrite(pwm_motor_right,127);      //forward
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,LOW);
    }
    
 else if(y <= minRange && x >= minRange && x <= maxRange)
    {
  analogWrite(pwm_motor_right,127);      //reverse
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,LOW);
  digitalWrite(dir_motor_left,HIGH);
    }

    
  else if(x <= minRange && y >= maxRange)
    {
  analogWrite(pwm_motor_right,127);      //turn left
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,HIGH);
  digitalWrite(dir_motor_left,HIGH);
    }

   else if(x >= maxRange && y >= maxRange)
    {
  analogWrite(pwm_motor_right,127);      //turn right
  analogWrite(pwm_motor_left,127);
  digitalWrite(dir_motor_right,LOW);
  digitalWrite(dir_motor_left,LOW);
    }
    
  else if(y < maxRange && y > minRange && x < maxRange && x > minRange)
    {
        analogWrite(pwm_motor_right,nospeed); //no move
        analogWrite(pwm_motor_left, nospeed);
    }
}

void loop()
{
    Blynk.run();
}

BLYNK_WRITE(V0)
{
    int x = param[0].asInt();
    int y = param[1].asInt();
    moveControl(x,y);
}

"Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application."

Hardware Components