Go Down

Topic: How to control DC motor forward and reverse with one potentiometer (Read 8 times) previous topic - next topic

AWOL

Quote
Why is everyone assuming he wants to control a servo, he said he wants to control a DC motor.
Where did servo come from?
Because it is the closest analogy to the requirement stated?
Clearly a pot, motor and battery alone aren't going to be sufficient because they don't allow for current reversal to allow the motor to change direction, unless, perhaps you have a battery with centre tap. You're going to need some active components in there.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

HazardsMind

I know he needs an H-bridge, but all he asked was can he control a DC motor with a POT.
YES, he can. He will need a H- bridge, to supply the proper current to the motor, and if he wires it up correctly, the code I wrote will work.

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

AWOL

Quote
the code I wrote will work.

Maybe, but it isn't an analogue solution, as requested in the original post (though what it is doing in this forum beats me   XD  )
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

holmes4

For a motor (with h-bridge/motor shield of course!). You read the pot with ADC and then values above (say ) 700 are forward, values below 300 are backward and values in between are stop. But you still need one pot per motor.

Mark

HazardsMind

#14
Dec 04, 2012, 02:10 pm Last Edit: Dec 04, 2012, 02:37 pm by HazardsMind Reason: 1
Quote
In the big picture there will be a 2-axis joystick controlling two DC motors.

this is simple too. It is only a differential setup.

Code: [Select]

Pseudocode.
if ( Y > 0 && XL > 0 || XR < 0) //forward with left or right turning
{
M1F = Y - XL;         M2F = Y - XR;              //XL and XR can be set by an IF statement, if analogRead(A0) > 0, then put it in XL
M1R = 0 or LOW     M2R = 0 or LOW           // else put it in XR
}
else if ( Y < 0 && XL > 0 || XR < 0) // reverse with left or right turning
{
M1R = Y - XL;         M2R = Y - XR;       
M1F = 0 or LOW     M2F = 0 or LOW
}

More code for 360 turning...

else
{...full stop... }

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Go Up