Thanks Joe.S and Bruce.
The SLEEP routine does actually work!!
Doesn't the GPIO = %00000000 command set all pins which are outputs to 0?
TRISIO configures them as either inputs or outputs?
It could be that the GPIO commands are causing my problem though.
The problem is that the system stays in closed position if it is started in the closed position.
If the system is started in the open position it closes it (as in the start-up routine) then opens closes and sleeps as intended.
Any chance of a 2nd look?
Cheers
Bookmarks