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.
Why don’t you
check this link and let us know if you understand it.
I have already seen this,
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
the last post
sorry, accidentally posted the last reply twice
Let’s see if I can answer two of your questions.
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.
The switch for power
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.
power
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.
Your batteries will feed
7.2 volts to each motor. Your motors will pull all the current they need to move from said batteries.