10A DC Motor Driver Arduino Shield direction

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

10A DC Motor Driver Arduino Shield direction

Postby carlosap » Mon Mar 16, 2015 3:52 am

on the sample code you use :
// Control the motor according to the speed value.
// Positive speed value = CW,
// Negative speed value = CCW.
if (iSpeed >= 0) {
analogWrite(pinPwm, iSpeed);
digitalWrite(pinDir, LOW);
}
else {
analogWrite(pinPwm, -iSpeed);
digitalWrite(pinDir, HIGH);
}

what does the direction pin controls? do I always wave to have positive pwm with low? what if I put -ispeed with low direction?
what does actually control the direction the pas/neg value of the PWM of the pinDir: LOW/HIGH?
carlosap
Freshie
 
Posts: 4
Joined: Mon Mar 16, 2015 3:49 am

Re: 10A DC Motor Driver Arduino Shield direction

Postby waiweng83 » Mon Mar 16, 2015 11:54 am

pinDir control the direction of the motor and the PWM value in analogWrite(pinPwm, VALUE) must be always positive.

In this example, we use a single variable "iSpeed" to control the speed and direction of the motor. If this value is positive, the pinDir is set to LOW while if it is negative, the pinDir will be set to high.

If you 12 control the pinDir directly, you can just do like this:

// Run motor clockwise.
analogWrite(pinPwm, value);
digitalWrite(pinDir, LOW);

// Run motor counter clockwise.
analogWrite(pinPwm, value);
digitalWrite(pinDir, HIGH);
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 205
Joined: Wed Apr 15, 2009 2:17 pm

Re: 10A DC Motor Driver Arduino Shield direction

Postby carlosap » Mon Mar 16, 2015 9:54 pm

Thanks. It threw me off but after your reply I got it. It passes an iSpeed negative and the -Ispeed turns it into positive..hahaha
carlosap
Freshie
 
Posts: 4
Joined: Mon Mar 16, 2015 3:49 am


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 17 guests

cron