Let's Make Robots!

Dagu 4 channel motor controller

I just got the dagu 4 channel motor controller and will very soon be recieving a set of four (2 left, 2 right) mecanum wheels. I want to use this motor controller with my mecanum wheels for the project that i am working on right now, but I have abslutely no idea how to program this motor cotroller, even for a normal drive system (I haven't ever used actual motors, only servos, so of course i havent used a motor controller either. If anybody knows how to do this, I would appreciate the help. Also, I have no idea how to physically connect any of the pins, besides of course the motor battery and from the motors to the motor controller. I would also appreciate help with the hardware connections. Pictures would be good too. Thanks to everyone who can help in advanced.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

One other thing, I am not really clear, but when I use four motors, the voltage from the battery is divided by four. So then, for example, if the battery is 7.2v, then each channel would get 1.8v. Please correct me if this is wrong, as I need a certain amount, definetely more than 1.8v per channel, so I might need to get some different motors.

7.2 volts to each motor. Your motors will pull all the current they need to move from said batteries.

Ok so based on what you said, what kind of switch setup would you propose for this in order to not ruin the motor controller.

PS: I still haven't used the motor controller so if there are any hardware problems with the motor controller, it was something caused during the manufacturing.

Since you are a complete beginner I should first warn you that the controller may be damaged if you do not connect power correctly. The 5V logic supply should always have power when the motors do so you should always have 1 switch for all power. Many people have damaged these by having two power supplies and switching the motor power supply separately.

The motor power should be no more than 12V. The logic should always be 5V.

As Birdmun said, the DIR pin cotrols the direction of the motor. the PWM pin controls the speed. You can also use the PWM pin as a simple on/off with a high signal (5V) being on and low (0V) being off.

All 4 motor controllers are the same so it might be best just to experiment with 1 motor 1st.

Do not worry about the encoder pins unless you are using encoders. At this stage I suggest you do not worry about encoders until you understand the basics of controlling a motor.

The Dir pin, for each motor controller, controls the direction of each, individual motor. That means the Dir pins will be digital; 1 is forward and 0 is reverse. PWM goes to individual PWM pins to set the speed of each motor. Savvy?

As for programming, choose any arduino program that controls a wheeled bot and uses PWM (analogWrite). Just realize that most of those are written for motor shields and they have a total of 3 pins per motor. All you need to do is trim that number to 2 per motor, 1 digital and 1 analog.

It will be something like:

const int leftFrontDirection //choose a pin number
const int leftRearDirection //choose another pin
const int rightFrontDirection //choose another pin
const int rightRearDirection //choose another pin
const int leftFrontSpeed //choose a PWM pin
const int leftRearSpeed //choose another PWM pin
const int rightFrontSpeed //choose another PWM pin
const int rightRearSpeed //choose another PWM pin
const int stop = 0; // the next 4 numbers are for example only
const int slow = 85;
const int medium = 170;
const int fast = 255;
const int forward = 1;
const int reverse = 0;

void setup() {
pinMode ( leftFrontDirection, OUTPUT );
pinMode ( leftRearDirection  , OUTPUT ); 
pinMode ( rightFrontDirection  , OUTPUT ); 
pinMode ( rightRearDirection  , OUTPUT );
pinMode ( leftFrontSpeed  , OUTPUT ); 
pinMode ( leftRearSpeed , OUTPUT ); 
pinMode ( rightFrontSpeed  , OUTPUT );
pinMode ( rightRearSpeed  , OUTPUT );
}

void loop() {
//move forward slow for 1 sec
move(forward, forward, slow);
delay(1000); 
//move forward medium for 1 sec
move(forward, forward, medium);
delay(1000);
//reverse fast for 1 sec
move(reverse, reverse, fast);
delay(1000); 


void move(int leftDirection, int rightDirection, int speed) {
digitalWrite( leftFrontMotorDirection, leftDirection );
digitalWrite( leftRearMotorDirection, leftDirection );
digitalWrite( rightFrontMotorDirection, rightDirection );
digitalWrite( rightRearMotorDirection, rightDirection );
analogWrite( leftFrontMotorSpeed, speed );
analogWrite( leftRearMotorSpeed, speed );
analogWrite( rightFrontMotorSpeed, speed );
analogWrite( rightRearMotorSpeed, speed );

I hope that code will work for you. I am sure someone will straighten it out if need be. :)

sorry, accidentally posted the last reply twice

I have already seen this, and after a bit more scrounging, I am mostly fuzzy on the encoder part of this. I still have no idea about that. Do you know what the Dir pins connect to. Also, keep in mind, the main focus of this post is the programming, so if you have a sample code or something I could get in order to study so that I can kind of figure out the programming for the encoder and current pins, that would be very appreciated as well

I have already seen this, and after a bit more scrounging, I am mostly fuzzy on the encoder part of this. I still have no idea about that. Do you know what the Dir pins connect to. Also, keep in mind, the main focus of this post is the programming, so if you have a sample code or something I could get in order to study so that I can kind of figure out the programming for the encoder and current pins, that would be very appreciated as well

check this link and let us know if you understand it. :)

http://letsmakerobots.com/node/27513