How can I calculate the remaining capacity (exact or approx value) of a Li-ion battery by measuring its voltage. The battery is connected the load and i know only the battery voltage and the value of current drawing from battery by the load. Is there any formula?
Metering a battery capacity is a process of monitoring the incremental energy that goes into the battery while it is being charged and then again monitoring the incremental energy that leaves the battery while it is being discharged. During the incremental gathering (which actually means periodic sampling) the samples are added to or subtracted from a running accumulator of the energy in the battery.
Initially when a fully charged new battery is deployed this running total is set to represent the rated battery capacity.
Some battery packs will come with a small monitoring chip installed that performs the incremental accumulation all inside the chip. In the industry these are referred to as a "battery gas gauge chip". These chips monitor the battery pack voltage and current (as a voltage drop across a low resistance element placed in series with the battery) and internally compute that into incremental energy that gets added or subtracted from an internal accumulator register. These chips typically also have a bi-directional single wire serial interface that is used to configure the device and to be able to read out the accumulator value.
If all this is done properly then the accumulator value, whether that be done in software or in hardware by a "gas gauge", can be used to display current battery state.
If an approximation is actually desired, as long as your intended load is not at the limits of the battery draw current, which is fairly high for li-ion cells, you can fully charge your battery, and build a power controlled circuit with a dummy load (resistor/high powered LED/low voltage heat coil), except put the current/voltage sense on the input so you have a constant power variable input voltage load. A cuk converter variation would probably be good to control the load because it doesn't... unsmooth? break up? I don't know the word, but it's smooth on the input. Because lithium ion capacity varies by load, the dummy load should match your intended load.
Use the load to drain the battery completely and see how long it takes, and measure and record output voltage under load as it drains at regular increments. Now you know, when the battery is new what the remaining capacity of the battery is at each voltage at your intended load.
Battery life decreases over time, and the remaining capacity at each voltage does too. If you don't have an old matching battery or the time to "age" one, find datasheets for the battery and find the information they provide on expected life after X charge cycles. Use it to produce one or more extra sets of numbers, what you expect the capacity to be at half or near the end of intended service life at each voltage. Note that while the capacity at each voltage will drift a lot as time goes by, the 50% line, for example, or some arbitrary value will not drift as much as the capacity.
Measurement would likely be much more accurate, so measurements of similar batteries that have been through a lot of cycles would help you, but you can arbitrarily choose a compromise among this range of figures and treat that as your lexicon for that battery. Near the start of the service life it will show fuller than it is, but if you wish to keep the circuit itself simple you can use an experimental process like this to get an approximation.
Note that even for same chemistry batteries, if you don't want to use a monitor chip, you need to determine capacity for the intended load. Note also that with a variable load or no load voltage, the reason that this won't work is that measured voltage under load will vary by load, so if you wish you can take the information you now have and repeat the process, stopping it at the significant increments for just long enough to measure no load voltage on the battery.