3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Water Recycler (Grey Water)

Step 3Programming the PIC

Programming the PIC
The PICAXE-8M is programmed via the serial port of your PC. The PICAXE editor and data sheets can be obtained from the following URL:-
http://www.rev-ed.co.uk

The code is easily modified however I didn't put any "in circuit" program headers on the PCB so you'll have to take the PIC out to re-program.

The schematic & PCB could be used for other switching / sensor purposes with the required code changes made.

Here's the BASIC code:-

;Grey water controller MK2

symbol PUMP=0 ; name output 0 as the PUMP
symbol ERROR_LED=1 ; name the output 1 as the error (fault) LED

;high waterfloat switch = input 3, low water float switch = input 4

let dirs=%0000111
let pins=%0000000 ;ensure all outputs low

;float switches are inverse logic, a 0 means it is turned on
main_loop:
if input3=0 and input4=0 then debounce ;high water float mark
if input4=0 then inc_timer ;low water float mark
goto main_loop

inc_timer:
let w0=w0+1
if w0=36000 then start_pump ;if water is in the tank for 10 hours, start pump
pause 1000 ;pause 1 second
goto main_loop

debounce:
pause 500
if input3=1 then main_loop ;check if the float is still high

start_pump:
high PUMP ;turn on pump relay

pump_loop:
if input4=1 then stop_pump ;check to see if low water
if w1=3600 then pump_error ;error if pumps operates continuously for more than 60 minutes
let w1=w1+1
pause 1000
goto pump_loop

stop_pump:
low PUMP ;stop pump
let w0=0 ;reset stale water counter
let w1=0 ;reset error counter
goto main_loop

pump_error:
low PUMP ;stop the pump

error_loop:
if input4=1 then exit_loop ;stay errored until tank empty
high ERROR_LED
pause 500
low ERROR_LED
pause 500
goto error_loop

exit_loop:
let w0=0 ;reset counters
let w1=0
low ERROR_LED ;reset error LED
goto main_loop

I set up the following circuit up on a prototyping board to program the PIC.

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
17
Followers
2
Author:slemke