Dagu Rover 5 chassis robot demo

So I finally connected together a few things that arrived in the mail. :slight_smile:

This incredibly-sloppily wired-up robot is my first attempt to make something useful, eg. that will one day deliver a can of beer to my hands. :wink:

Right now it's a prototype. :stuck_out_tongue:

It consists of a Dagu 5 chassis which I bought from here:

http://www.robotgear.com.au/Product.aspx/Details/554

(There are suppliers overseas too).

I also got their controller board which supports up to 4 motors and encoders.

At this stage the encoders are not used (although you may spot the wiring for them on the top). There is interrupt-driven code in the sketch to detect one of the encoders.

To help others get started, here is how I wired it up:

![](http://gammon.com.au/images/Dagu Controller.png)

The battery is actually 6 x 1.5 NiMh batteries taped to the side.

This is the sketch:

// Dagu 5 Chassis example.
// Author: Nick Gammon
// Date:   11th December 2011

volatile int rotaryCount = 0;

#define PINA 8
#define PINB 9
#define INTERRUPT 0  // that is, pin 2

#define DIRECTIONA 4
#define MOTORA 5

#define DIRECTIONB 7
#define MOTORB 6

#define TIME_FORWARDS 10000
#define TIME_BACKWARDS 10000
#define TIME_TURN 1200

// Interrupt Service Routine for a change to encoder pin A
void isr ()
{
  boolean up;

  if (digitalRead (PINA))
    up = digitalRead (PINB);
  else
    up = !digitalRead (PINB);

  if (up)
    rotaryCount++;
  else
    rotaryCount--;
}  // end of isr


void setup ()
{
  attachInterrupt (INTERRUPT, isr, CHANGE);   // interrupt 0 is pin 2, interrupt 1 is pin 3
  pinMode (MOTORA, OUTPUT);
  pinMode (DIRECTIONA, OUTPUT);
  pinMode (MOTORB, OUTPUT);
  pinMode (DIRECTIONB, OUTPUT);

}  // end of setup

byte phase;
unsigned long start;
int time_to_go;

void loop ()
{

  analogWrite (MOTORA, 200);
  analogWrite (MOTORB, 200);
  start = millis ();
  
  // check current drain
  while (millis () - start < time_to_go)
    {
    if (analogRead (0) > 325)  // > 1.46 amps
      break;    
    }
    
  
  switch (phase++ & 3)
    {
    case 0: 
      digitalWrite (DIRECTIONA, 1); 
      digitalWrite (DIRECTIONB, 1); 
      time_to_go = TIME_FORWARDS;
      break;
      
    case 1: 
      // turn
      digitalWrite (DIRECTIONA, 1); 
      digitalWrite (DIRECTIONB, 0); 
      time_to_go = TIME_TURN;
      break;

    case 2: 
      digitalWrite (DIRECTIONA, 0); 
      digitalWrite (DIRECTIONB, 0); 
      time_to_go = TIME_BACKWARDS;
      break;

    case 3: 
      digitalWrite (DIRECTIONA, 0); 
      digitalWrite (DIRECTIONB, 1); 
      time_to_go = TIME_TURN;
      break;
      
    } // end of switch
    
  analogWrite (MOTORA, 0);
  analogWrite (MOTORB, 0);
  delay (500);
  
}  // end of loop

And this is the robot banging into walls (52 seconds):

The code is designed to drive the robot forwards or backwards for 10 seconds. Then it attempts to turn by driving the wheels in opposite directions for 1.2 seconds.

The current-sense circuit is used to detect too much load on the motors, if that happens the code immediately skips to the next phase.

There are quite a few improvements that could be made. For one thing, it needs a beer carrier. :wink:

It also could use a sensor to detect nearby obstacles. And a smarter algorithm would help it get out of being stuck in tight places. Oh, and it needs a sensor to stop it turning upside-down and spilling its guts.

This photo, taken after I neatened up the wiring with a my wire-wrapping tool, shows the connections between the motor board and the Arduino:

![](http://gammon.com.au/images/Dagu Photo.png)

hello nick gammon....thanks for information provided but i need to know what the controller board, which you have used to support the rover 5 is called as...because the doing a project with arduino and planning to buy the rover 5 for my project...

Hi Nick,

I don't know if they are available in your part of the world, but this might fit - http://www.amazon.co.uk/Bigtrak-Can-Holder-Junior/dp/B005G3R4Z0

Been meaning to get one for my BigTrak. Also been meaning to make my BigTrak autonomous, but I only got it for Christmas, and I think it might be too soon to start tearing it apart.

Only problem with the can holder is that it'd need someone in the kitchen to put the can in.

dxw00d:
Hi Nick,

I don't know if they are available in your part of the world, but this might fit - http://www.amazon.co.uk/Bigtrak-Can-Holder-Junior/dp/B005G3R4Z0

Been meaning to get one for my BigTrak. Also been meaning to make my BigTrak autonomous, but I only got it for Christmas, and I think it might be too soon to start tearing it apart.

Only problem with the can holder is that it'd need someone in the kitchen to put the can in.

I wonder if that'll fit the original Big Trak (still have mine from when I was a kid; then again, I have the transport dumper, so maybe I don't need the can holder...)?

:slight_smile:

It should fit. I think the mouldings are the same.

krishna84:
hello nick gammon....thanks for information provided but i need to know what the controller board, which you have used to support the rover 5 is called as...because the doing a project with arduino and planning to buy the rover 5 for my project...

The link above would have led you to it, but here is the controller:

No doubt there are non-Australian suppliers as well.

Nice to see another Rover 5 :slight_smile: I bought one a couple of weeks ago. I've managed to write a sketch that lets me remote control it through a Nrf24L01 wireless module. I'm using the Mega1280 based Dagu red back spider controller and motor controller. Power comes from a 2 cell lipo battery. Here's a video of mine:

I also have the version with 4 encoders/motors, but don't really have a clue what to do with the encoders :~

Bajdi:
I also have the version with 4 encoders/motors, but don't really have a clue what to do with the encoders :~

Very cute!

I'm not using the encoders right now, but what you could do with them is find how far it has gone. For example, you put out "full power" but you don't know whether, after 3 seconds, you have gone one foot or five. Reading the encoder data back would tell you how much the wheels have moved. Off course that doesn't take into account the wheels slipping.

Nick
I heard of one guy using the guts of an optical mouse, in a sumobot.
He simply detected if he was moving backwards while he was driving the wheels forward and acted on it.

This might help overcome the slippery surface issues.

Mark

hello everyone...i am doing a project which has three sensors, which when detects anything moves in other direction. For these work i am planning to going with rover 5 and also going with encoder compatible board(nick as suggested) but i guess i need some help with stuff....new for these kind of stuff...

hi nick...i am really sorry for the way of the message...i guess its hurt u alot...really sorry for that...i was trying get some information from you and i was in a little hurry...that's it....actually i am trying to develop a robot which should have three sensor's..as it detects something..the vehicle should move...its my final project....

krishna84:
... i guess its hurt u alot...really sorry for that...

This is referring to a couple of personal messages I received in the last few days which shouted at me in all caps.


krishna84:
... i guess i need some help with stuff....

@krishna84 - I'm sorry but I don't see a question here. No wonder no-one else has answered.

krishna84:
actually i am trying to develop a robot which should have three sensor's..as it detects something..the vehicle should move.

What sensors? We can't read your mind you know. Motion detectors? Sound? Light? Colour? Distance? "as it detects something" ... what? A cat? A wall? A hand? A line? A hole?

Read this:

I'm not going to sit here and design a cat-avoidance system so you can pass your final project in your exam. At least try something yourself. Choose some sensors. Post a link to them. Show how you wired them into your project (photo or schematic). If you don't know how to do that Google it and find out. If you can't make it work then, at least show how far you got, including links to the web sites you found with Google. If you write some code, post it. If it doesn't work, describe in what way.

In your first post you said that the rover is sloppily wired. I got my share of that today, and needed to perform some surgery on my rover. I was trying out a sketch and suddenly one motor stopped running. I was fearing the worst thinking that one of the FETs on the motor controller had given up. Turned out to be a loose wire... one of the wires going from the coil to the connector had come loose. There was almost no solder to be seen on that connection so it's no surprise it came loose.
I've been working on an autonomous sketch using an ultrasonic sensor to detect obstacles. The code works but it keeps bumping into stuff. Think I need some more sensors and fancier code :slight_smile:

This incredibly-sloppily wired-up robot is my first attempt to make something useful, eg. that will one day deliver a can of beer to my hands

Something like this?

robtillaart:
Something like this?

Exactly like that. :slight_smile:

Nick,

I have the same setup as you to in this tutorial, but i cannot get the bot to move for more than .5 seconds per direction. I havent changed any code at all and double checked the wiring.

Also in the code, to a novice, it appears you are using pins 8 and 9 as pin A & B respectively, but in the diagram they are not hooked up.. Could you please explain that to me.

Thanks!

Pins 8 and 9 were for the rotary encoders which I didn't use in the end, although the article talked about them.

It stops after about a second if it doesn't get another message from the remote, so it sounds like the connection might be flaky.

You could change this:

const unsigned long TIME_BEFORE_WE_GIVE_UP = 1000;  // ms

Where 1000 mS is 1 second. But you probably need to work out the underlying problem. Do you have an aerial at all? I stuck a short bit of wire in to help with that.

Also for the interrupt 0 assignment, that doesnt seem to be hooked up either,. Sorry I am rather new at this.

To clarify, my rover is going thru the fwd, left, backwards, right sequence but it is only moving for like .25 to .5 a sec before changing to the next direction in the list.

Oh I thought you were referring to this:

The forum is incredibly slow right now, it's taking 5 minutes for a page to load, so please bear with me.

Here, in the code on page 1 of this thread:

  delay (500);
  
}  // end of loop

So it changes direction every 1/2 a second. Change that to a bigger figure if you want.

The forum is incredibly slow right now, it's taking 5 minutes for a page to load, so please bear with me.....

Your not alone, the site is sooo slow lately. Whats goin on? ... Wait don't answer that. I will start my own thread to hijack.