I’ve got a challenge for you (actually it’s more of a problem for myself). I need your help. I need to find out if there is any possible way to make a forward only speed control (where the power positive goes straight to the motor positive and the ground is what is being switched) into a forward and reverse speed control. I thought of putting a relay after it (before the motor) and using some fancy code. Would this work? Any other ideas?
A double pole double throw relay can easily change the the direct for you.
DPDT relays are essentially dual single pole double pole switches. I will use the following names for pins
C1 - Common for switch 1
NO1 - Normally open side of switch 1
NC1 - Normally closed side of switch 1
Similar names for switch 2.
C1 - motor lead
C2 - motor lead
NC1 - NO2 AND High voltage side of speed controller
NO1 - NC2 AND Ground side of speed controller
If you operate the speed controller with the relay energized, you will drive in one direction. If you de-energize the relay your motor will drive in the opposite direction.
Double Pole, Double Throw relays are available from a variety of sources, many of them cheap. The tough part is you need a contact rating that is higher than the current you expect to deliver to the motor. Be aware that the contacts will arc when changing directions unless all power is removed and the motors are stopped. It is just the nature of the beast. Remember that two single pole relays wired in parallel will be a double pole relay. Digikey PB527-ND relays can be used for this, they have a 12 volt operation on the coil and 40 amp contact rating and at $3.91 each appear to be a pretty good bet for most applications using robot motors.
one thing from your post is not clear - you mentioned one side of the motor is ground
does that mean chassis ground? is there a ground wire or is the case of the motor ground - like the starter motor on a car?
to use a relay to reverse direction, you must have wires for the pos and gnd connection, or you will need to isolate the motor from the chassis (if its like a car starter motor)
When I say ground I was referring to negative - the black wire. Anyway, these relays you all mentioned, are they able to switch back and forth really fast, like fast enough for a two wheeled balancing vehilce?
You vary the motor speed with the PWM signal from the single direction speed controller, and determine the direction by means of the H-Bridge. (Which is what everyone else is suggesting, just a bunch of switches.) Theoretically, you’ll get more resolution for the control of the motor speed, but that doesn’t matter much.
Also, if you can’t find relays that can handle enough current, you might be able to make your own heavy-duty solenoid relays. Just a thought.
Relays are available in 24 volt as well but no, they are not fast enough to get balance. For that type of servo system, you need some sophisticated drive amplifiers and special motors. The overall system needs to have relatively quick response and the motors need to have relatively fine control (i.e. optimized brush/commutator for the rotational accuracy) or have a well designed gear box capable of rapid changes in direction without tearing themselves apart.