Controlling One Motor With Two Potentiometers - Possible?

I've got a DC brushed motor, an H-bridge controller, an Uno, and two 5k ohm rotary pots. I need to control the speed and direction of the motor with both pots:

-One pot spins the motor counterclockwise
-The other pot spins the motor clockwise.
-If one pot is in use and the motor is spinning and the other pot is activated, the motor stops spinning (or simply ignores the input from the pot activated last)

While I'm not an Arduino coding guru by any means, I'm okay with controlling speed/direction of a motor with one pot - but two pots has me scratching my head.

Has this been done already? Any help would be greatly appreciated.

It sound like a rather odd set up. I'd have expected a pot to control the speed and a switch for forward/reverse.
If the system is restarted, how should it interpret the position of the two pots since the information about which one was last touched would be lost ?

Sorry, wasn't clear on this: the pots are throttle pots, so they're spring loaded and return to zero when not being turned.

Doable

alesam:
Doable

Good to know, thanks.

OK. It's clear now. It should be straightforward. If you can do it with one pot, post the code and someone may help to adapt it to handle the two pots and the direction change.

The main problem - what to do if user engages both pot simultaneously.

6v6gt:
OK. It's clear now. It should be straightforward. If you can do it with one pot, post the code and someone may help to adapt it to handle the two pots and the direction change.

Will do, thanks.

alesam:
The main problem - what to do if user engages both pot simultaneously.

I suppose there are three possible scenarios in answer to you question (in preferred order):

  1. First come, first serve: the first pot in use overrides any input from the second pot.

  2. The motor simply stops when both pots are supplying any signal.

  3. The Arduino Board overheats in confusion and catches fire.

I'm almost certain I'm good for coding #3, but numbers 1 & 2 are out of my league...

This should give you option #1 (Pseudocode)

In the section of code where you are testing the value of the potentiometers there would be an interlock variable (State) which would have 3 possible states:
Pot1_Active
Pot2_Active
No_Pots_Active

PotX_value is the value read from potX by, say, analogRead()

. . . 
If ( State == Pot1_Active && Pot1_value == 0 ) State = No_Pots_Active ;
If ( State == Pot2_Active && Pot2_value == 0 ) State = No_Pots_Active ;

If ( Pot1_value > 0 ) {
     If ( State != Pot2_Active ) {
         if ( State != Pot1_Active ) State = Pot1_Active
         handle pot1 
     }
}

If ( Pot2_value > 0 ) {
     If ( State != Pot1_Active ) {
         if ( State != Pot2_Active ) State = Pot2_Active
         handle pot2
     }
}
. . .

6v6gt:
This should give you option #1 (Pseudocode)

In the section of code where you are testing the value of the potentiometers there would be an interlock variable (State) which would have 3 possible states:
Pot1_Active
Pot2_Active
No_Pots_Active

PotX_value is the value read from potX by, say, analogRead()

(Code snipped)

Deliciously esoteric yet utterly simple and to the point - I love it. I'll plug it in and report back. Many thanks, 6v6gt.

That is the beauty of calling a code snippet "Pseudocode". All the grisly implementation details (for example lying behind the phrase "handle pot1") can be postponed until the next level !

Darn details can be so pesky! :slight_smile:

  1. First come, first serve: the first pot in use overrides any input from the second pot.

You seem to have a completely incorrect understanding of the potentiometers. You plugged them into the Arduino. You loaded a sketch. You booted the Arduino. From that moment on, both potentiometers are in use ALL THE TIME. The value that you read from the potentiometer might indicate that it is centered, but that does NOT mean that it is not in use.

You REALLY need to do a better job with the requirements.

PaulS:
You REALLY need to do a better job with the requirements.

If humanity depended on what some thought possible we'd still be banging rocks together, naked and shivering in our caves.

Turns out, it works fine, using two separate pots to control the speed and direction of a motor, as I've described in an earlier post. What wasn't apparent - before physically controlling the motor with two throttle pots - was user confusion - turns out some operators would accidentally rest their finger on the pot not in use just slightly, and when the pot in use was released the motor would reverse direction unexpectedly (sort of like following someone driving an automatic car with one foot on the gas pedal and the other foot on the brake pedal). Turns out having the motor stop if input is detected from the second pot is best - "Keep yer goddam left foot off the brake pedal!" is the message I want to send to all operators of this gadget.

I didn't write the code, and don't yet have a copy of it, so I can't post it yet.

ZipZoomFly:
What wasn't apparent - before physically controlling the motor with two throttle pots - was user confusion

That possibility should have been apparent after reply #1, and is a sign of poor user interface design.

A physical toggle switch is much more obvious for direction control, with the knob itself giving feedback on the actual direction chosen.

wvmarle:
A physical toggle switch is much more obvious for direction control, with the knob itself giving feedback on the actual direction chosen.

Not in the industry this gadget is used in.

I'll take your word for that. Even though it's at odds with your comment that there actually "was user confusion".

Maybe you have to say that potX is not a candidate to take control of the motor unless its value was 0 at the time the other pot released control of the motor.

The user would then be auto trained to develop the reflex action of releasing a pot back to zero if it appeared to have no effect.