DBL Flusher
Updates
<section begin=updates />*DBL Flusher project is posted in its completeness. BOM, CODE, HARDWARE, and more is all posted. --Paul 13:58, 7 November 2007 (EST)<section end=updates /> <section begin=oldnews />
- Its been a month of testing and everything looks good. The device is still operating fine. I am working on polishing up the code and adding programmable time delay. But the hardest part is creating a template for the bracket, and its taking a long time to get that to where I want it to be. I will soon flood the page with all this stuff once I'm satisfied with it. --Paul 13:18, 1 November 2007 (EDT)
- Its been over a week with my DBL Flusher installed on the potty and so far so good. I am waiting to see how long the battery lasts to device if any further changes need to be made. --Paul 17:39, 22 September 2007 (EDT)
- I have completed the DBL flusher code to my likening. The device is currently installed in my home toilet for testing. Pics and video soon to follow! --Paul 22:33, 11 September 2007 (EDT)
- Boards arrived on sat. I got all the stuff on them and they work great. I have some preliminary code that Ive tried out and it works great. More to come later on in the week. --Paul 11:59, 10 September 2007 (EDT)
- The PCBs are inbound. I am eager to receive them and get to work! If all goes according to plan (haha!) I feel like I should have a working model by Monday (if i receive them tomorrow).--Paul 15:15, 6 September 2007 (EDT)
- I made the first bracket to suspend the servo in the filler tank in the potty. Images have been uploaded. --Paul 12:36, 21 August 2007 (EDT)
- I am currently waiting on parts and will soon be ordering the first PCB. This project will be my first attempt at working with SMD components. After bench testing with the parts I will order the PCB. --Paul 13:17, 16 August 2007 (EDT)
- Reworked the PCB. The new design uses a different PIC with more I/O. I did all I could to avoid changing the PIC but in the end it seemed like the cheapest method for me to get working prototype. I was short I/O on the 84a and I would have had to do some fancy things to get what I wanted, which meant more components, and more PCB space. The new PIC allows me to implement ICSP easily which makes development so much smoother. Also the new design uses two 2-digit 7-segment displays for a total of 4 digits. Once I'm happy with the BOM I will order the parts and the PCB shortly after. --Paul 17:26, 6 August 2007 (EDT)
- Added a schematic of the DBL Flusher to the DBL flusher page along with the PCB layout. --Paul 21:39, 30 July 2007 (EDT)
<section end=oldnews />
Abstract
The DBL Flusher is a device that will automatically flush a toilet. A PIC micro controller is used to control the device. A small control board is placed on top the fill tank of the toilet with a leash to a servo that is inside the tank. A bracket is used to suspend the servo in the proper position inside the tank allowing it to flush the toilet while still allowing manual flushing. The control board has 2 buttons and a 3 digit 7 segment display. 1 button is used to set the number of flushes that will be made while the other starts the automation control. The default number of flushes is 1. When the start button is pressed a count down is started and displayed on the 7 segment display. When the count down reaches 0 the servo is driven to flush the toilet and then resets for the next flush. If only 1 flush was selected the device will go to sleep and wait for the next use. If not the device will reset and flush again. The device will continue doing so until the number of flushes desired is achieved.
Parts
| Part Decription | Part | Mouser PN | Qty | Price | |||
| Servo | HiTech HS-322HD | * 395760 | 1 | 16.9500 | |||
| 7-seg display | Kingbright BC56-12GWA | 604-BC5612GWA | 1 | 2.7300 | |||
| 10K 1206 Resistors | KOA Speer RK73H2BTTD1002F | 660-RK73H2BTTD1002F | 3 | 0.1000 | |||
| 4.7K 1206 Resistors | KOA Speer RK73H2BTTD4751F | 660-RK73H2BTTD4751F | 1 | 0.1000 | |||
| 1K 1206 Resistors | KOA Speer RK73H2BTTD1001F | 660-RK73H2BTTD1001F | 3 | 0.1000 | |||
| Battery Holder | Eagle Plastic Devices, 4 D cells. 12BH144A-GR | 12BH144A-GR | 1 | 1.8900 | |||
| 100Ohm R Network | Bourns QSOP 2QSP16-TJ1-101LF | 652-2QSP16-TJ1-101LF | 1 | 1.6800 | |||
| TSV | Vishay DO-214AA 5V TSV SMBJ5.0A-E3/52 | 625-SMBJ5.0A-E3 | 2 | 0.2800 | |||
| MCLR Diode | Vishay MELF Switching diode LS4148-GS08 | 78-LS4148 | 1 | 0.0600 | |||
| MOSFET | Fairchild N type RPP and Servo Sitching SOT-3 NDS335N | 512-NDS335N | 2 | 0.3900 | |||
| Headers | For ICSP and Servo con 649-68000-436HLF | 68000-436HLF | 1/4 | 0.1200 | |||
| Crystal | Murata SMD ceramic Resonator 4MHz CSTCR4M00G53-R0 | 81-CSTCR4M00G53 | 1 | 0.5600 | |||
| Transistors | Central Simiconductor NPN SOT-23, 7seg Mux CMPT4401 | 610-CMPT4401 | 3 | 0.2000 | |||
| PIC | Microchip PIC MCU16F872 SOIC-28 PIC16F872-I/SO | 579-PIC16F872-I/SO | 1 | 4.8400 | |||
| Voltage Regulator | 5V regulator STMicro L7805CV TO-220 | 511-L7805CV | 1 | 0.2400 | |||
| Decoupleing Cap | 30pF Ceramic Radial 140-50N5-200J-TB-RC | 140-50N5-200J-TB-RC | 1 | 0.0600 | |||
| Cap | 1uF Electrolytic Xicon 140-XRL25V1.0-RC | 140-XRL25V1.0-RC | 1 | 0.0600 | |||
| Cap | .1uF Electrolytic Xicon 140-XRL100V0.1-RC | 140-XRL100V0.1-RC | 1 | 0.0600 | |||
| Red Switch | NO MO Red 104-0012-EVX | 104-0012-EVX | 1 | 0.8700 | |||
| Black Switch | NO MO Black 104-0013-EVX | 104-0013-EVX | 1 | 0.8700 | |||
| PCB | Circuit Board | 1 | 15.0000 | ||||
| Sheet Metal | Sheet metal for the servo bracket with various parts | 1 | 10.0000 | ||||
| * Servo is only avaliable from Jameco | |||||||
Code
spelling not guaranteed correct. But hey, it works so it docent matter. Its not like it keeps the names anyway when you disassemble it...
;********************************************************************** ; * ; Filename: main.asm * ; Date: 10/13/07 * ; File Version: 1.0 * ; * ; Author: Paul Mac * ; * ; * ;********************************************************************** ; * ; Files required: P16F872.INC * ; * ; * ; * ;********************************************************************** ; * ; Notes: RC0 is start button. RC1 is the increment button. Both * ; buttons are idle high. * ; * ; * ; * ;********************************************************************** list p=16f872 ; list directive to define processor #include <p16f872.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _CPD_OFF ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. ERRORLEVEL -302 ;remove message about using proper bank ORG 0x2100 DE 1 cblock 0x20 d1,d2,d3 dig1,dig2,dig3 sec, loop, flush, i hundreds, tens_and_ones, bin, limit, sleeps, sleepn, counter endc ;********************************************************************** ORG 0x000 ; processor reset vector clrf PCLATH ; ensure page bits are cleared goto Main ; go to beginning of program Main clrf PORTA clrf PORTB clrf PORTC movlw 0x06 BANKSEL ADCON1 movwf ADCON1 BANKSEL TRISA ;bank 1 clrf TRISA clrf TRISB movlw b'00000011' movwf TRISC BANKSEL PORTC movlw d'1' movwf flush ; the flush counter movlw d'3' movwf limit ; the max amount of flushes alloud call SetupSleep clrf sleeps call DisplayOn Buttons btfsc sleeps,0 call DisplayOff btfss PORTC,0 ; test start button goto SetupTimer btfss PORTC,1 ;test inc button call Inc movf flush,w ; call the flush value to display it movwf bin call binary_to_bcd movf tens_and_ones,0 ;bring BCD ones and tens into W andlw b'00001111' ;mask the junk movwf dig1 movf dig1,0 ;move the digi into W to get ready to display it call LookupA movwf PORTA movf dig1,0 call LookupB movwf PORTB call FourtyMS call SleepR goto Buttons SetupSleep movlw d'255' movwf sleepn ; setup the sleep counter return DisplayOff bcf PORTC,7 return DisplayOn bsf PORTC,7 return SleepR decfsz sleepn,f ; decrement the sleep counter return movlw d'1' ;set the sleep var to 1 to put it to sleep when its time movwf sleeps return Inc clrf sleeps call SetupSleep call DisplayOn btfsc PORTC,1 ;test inc button goto Buttons incf flush,f ; incriment counter movf flush,w ;move flush to the W subwf limit,w ; TEST TO MAK SURE THE INC IS LESS THAN THE LIMIT btfsc STATUS,Z goto SetFlush btfss STATUS,C goto SetFlush Release call Debounce ;20mS debounce delay btfsc PORTC,1 ;test inc button return call FourtyMS goto Release SetFlush movlw d'1' movwf flush goto Release SetupTimer call FourtyMS ;40mS debounce delay call FourtyMS ;40mS debounce delay call FourtyMS ;40mS debounce delay call FourtyMS ;40mS debounce delay movlw d'120' ; delay seconds movwf sec Start movf sec,w movwf bin ; bin is the variable that is BCD'd call binary_to_bcd movf hundreds,w movwf dig3 swapf tens_and_ones,0 ; swap the nibbles in BCD and put it in W andlw b'00001111' ; mask the crap, leaves the clean number in W movwf dig2 ; put it in the 2nd digit holder movf tens_and_ones,0 ;bring BCD back into W andlw b'00001111' ;mask the crap movwf dig1 Print movlw 0xFA ; loop count for 1 sec movwf loop MuxLoop movf dig3,0 ;move the digi into W to get ready to display it call LookupA movwf PORTA movf dig3,0 call LookupB movwf PORTB movlw b'00100000' ;strobe the 3nd digit movwf PORTC call MuxDelay movf dig2,0 ;move the digi into W to get ready to display it call LookupA movwf PORTA movf dig2,0 call LookupB movwf PORTB movlw b'01000000' ;strobe the 2nd digit movwf PORTC call MuxDelay movf dig1,0 ;move the digi into W to get ready to display it call LookupA movwf PORTA movf dig1,0 call LookupB movwf PORTB movlw b'10000000' ;strobe the 1st digit movwf PORTC call MuxDelay btfss PORTC,0 ; test start button for cancelation goto Cancle decfsz loop,f ;decrement loop counter, do it 250 times for 1 second goto MuxLoop decfsz sec,f ;decrement sec counter, do it however many times goto Start call ServoDrive BANKSEL flush decfsz flush,f goto SetupTimer goto Main Cancle movlw b'00011111' andwf PORTC,f btfss PORTC,0 ; test start button for cancelation goto Cancle call FourtyMS call Debounce ;20mS debounce delay goto Main ServoDrive call Hone call OneEighty BANKSEL EEADR movlw 0 movwf EEADR BANKSEL EECON1 BCF EECON1,EEPGD BSF EECON1,RD BANKSEL EEDATA MOVF EEDATA,w BANKSEL counter MOVWF counter INCF counter BANKSEL EEADR movlw 0 movwf EEADR BANKSEL counter movf counter,w BANKSEL EEDATA movwf EEDATA BANKSEL EECON1 BCF EECON1,EEPGD BSF EECON1,WREN MOVLW 0x55 MOVWF EECON2 MOVLW 0xAA MOVWF EECON2 BSF EECON1,WR BCF EECON1,WREN EEPROMcheck btfsc EECON1,WR goto EEPROMcheck return LookupA addwf 0x02,f retlw b'00000001' ;0 retlw 0x00 ;1 retlw b'00000011' ;2 retlw b'00000011' ;3 retlw b'00000010' ;4 retlw b'00000011' ;5 retlw b'00000011' ;6 retlw 0x00 ;7 retlw b'00000011' ;8 retlw b'00000010' ;9 LookupB addwf 0x02,f retlw b'00110111' ;0 retlw b'00000110' ;1 retlw b'00010011' ;2 retlw b'00000111' ;3 retlw b'00100110' ;4 retlw b'00100101' ;5 retlw b'00110100' ;6 retlw b'00000111' ;7 retlw b'00110111' ;8 retlw b'00100111' ;9 Hone movlw d'75' movwf i movlw b'00001000' ; turn on the FET xorwf PORTC,f Hone0 movlw b'00000100' ; 1ms pulse to put the servo somewhere IDK GOD xorwf PORTC,f call ZeroDegre movlw b'11111011' addwf PORTC,f call ZeroDegreR decfsz i,f ; make the loop happen 5 secdonds worth (250 times) goto Hone0 movlw b'11110111' ; turn off the FET andwf PORTC,f return OneEighty movlw d'75' movwf i movlw b'00001000' ; turn on the FET xorwf PORTC,f OneEighty0 movlw b'00000100' ; 2ms pulse to put the servo somewhere IDK GOD xorwf PORTC,f call OneEightDegre movlw b'11111011' addwf PORTC,f call OneEightDegreR decfsz i,f ; make the loop happen 5 secdonds worth (250 times) goto OneEighty0 movlw b'11110111' ; Turn off the FETS andwf PORTC,f return FourtyMS ;39993 cycles movlw 0x3E movwf d1 movlw 0x20 movwf d2 FourtyMS_0 decfsz d1, f goto $+2 decfsz d2, f goto FourtyMS_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return Debounce ;20mS delay ;19993 cycles movlw 0x9E movwf d1 movlw 0x10 movwf d2 Debounce_0 decfsz d1, f goto $+2 decfsz d2, f goto Debounce_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return MuxDelay ;1323 cycles movlw 0x08 movwf d1 movlw 0x02 movwf d2 MuxDelay_0 decfsz d1, f goto $+2 decfsz d2, f goto MuxDelay_0 ;4 cycles goto $+1 goto $+1 ;4 cycles (including call) return ZeroDegre ;893 cycles movlw 0x73 ;B2 is orgional vlaue movwf d1 movlw 0x01 movwf d2 ZeroDegre_0 decfsz d1, f goto $+2 decfsz d2, f goto ZeroDegre_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return ZeroDegreR ;19093 cycles movlw 0xEA ;EA is orgional Value movwf d1 movlw 0x0F movwf d2 ZeroDegreR_0 decfsz d1, f goto $+2 decfsz d2, f goto ZeroDegreR_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return OneEightDegre ;2093 cycles movlw 0xC8 ; A2 orgional value movwf d1 movlw 0x02 movwf d2 OneEightDegre_0 decfsz d1, f goto $+2 decfsz d2, f goto OneEightDegre_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return OneEightDegreR ;17893 cycles movlw 0xFA movwf d1 movlw 0x0E movwf d2 OneEightDegreR_0 decfsz d1, f goto $+2 decfsz d2, f goto OneEightDegreR_0 ;3 cycles goto $+1 nop ;4 cycles (including call) return binary_to_bcd CLRF hundreds SWAPF bin,w ;w = A0*16+A1 ADDWF bin,w ;w = A0+A1 ANDLW b'00001111' ;w = A0+A1 % 16 SKPNDC ;if A0+A1 > 16 ADDLW 0x16 ;w += 16 SKPNDC ;if w % 16 > 10 ADDLW 0x06 ;w += 6 ADDLW 0x06 ;w += 6 SKPDC ;if w < 10 ADDLW -0x06 ;w -= 6 BTFSC bin,4 ADDLW 0x16 - 1 + 0x6 SKPDC ADDLW -0x06 BTFSC bin,5 ADDLW 0x30 BTFSC bin,6 ADDLW 0x60 BTFSC bin,7 ADDLW 0x20 ADDLW 0x60 RLF hundreds,f BTFSS hundreds, 0 ADDLW -0x60 MOVWF tens_and_ones BTFSC bin,7 INCF hundreds,f return END ; directive 'end of program'
Schematic
Board
[1] Batch PCB board. (login required to view/buy)
Hardware
This is the bracket used to suspend the servo in position in the water tank of the potty.
A 1:1 PDF template of the bracket assembly is here Media:Bracket.pdf
-
Top
-
Side
-
Front
-
Front
Pictures
-
Fully assembled DBL Flusher in place.