Electrical – Battery as reference voltage

batteriescomparatorvoltage-reference

I am fooling around with a solar panel and I am trying to make a circuit, which would monitor its voltage and eventually switch the load on and off.
The thing is, I don't have a good "reference" voltage to compare with. The solar panel can produce anywhere from 0 to ~20V. If it is high enough I can use zener or even voltage regulator, but when it is (almost) dark both of these options will drop in voltage.
So, I was wondering if it is a good practice to use a battery (like a coin cell or something) just to feed one input of a comparator. It doesn't need to be precise, and I think there will be virtually no drain from the battery, so it will last very long.
Another option is to stick with the zener and abuse the gate threshold voltage of the NMOS (whos gate is connected to the comparator output). I mean, if the comparator outputs either ~0V or the zener voltage and that zener voltage drops low enough, the MOSFET won't turn on anyway.
I will probably ask a separate question with more details of what I am trying to do and whether it makes sense at all, but right now I am just asking whether using a battery as a reference voltage for a comparator (and nothing else) is something common, does it make any sense, etc.

Best Answer

Don't use a battery as a voltage reference. To quote my firmer boss and mentor: "Battery voltage is a nonlinear function of everything. [That includes temperature.]"

Zener voltage reference, or a bandgap voltage reference would work for you. They are available in a variety of voltages.

Keep in mind also that most A/D converters inside microcontrollers have a built-in voltage reference, which can be enabled from code.