I got tripped up with this one too...
Needs to be along the lines of:

Code:
Case is >= pvmin 
        if (pv >= batt) AND (pv <= battmax)  then etc...
Good luck and happy coding.

Chris