Pages: [1]   Go Down
Author Topic: Re-posting, Need some help with motor controller.  (Read 949 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 
Hello Arduino world,

I need some help on a PWM motor controller that I want to use for a project. Specifically it is the PWM Motor Controller 3A 12-55V from Superdroid Robots. I have the motor inputs figured out and I am testing with a 12 volt battery, using a 24v motor (it just runs slower).

In the testing phase, I hooked a potentiometer to run the motor one direction, varying the speed.

Hookup:         Arduino:
Pot center         Analog – 0
Pot lead (L)          5v
Pot lead (R)          Ground

Motor driver board
Pin G             Ground   
Pin P (PWM)         PWM – 3

Code:
 
int potpin = A0;
int val;

void setup() {}

void loop() {
  val = analogRead(potpin);
  val = map(val, 0, 1023, 0, 225);
  analogWrite(3, val);
  delay(15);
}
 

Everything worked great with no problems…but as I move forward I am having problems and my searches have me going in circles. 

There are 4  IO pins on the motor controller board.
D-direction (0V and 5V will change the direction of the motor)
P-PWM (used in test)
B-brake (0V to the brake will turn the brake off, 5V will turn it on.)
G-Ground (used in test)

I was able to put 5v on the direction pin and the motor would change direction.
I was also able to put 5v on the brake pin and the motor would stop.

Easy enough to add some switches and use the brake and direction feature of the motor controller, but both the break and direction changes are to abrupt.

In a book I have it discuses; “Bi-directional Analog control: Uses a 0-5v analog (or PWM) signal to determine the speed and direction of a motor. In this mode, the center position of 2.5v is considered Neutral. Below 2.5v spins the motor proportionally in Reverse with a0v value yielding 100% Reverse. Above 2.5v spins the motor Forward with a 5v value yielding 100% Forward—this is called “Analog.” “

So I am looking for some help ---- use a potentiometer with my motor controller, for speed control and forward/reverse, as well as using the break input as a  kill switch but have the motors slow down to 0, 

Thanks
Chris


                     
 
 
 Report to moderator    138.32.12.6 
 
 

 
 
AWOL 
Global Moderator
UK
 Online
Brattain Member

Karma:
 24
Posts: 15168
I don't think you connected the grounds, Dave.
  Re: Need help with my PWM motor controller
« Reply #1 on: October 03, 2012, 06:53:46 AM »  Bigger  Smaller  Reset Quote 

--------------------------------------------------------------------------------

First, there's a big difference between "brake" and "break".

Lot's of ways of skinning this cat.
Take an analogue reading from your pot.
It will return a value in the range 0..1023.

Half this range is 0..511 and 512..1023, but you probably want a dead-band around the middle of the range, say from 500 to 520.
So, numbers below 500 sets REVERSE for the motor, and a count of zero sets a speed of 100% (the "map" function makes things easier here) and 499 sets a speed of 0%.
Numbers above 520 sets FORWARD, and 520 is a speed of 0% and 1023 is a speed of 100%.

100% is "analogWrite(speedPin, 255)"
 
 Report to moderator    Logged 

--------------------------------------------------------------------------------

Pete, it's a fool looks for logic in the chambers of the human heart.
 

 
 
snakeoil 
 Offline
Newbie

Karma: 0
Posts: 0
  Re: Need help with my PWM motor controller
« Reply #2 on: October 03, 2012, 12:32:21 PM »  Bigger  Smaller  Reset Quote Modify Remove 

--------------------------------------------------------------------------------

OK, on the brake.
do you know if I will need to use the direction pin on the motor controller?   
 
 Report to moderator    138.32.12.6 
 
 

 
 
AWOL 
Global Moderator
UK
 Online
Brattain Member

Karma:
 24
Posts: 15168
I don't think you connected the grounds, Dave.
  Re: Need help with my PWM motor controller
« Reply #3 on: October 03, 2012, 12:38:15 PM »  Bigger  Smaller  Reset Quote 

--------------------------------------------------------------------------------

Quote
do you know if I will need to use the direction pin on the motor controller?
If you want to change the direction of rotation, yes, I think you probably do,
 
 Report to moderator    Logged 

--------------------------------------------------------------------------------

Pete, it's a fool looks for logic in the chambers of the human heart.
 

 
 
snakeoil 
 Offline
Newbie

Karma: 0
Posts: 0
  Re: Need help with my PWM motor controller
« Reply #4 on: October 03, 2012, 12:40:02 PM »  Bigger  Smaller  Reset Quote Modify Remove 

--------------------------------------------------------------------------------

Thanks 
 
 
 
 
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 Author Topic
AWOL 
Global Moderator
 Online
Brattain Member

Karma:
 20
Posts: 15168
I don't think you connected the grounds, Dave.
 Re: need a little more help.
« Sent to: snakeoil on: Today at 10:22:03 AM » Quote Reply Remove   

--------------------------------------------------------------------------------

It's better if you post your questions on the forum, then everyone benefits.
Think about what you're trying to do.
A pot only gives a positive reading.
You could subtract half the range (512) from the reading to give a value in the range -512 ...+511.
Use the sign of the value to set the direction, and simply divide the absolute value by two to give the speed.
However, this doesn't give you your dead-band in the middle of the pot's travel.

--------------------------------------------------------------------------------

Pete, it's a fool looks for logic in the chambers of the human heart.
 
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

no luck.
I can map  Val = map(val, -511, 0, 0, 255);
and all different variations...but I can't get the dead zone in the middle and have the motor accelerate from 0 to 255 both ways.
Does anyone know of a book or instructions that would cover this?
Thanks
Logged

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should set the PWM pin as an output in setup() and set it LOW to prevent that pin floating at the start of your sketch (or equivalently  analogWrite (3, 0)  in setup().

Please use
Code:
// the code tag
for code.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: