The problem with circuit is that it may give same ADC value even when the voltage of battery drops.....so please give me suggestions on that...thanks in advance.
The problem you have is that the A/D uses Vdd as it's reference, so therefore it can't measure Vdd.
You need a different reference voltage somehow. Possible options are:
- Run the A/D from the internal reference voltage, if your micro can do this. Measure something linearly derived from Vdd. The measurement is then proportional to Vdd.
- Run the A/D from a external reference voltage. Very little current is usually needed, so any tiny linear or shunt regulator can do this.
- Feed the internal reference voltage into the A/D. The Vdd level is proportional to the reciprocal of this reading.
- Same thing as #3, but using a external reference voltage. The advantage of this over #2 is that the reference can be lower, below the full reference voltage the A/D requires.
You can use the following simple circuit:
U2: 1.8v voltage regulator
When the battery is full at 5v the voltage at A0 will be 1.6v . If the voltage of the battery drops The voltage at A0 drops as well but the power supply of the MCU is fixed at 1.8v.
The disadvantage of this solution is that the resistors R1 and R2 are going to drain the battery. You had better choose bigger values.
This is a simple solution and it can be improved. there are other solutions to not drain the battery by using two transistors like someone suggested here. Combining the two solutions would be a good step toward a better design.
Take care to choose values suitable for your application.