HCR-Mobile_robot_platform_V2.0__SKU_ROB0004_-DFRobot

Introduction

The HCR Mobile Robot Kit is a two wheel drive mobile robot platform which has three levels included (if you want, you can use only the parts you need, or make a two level robot). The kit includes two motors, 2 wheels (and one rotating third wheel) and all associated plates and hardware. The supports include spaces for servos and sensors and the base has holes specifically for mini-its motherboards. This is a second release of the HCR. In this update, new motors and new wheels have been updated. The composition of the sensors is changed. Now, there are 6 URM sensors in 6 different directions. And about the new motor, this is DFRobot customized high quality DC motor. The best part of this motor is that it is a quiet and high torque output motor with optical encoder building. The optical encoder gives 663 pulse per rotation which is able to sensor 0.54 degree rotation from the shaft. The resolution can meet a general PID speed control requirements. A new level for users to do more interesting things. Like a Kinect for XBOX 360.

Specifications

Part List

Hardware Architecture

Picture1 the hardware architecture

Connection

GMR Board

Attention: The yellow wires are jump wires.

And for this GMR board 3 microcontrollers should be used. Two Arduino Nano and one Arduino Mega ADK. One of Nano to control the motors and the other used to drive 6 URM sensors. And the Main microcontroller is the Mage ADK, it is used to collect the date and transfer it. There are two Wireless slots for Xbee, blueteeth and other wireless communications. In this case, we just need one Nano to drive the motors.

Switch System

Testing

Guide

Software Architecture

In this part, the example code of the HCR will be listed, It is written by Arduino, include the motor control, bumper and the IR sensor.

Arduino IDE 1.0.x

The code can only be used by IDE over 1.0

All hardware can be drive by Adruino

Code on Arduino Nano control the motor: If use the Sabertooth motor control, the motor can be control by <serve.h> perfect.

#include <Servo.h>
Servo Lmotor;
Servo Rmotor;
float Lspeed = 0; //from 0-180, 0 means max speed forwards, 180 means max speed backwards 90 means stop
float Rspeed = 0; //from 0-180,

void setup()
{
  Lmotor.attach( 9, 1000, 2000);
  Rmotor.attach( 10, 1000, 2000);
}

void loop()
{
   Lmotor.write(Lspeed);
   Rmotor.write(Rspeed);
   delay(500);
} // use this code to control the HCR move

If use the DC Motor Driver 2×15A – Lite

#define LF 0
#define RT 1
int E1 = 9;     //M1 Speed Control
int E2 = 10;     //M2 Speed Control
int M1 = 8;     //M1 Direction Control
int M2 = 11;     //M1 Direction Control
int a;
int b;
int counter=0;

void setup()
{
  int i;
  for(i=4;i<=7;i++)
  pinMode(i, OUTPUT);
  Serial.begin(57600);      //Set Baud Rate
  Serial.println("Run keyboard control");
  digitalWrite(E1,LOW);
  digitalWrite(E2,LOW);
}

void loop()
{
  Motor(2000,LF);
  Motor(1000,RT);
}

void Motor(int value,byte whichwheel)
{
  value = constrain(value,1000,2000);
  if(whichwheel == LF) {
    if(value>1500) {
      a=(value-1500)/1.961;
      analogWrite (E1,a);
      digitalWrite(M1,HIGH);
    }
    else {
      a=(1500-value)/2;
      analogWrite (E1,a);
      digitalWrite(M1,LOW);
    }
  }
  else if(whichwheel == RT){
    if(value>1500) {
      b=(value-1500)/1.961;
      analogWrite (E2,b);
      digitalWrite(M2,HIGH);
    }
    else {
      b=(1500-value)/2;
      analogWrite (E2,b);
      digitalWrite(M2,LOW);
    }
  }
}

The first thing is make the wheels move

BumperFunction.h

#include "Arduino.h"

int BumperR_pin;
int BumperL_pin;
int BumperC_pin;
byte BumperValue;
boolean blocked = false;
void OpenBumper(int,int,int);
void bumperRead();
/*************************** Details *****************************/


void OpenBumper(int LIO,int CIO,int RIO)
{
  BumperL_pin = LIO;
  BumperC_pin = CIO;
  BumperR_pin = RIO;

  pinMode(BumperL_pin,INPUT);
  pinMode(BumperC_pin,INPUT);
  pinMode(BumperR_pin,INPUT);
}
/*************************************************Bumper Sensor Status***********************************/
void bumperRead()
{
  BumperValue = 0x07;
  BumperValue=digitalRead(BumperL_pin)<<2;
  BumperValue|=digitalRead(BumperC_pin)<<1;
  BumperValue|=digitalRead(BumperR_pin);
//  Serial.println(BumperValue,BIN);
}

Code of the IR sensor:

/********************** IR sensor ***********************/
void IRreader()//detect distance on both sides
{
  static float IRdata[IrNumber] = {
    80,80,80,80,80                  };
  for(int h=0;h<IrNumber-2;h++)
  {
    float volts = analogRead(h + 1);
    _iR[h] = (6787 / (volts - 3)) - 4;
    if(_iR[h]<10)   _iR[h] = 80;
    _iR[h] = min(_iR[h],80);
    _iR[h] = max(_iR[h],12);
  }
    for(int h=5;h<7;h++)
    {
      float volts = analogRead(h-4);
      _iR[h] = (6787 / (volts - 3)) - 4;
      if(_iR[h]<10) _iR[h] = 80;
      _iR[h] = min(_iR[h],80);
      _iR[h] = max(_iR[h],12);
    }
  for(int h = 0 ; h < 5 ; h++)
  {
    _iR[h] = smooth(_iR[h],0.9,IRdata[h]);
    IRdata[h] = _iR[h];
  }
}
float smooth(float newdata, float filterVal, float smoothedVal)
{
  if (filterVal > 1)
    filterVal = .99;
  else if (filterVal <= 0)
    filterVal = 0;
  smoothedVal = (newdata * (1 - filterVal)) + (smoothedVal  *  filterVal);
  return smoothedVal;
}

Reference

The specifications of all the hardware.

Master: Arduino Mega ADK/2560

Use to transfer the date and drive the Bumpers/IR sensors.

  1. DFRduino MEGA ADK

Slaver: Arduino Nano

Use to drive the motors and with the help of encoder, the motor can do the close loop.

  1. DFRduino Nano V3.1

Motor Control

DC Motor Driver 2×15A – Lite/ Sabertooth dual 12A motor driver

Sabertooth dual 12A motor driver

  1. Sabertooth dual 12A motor driver

DC Motor Driver 2×15A – Lite

  1. 2×15A DC Motor Driver

Motor

12V high quality and quiet DC Motor 146rpm w/Encoder

  1. 12V high quality and quiet DC Motor

Xbee/Wifi/Bluetooth:

Can be connect on the Master then giving a method to control the HCR by wireless.

IR sensor: Sharp GP2D12

  1. Sharp GP2Y0A21 IR Distance Sensor

Bumper

Use digital pins.

DFshopping_car1.png Get HCR - Mobile Robot Platform (Support Kinect) from DFRobot Store or DFRobot Distributor.

Turn to the Top