Steve,
the program controls both the load disconnection and the external power .
You can set the voltages at your choice.
Here is the piece of code. The whole code is not optimized : I am not a software expert as I told at the beginning. There are a lot of comments on the program.
I think that a software guy could improve the code in a significant way. BTW it is still working at my home.
regards,
Ambrogio
iw2fvo

' LOW VOLTAGE PROTECTION ...and load control..................................

IF ( VB<11800 ) THEN ' BATT LOWER THAN 11.8 Vdc
U_VOLT=1 ' SET UNDER_VOLTAGE FLAG
LOW LD_EN ' DISABLE LOAD
LOAD=0
U_FLG=1
ELSE
IF ( VB>12600 ) THEN ' IF VBATT MORE THAN 12.6 Vdc
U_VOLT=0 ' RESET UNDER_VOLTAGE FLAG
IF U_FLG=1 THEN
HIGH LD_EN ' ENABLE LOAD
LOAD=1
U_FLG=0
ENDIF
ENDIF
ENDIF

IF (U_VOLT=1) AND (EXTPWR_OK=1) THEN
LOW EXT_PWR_RLY ' ACTIVATE EXT POWER RELAY
EX=1
ELSE
IF U_VOLT=0 THEN
HIGH EXT_PWR_RLY ' RELASE EXT POWER RELAY
EX=0
ENDIF
ENDIF

IF U_VOLT=0 THEN
IF PB_3=0 THEN
if LOAD=0 THEN
LOAD=1
ELSE
LOAD=0
ENDIF
IF LOAD=0 THEN
LOW LD_EN
ENDIF
IF LOAD=1 THEN
HIGH LD_EN
ENDIF
WHILE PB_3=0 : WEND
ENDIF
ENDIF