ADCON1 is not used that way on this chip so get rid of that. If that does not solve the problem I would look at your hardware setup. Something giving a false signal . How is the solenoid connected ?