Finally YOU made it!!!
I just changed my circuit to power it directly from my variable power-supply and simulate the batterie's weakening.
@5VDC, my display shows a value of 135 and @4,2VDC (can't go lower or my display won't work anymore) I read 147.
So, except the particular init sequence for the LCD I use, the code example here under is working fine and should be quite standard.
Using the internal 0,6V reference:Code:' PIC 16F690 Fuses @ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF '------------------------------------------------------------------------------- ' Registers 76543210 OPTION_REG = %10000000 'OPTION register ANSEL = %00000000 'Select analog inputs Channels 0 to 7 ANSELH = %00000000 'Select analog inputs Channels 8 to 11 WPUA = %00000000 'Select weak pull-ups WPUB = %00000000 'Select weak pull-ups ADCON0 = %00000000 'AD Module ADCON1 = %00000000 'AD control register CM1CON0 = %00000000 'Comparator1 Module CM2CON0 = %00000000 'Comparator2 Module INTCON = %00000000 'INTerrupts CONtrol TRISA = %00000000 'Select Input/Output (0 to 5) PORTA = %00000000 'Set High/Low (0 to 5) TRISB = %00000000 'Select Input/Output (4 to 7) PORTB = %00000000 'Set High/Low (4 to 7) TRISC = %00000000 'Select Input/Output (0 to 7) PORTC = %00000000 'Set High/Low (0 to 7) '------------------------------------------------------------------------------- ' Defines DEFINE OSC 8 DEFINE LCD_DREG PORTC 'LCD data port DEFINE LCD_DBIT 4 'LCD data starting PORT.bit (0 or 4) DEFINE LCD_RSREG PORTC 'LCD register select port DEFINE LCD_RSBIT 3 'LCD register select bit DEFINE LCD_EREG PORTC 'LCD enable port DEFINE LCD_EBIT 2 'LCD enable bit DEFINE LCD_BITS 4 'LCD bus size 4 or 8 DEFINE ADC_BITS 10 'Number of bits in ADCIN result '------------------------------------------------------------------------------- ' Init display ' ELECTRONIC ASSEMBLY DOGM081 LCD display Mandatory settings ' See datasheet for circuitry changes by 5V or 3,3V operation PAUSE 1000 'Time to settle Vdd (THIS IS CRUCIAL FOR THIS DISPLAY!!!) LCDOUT $FE, $29 'Function Set: 4 bits bus mode LCDOUT $FE, $1C 'Bias set LCDOUT $FE, $52 'Power control + Contrast (HiByte)(for 5V=$52 or 3,3V=55) LCDOUT $FE, $69 'Follower control (5V=$69/3,3V=6D) LCDOUT $FE, $78 'Contrast (LowByte) '------------------------------------------------------------------------------- ' Variables Bat_Value var word 'holds ADC value Bat_Value = 0 '------------------------------------------------------------------------------- ' Start program MAIN: ADCON0=%10110101 ' Here we drive the 0,6 volts to the ADC 'ADCON1=%00110000 ' I prefer to be sure to have FRC for the beginning at least VRCON= %00010000 ' Enable the VP6 reference ADCON0.1=1 WHILE ADCON0.1 : WEND Bat_Value.HIGHBYTE = ADRESH : Bat_Value.LOWBYTE = ADRESL LCDOUT $FE,2,DEC4 Bat_Value PAUSE 1000 GOTO MAIN END
- 0,8Vbatt difference = 12 value change
+ no external components
Using an external voltage divider:
+ 0,8Vbatt difference = 84 value change
- external components
Thanks a lot for all your help![]()





Bookmarks