Michael, I've looked, but can't find the original reference code I used. But, it does seem similar to: http://extremeelectronics.co.in/microchip-pic-tutorials/using-analog-to-digital-converter-–-pic-microcontroller-tutorial/ I think that is either my reference, or some variant of it. Regards, Mark. On 23 Feb, 2013, at 6:07 PM, Michael Balzer <dexter@expeedo.de> wrote:
Mark,
I got some 12V alerts during the last 3 days. Checking the 12V reading after the alerts showed normal level, so I'm trying to figure out if they were false alerts.
Last alert was about 2 hours ago, alerting about 11.0 V -- my check only a few minutes later showed 12.1 V again...
I've read into the PIC18 doc on the A/D conversion (chapter 19). AFAIS inputs_voltage() differs from the example in two ways:
1) the example does not turn off the converter after reading the result (but I understand the ADRES register should keep the result)
2) the example step 3 says "wait for acquisition time if required", it seems our function currently does not wait.
"To determine acquisition time, see Section 19.1 “A/D Acquisition Requirements”. After this acquisition time has elapsed, the A/D conversion can be started."
Section 19.1 contains an equation based on hardware parameters I don't know. Can you please have a look and tell if missing that wait time could lead to false measurements?
Thanks! Michael
-- Michael Balzer * Paradestr. 8 * D-42107 Wuppertal Fon 0202 / 272 2201 * Handy 0176 / 206 989 26
<dexter.vcf>_______________________________________________ OvmsDev mailing list OvmsDev@lists.teslaclub.hk http://lists.teslaclub.hk/mailman/listinfo/ovmsdev