I want it to turn on every 6 hours for 3 minutes only if switch6 is closed, if switch 6 is closed and the ATO is turned on i want it to stay on 30 seconds after the switch6 is open. if my mainpump is off I want the ATO to be off (this probably isn't needed but for some reason I felt it was a good failsafe)
Now, here is my code
Fallback OFF
Set OFF
If Outlet Mainpump = OFF Then OFF
OSC 000:00/003:00/360:00 Then ON
If Switch6 CLOSED Then OFF
Defer 000:40 Then OFF
This doesn't match up with your intentions. You stated that the ATO should be ON when Switch6 is CLOSED, but you have it set to OFF. Keep in mind that the Apex executes top to bottom, so later code has higher priority. Currently, you have the Mainpump condition at a very low priority and it can be overridden by the OSC. The basic approach is to set the most common/normal behavior first and then set the exceptions.
If I understand correctly:
You only want the ATO to run within a three minute window every six hours, but only if needed based on Switch6? And then run an additional 30 seconds beyond the 'shut off point', to basically overfill it slightly? If so then this will require a virtual outlet:
[ATO_Allow]
OSC 000:00/003:00/360:00 Then ON
[ATO]
Fallback OFF
Set OFF
If Switch6 CLOSED Then ON
If Outlet ATO_Allow = OFF Then OFF
If Outlet Mainpump = OFF Then OFF
Defer 000:30 Then OFF
The float will attempt to turn ATO ON when the sump is low. But, if ATO_Allow is OFF (ie outside the allowable time slot), then ATO is kept OFF. The Defer will run the ATO for an additional 30 seconds before turning OFF. The drawback here is that Defer applies to the whole outlet, not a specific condition. So if ATO happens to be ON and Mainpump turns OFF, ATO won't turn OFF until the delay expires.
Todd