Hi all, I'm a VERY beginner in PICS (and also in Electronic) but my real hobby is Caving. Now, I have discovered that the researchs in underground environment are much more interesting with the use of Dataloggers and electronics. I haven't much money, so.... Briefly: I seen on various PIC sites the project TLOGGER by Stan Ockers (Temperature logger with PIC16F84 e DS1820): a lots of months ago Stan helped me, by E-mail, to realize my first logger prototype: very "essential" but also very ok for my use (Thanks,Stan!!) Now, I want enhance it to measure also the rainfall from an homemade rain gauge. One of the simplest methods I have seen (i think) is to count the times that a a bucket empties its contents, moving a magnet in front of a reed switch and causing an interrupt in the Tlogger (RB0 pin). So, I have written this code (really, a copy-paste from examples in the PICList mails and Stan Ockers CHEAPIC!) and... can anyone suggest to me if the code can be ok for this use or if there may be problems to use it together the DS1820? Below, there are the most important modifyes made to the code for recording rainfall : any help much appreciated. ;============================================================= ; Tlog1_3.asm ; 4Mhz Clock (no sleep) 24LC256 ; LIST P=16F84A __CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF ; Register definition: REG_1 EQU H'0C' REG_2 EQU H'0D' ..... ......... ..... ......... COUNT_LO EQU H'28' ; low byte of count rainfall (added) COUNT_HI EQU H'29' ; high byte of count rainfall (added) ORG 0 goto MAIN ; jump to the main program ORG4 ; jump to the interrupt routine goto ISR ;**************** Interrupt routine ******************; ; ( I have read that GIE is automatically disabled on entry to interrupt ; routine and re-enabled by the RETFIE instruction: ok?). ISR movwf W_TEMP ; save W swapf STATUS,W ; save status movwf status_temp ; bcf INTCON, INTF ; clear interrupt flag for next time incf count_lo, f ; increment low counter btfsc STATUS,Z ; rolled over to zero? Incf count_hi,f ; yes, increment high counter swapf status_temp,W ; get original status back movwf STATUS ; into status register swapf w_temp,f ; restore W swapf w_temp,W ; retfie ; re-enable GIE ;**************** The MAIN routine ******************; MAIN call INIT ; initialize ports etc. btfss PORTB,2 ; is button pressed ( RB2 low ) goto SETDLY ; yes, set the delay time btfss PORTB,3 ; is link in? ( RB3 low ) goto MEMDUMP ; yes, start dump of memory HOLDIT btfsc PORTB,2 ; wait for button to be pressed goto HOLDIT ;---------------- Start measure ading ---------------------------------; bsf INTCON, INTE ; set RB0 interrupt enable MEASURE call BLINK ; blink the LED movf COUNT_HI,W ; return value in 'W' call SAVEBYTE ; save register COUNT_HI in EEPROM movf COUNT_LO,W ; return value in 'W' call SAVEBYTE ; save register COUNT_LO in EEPROM clrf COUNT_HI ; reset count registers for next time clrf COUNT_LO ; ;-------------- DS1820 - Start temperature reading ------------------; call READTEMP ; collect a data point from DS1820 ........................ ........................ ........................ (and so on..) -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.