Originally Posted by doors666
1. How do I simulate a battery.
Normally with a voltage source, same as with your 15V input supply.
That will only simulate a perfect battery, which has no ESR and a flat voltage vs time curve.
There is nothing in SPICE that simulates the chemistry of a real battery. You can try to approximate various aspects of the battery, such as by adding 2-3 Ω in series on the positive terminal of the voltage source, being the ESR of a "9V" NiMH battery.
What would be the approximate resistance and capacitance of a 9v rechargeable battery.
The ESR, as I said, is about 2-3 Ω.
Capacitance? While there certainly is some capacitance in a battery, it's not especially useful to try and model it, at least as far as battery charging goes.
If you're trying to model a NiMH battery using nothing but passive components, don't bother. A battery is an active nonlinear device.
2. is it safe to switch on the amp while its charging. Can the amp be used safely while its charging.
The LM317 based chargers are nicer in this regard, in that they help lower the total supply impedance when they are active. In this O2 design, the 330 Ω resistor effectively causes the wall supply to not contribute to the power performance of the downstream circuit, since the source impedance of the battery is a couple of orders of magnitude lower.
3. If I use about 20mA current to charge, how much total current will be needed from the regulator. How much if I am using the amp while charging. I guess ne5532 uses Iq 20ma + 80ma max for output and 20 ma for charging, so total 120ma. Sounds good? 7812 driven from 15v supply at 120mA wont need a heatsink right?
You're going about that calculation the wrong way.
Again, because of the 330 Ω between the regulator and the battery — and the load! — ~99% of the current needed by the load will come from the battery, not from the wall supply. If you're using a 20 mA trickle charge and the load is drawing 40 mA, that means > 39 mA will come from the battery, and less than 1 mA from the wall supply.
The solution is not to increase the charge current, because that will endanger the battery, since there is no intelligent cut-off circuit. Correct solutions include:
- Accept that you cannot run such a load continuously without running the battery down. If you only use the circuit for a few hours a day, it will have time to recover overnight, if you leave it plugged in most of the time.
- Switch to one of the LM317 based chargers, which form a true constant-current source with near-zero output impedance, so they take the load while the wall supply is plugged in, not the battery.