Hi WindJuggler,
Please see:
http://www.arttec.net/Solar_Mower/4_Electrical/Battery%20Charging.pdf
Looking over the document to get 1% SOC accuracy, 20mv (eyeball number from the plots)
Lets assume 30v full scale a nice round number to measure the battery voltage.
The micro's ADC is 10 bits.
30v / 1024 = 30 mv per bit, not quite making the 20mv number.
LM7805ct initial output voltage is 4.75 to 5.25 v or +-5%
The ADC reference is the 5v supply, so the measurement error is +-5%
Over 30v 5% is 1.5v error.
Rather difficult to measure SOC with this much error?
We have not included the ADC errors or the voltage divider resisters errors etc.
Looking at the plots maybe 100mv total error may be acceptable? For 12v or 200mv for 24v batt.
200mv / 24 = 0.8% total error.
This is not expensive or hard to do, look at the cheap DVM for less than $10, they claim 1%
I have a 5.5 digit very accurate DVM, all the cheap DVM check out against it.
I prefer not to calibrate error out, takes time and is sloppy considering usually not more costly.
By incorporating Amp-hr counting in/out along with battery voltage a decent estimate of SOC can be determined.
Please let me know what your goals are!
Some other considerations:
Resister divider current considerations
Data sheet page 376 (will show as DS p376) states the max input leakage on any one pin is 1ua. To obtain a good reading the resistors current must be 100x or more higher to get better than 1% reading.
Using a very low input leakage opamp (AD8500 ) can fix this problem and allow for the use of higher resister values, but the opamp will add its own errors and it draws current.
ADC
DS p263 the input sample hold cap is listed as 25pF no max listed I could find. The filter cap with the input resisters must be 100-1000x bigger than the 25pF. The filter cap will supply the charge into SH cap introducing a droop error.
Micro's has 10bit ADC, more effective number of bits (ENOB) can be achieved by reducing the filtering (or increasing the frequency of the filter) and over sampling. Over sampling does not improve the accuracy, just resolution. Using a simple digital filter function.
For Each 2x over sampling an extra bit of resolution can be achieved. (4x; 2bits etc.)
Example 10hz filter = 20 samples per second for 1 extra bit.
Protect ADC input with diodes to +5v and gnd. Low leakage transistors work well.
Measuring the generator output
Range is depend on what is important to know.
If its good to know the voltage is above battery. Accuracy is not important here.
Two vs Three PWM
The micro can handle 10k interrupts per second. Using the main timer / interrupts a third PWM using a standard IO pin can be implemented. I have done this many times. No logic.
U7 opto is wired correctly U2 / 3 are not, was throwing me off about the grounds.
I was not seeing the isolation you were talking about!
I will stop here. Let me know if you want more.
Have fun,
Scott.