What about a radio shack (The Source by CC) cigarette lighter inverter? Probably cheaper than a battery.
I took the liberty of simplifying what you wrote above.
pwmDuty = T/(Tmax - T) * (Cmax - C)/Cmax; except for the possible the divide by zero, this looks good.
|