Let's Make Robots!

Rover 5 - Dagu Spider and 4 Channel Motor Controller

Ok so i recently purchased the Rover 5 Kit from Robotsavvy by Dagu.

With Help from Oddbot i have put wires from the encoder into the Motor Controller (in the right place i think)

But i have no idea which pins go to the arduino and also where on the arduino they go to.

 

Image of what ive done and the question :

 

Any help would be appreciated.

 

Bradley.

 

(P.S. I hope this is in the right area)

Comment viewing options

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

So i need just one power source?

As im using two; one for the Motors/Encoders and one for the Spider+Motor Controller Logic.

Is this a bad way of doing it?

Using 2 power Supplies ive got all 4 wheels moving and im about ready to start using IR to control it

 

Is A0 a PWM output? --Be sure it is.

In your main loop, you have dirpin HIGH and the PWM pin maxed out to 255. This is HIGH/HIGH and will not allow your motor to run. I would try a PWM speed of 127 to test.

More about PWM --This one might be a bit funny in your head. Lets assume you have a 75% duty cycle --High for 3/4 of the time and low for 1/4 of the time. Lets also assume your direction pin is low. This will result in 75% speed in that you will have a high/low (on) situation 75% of the time and low/low (off) 25% of the time. Now, lets change that direction pin to high instead to change direction. With this same 75% duty cycle, you will now have a high/high (off) 75% of the time and a low/high situation 25% of the time --this will result in 25% power the other direction. It seems counter-intuitive but to get your 75% power the "other direction" you actually need a 25% duty cycle.

Play around a bit and it should become clear.

Hey Chris, thanks for helping while I was away.

I think you must be talking about a different motor controller as far as the PWM goes. Regardless of the state of the direction pin, 75% PWM will give 75% power with this controller.

Usually in my programs I will set my speed between -255 to +255 with 0 being complete stop. Then the control code becomes very simple.

  digitalWrite(LFDpin,(frontleftspeed<0));       // set Left  Front Motor Direction to forward if speed>0
  analogWrite(LFPpin,abs(frontleftspeed));     // set Left  Front Motor Power to the asolute value of the speed.

 

Hmmm.. I'd like to see the schematic on this one...

I assumed that with a single "direction" pin that the PWM pin would be the "other" pin. I got it now --Its more like the PWM is on the "enable" pin. Dig it. --Kinda nice, 2 pins per instead of 3.

Do you still have freerun and braking via this set-up?

 

Small robots like Rover 5 don't really benifit from a brake. Only big heavy robots with lots of momentum.

0% PWM is free running.

Dig it.

Forget about the current pin for now --For testing, KISS is better. Less wires and fewer connections are good things. Connect then if you would like, they will neither help nor harm and will do nothing until the Arduino is coded to read them.

From there, you basically got 2 pins (connections) per motor. In the most simple set-up, if one is high and the other low, the motor will rotate (full speed) one direction. Reverse the high/low and the motor will reverse direction. This same system exists when one of those pins is connected to a PWM output on the Arduino. [do some searches for PWM] The idea is that the PWM output on the arduino is flicked on-and-off, wicked fast (thousands of times a second) and the percentage of time that the "pulses" are either on or off, controls the speed. Lets say it is at a %50 duty cycle --The PWM pin will be high 1/2 the time and low 1/2 the time thus, 1/2 speed. This would also be around 1/2 brightness if one were dimming a LED via the same method.

In the end, you will have one pin per motor going to a PWM output and one pin per motor going to a digital pin. The PWM controls the speed and the digital pin will toggle your FWD/REV.

That's about it.

 

ok so looking at http://www.arduino.cc/en/Tutorial/PWM

to control the speed i write analogwrite(Pin, 0-255)

and to control the Direction i write digitalWrite(Pin, HIGH or LOW)

so i wrote a quick bit of sample code but its not working:

int DirPin = 11;

int PWMPin = A0;

void setup() {

  pinMode(DirPin, OUTPUT);

  pinMode(PWMPin, OUTPUT);  

}

void loop() { 

 digitalWrite(DirPin, HIGH);

  analogWrite(PWMPin, 255);

}

 

ok so if im using say Channel 1 - i connect the Cur pin to an Analog pin (A0 - A9) on my Spider, the PWM to a Digital Pin (D2 – D13 and D44 – D46)

The Gnd would obviously go to the GND on the board and im unsure about the Dir pin.

I just looked up and read the manual and it seems pretty straight forward.

Current output:
Each channel has a current sensing circuit. The output of this circuit is approximately
1V for each amp the motor draws (5V maximum). This output can be connected
directly to the analog input of any 5V micro controller.


Control logic:
The built in control logic allows each motor to be controlled by 2 pins. Driving the
direction pin high or low will cause the motor to run forward or reverse. The PWM pin
is used to control the motor speed. When this pin is low, the motor is off. When this pin
is high the motor is at full power. To vary the speed of the motor this pin must be Pulse
Width Modulated.

Is there any of the above that is not clear to you?

The wires on the left side are what i am presuming go to the arduino.

As im unsure what goes to the arduino and what doesnt. 

I dont have much experience with the arduino but in a programming sense ive worked with C# for about 4 years now.

In an electronic sense ive only been working with the arduino for about 5 days and dont really have a great knowledge of electronics/circuitry.

I suppose im looking for a quick solution which i know is not the best way and then learning backwards after it works.

I have been looking as some basics in electronics on youtube which is again no the best way to learn but i work alot and dont have time for anything time consuming.

Bradley.