Don't know if this is of any use John. Found an example of a volt meter, you might be able to pick the bits out you want.
Adam
1 // Voltage.c, DW Smith, 1st December 2011
2 #include < p18f1220. h >
3 #pragma config WDT = OFF, OSC = INTIO2, PWRT = ON, LVP = OFF, MCLRE = OFF
4 #include <...