"Proper" mixing is open to debate :-).
An issue is that you have to make decisions about how fast a track is moving under pure signals from a single pot and what to do when signals from the other pot are included. For example, if you push the FB (Forward-Backward pot fully forwards, and if both motors then run at full speed ahead, how do you deal with the addition of a small amount of LR (Left-Right) pot being added. To get rotation you have to have one track going faster that the other. So, if you are already running at maximum forwards speed on both motors you must decrease one or other track speed in order to turn. But, if you had been standing still you would have accelerated one or other track to achieve the same result.
So, all that said, here is a simple off-the-cuff starting solution out of my head which seems like good start.
If pots are mechanically independant then both can be at 100% simultaneously.
If both are on a joystick type arrangement, if Yaxis = 100% and Xaxis = 0%, then adding some B will usually reduce A. A joystick could be constructed where the above is not true, but these are unusual.
Assume that the joystick is of the type that increasing Y% when X = 100% will reduce X. Other assumptions can be made.
FB = front-back pot. Centre zero, +Ve for forward motion of pot
LR = Left right pot. Centre zero. +Ve for pot at right.
K is a scale factor initially 1.
If any result exceeds 100% then adjust K so result = 100% and use same K value for other motor also.
- eg if Left motor result = 125 and Right motor result = 80 then.
As 125 x 0.8 = 100, set K = 0.8. Then.
Left = 125 x 0.8 = 100%. Right = 80 x 0.8 = 64%.
Then:
Sanity checks:
LR = 0 (centered), FB = full fwd -> Both motors run full forwards.
LR = full left, FB = 0 ->
Left motor runs full backwards,
Right motor runs full forwards.
Vehicle rotates anti clockwise.
FB was 100%, Lr = 0%. Add 10% of LR to right.
L = FB+LR = 100%- + 10%
R = FB-LR = 100%- - 10%
If largest axis < 100%, scale until = 100%.
Then scale other axis by same amount.
Rushing ...
Antiphase PWM per motor looks OK.
Disabling IC using EN lines will often create large motor spike - as long as internal IC catch diode rating is OK that's OK. Otherwise add external diodes to supplies.
What battery chemistry. What size?
AA Alkaline will often tolerate significant regeneration.
Unless battery is small physically or you want exceptional shelf life then NimH will be better than Alkaline. For very long shelf life LSD NimH are getting very good.
At AA size, energy density of NimH now equals or exceeds Alkaline and high load dishcharge characteristics are much superior so there is little reason for Alkaline.
At small cell size Alkaline MAY make sense.
I have not tried this
Answer is "seems like this to me".
Caveat emptor :-):
Motor inductance and resistance will set t = L/R time constant. But, very easy to put small resistor from motor to ground, apply voltage and watch voltage in resistor and thus current rise on scope. PWM period which is small compared to total motor rise time will (probably) be good.
Best Answer
Your basic architecture is flawed. The circuit producing the audio output will high pass filter the signal somewhere in the path. Even in "HiFi" audio, 20 Hz can be attenuated 3 dB with gain dropping off arbitrarily below that.
The net result is that there is no DC information in the signal. There is therefore no positive and negavite PWM. The DC average of the signal will be 0. For example, a positive 70% duty cycle PWM will be indistinguishable from a negative PWM of 30% duty cycle.
You might be able to salvage some of this concept by using 50% duty cycle as the 0 level, with high duty cycles (more time spent high than low) meaning forward rotation and low duty cycles meaning backward rotation. Note that you can't use 100% or 0% duty cycle for full forward and full backward since both would look the same after DC is removed. You probably want to limit the PWM to the 5-95% range or thereabouts.
However, all this is a kludge. You mention the device producing this audio is a Android phone, so you have various other digital communication interfaces available. One way or another you want to get digital motor speed from the device, and have the microcontroller driving the H bridge produce the actual pulses. You could even pass digital information over the audio output.