Browser compatibility warning: CircuitLab may not work as expected in your web browser. Please see our System Requirements.
Created by
Created May 10, 2012
Last modified May 10, 2012
Tags counter   picaxe   raingauge  

Summary

Simple momentary reed switch based raingauge interface counter circuit based on PICaxe-08M.


Description

PICAXE08M

;PIC chip pin allocations

;pin 1 +V

;pin 2 serialIn

;pin 3 IN4/OUT4/ADC4 ;

;pin 4 IN3/ infrain ;

;pin 5 IN2/OUT2/ADC2/PWM2 ;serial LCD

;pin 6 IN1/OUT1/ADC1 ;reed switch from tipping bucket raingauge

;pin 7 OUT0/serialOut/infraOut ;LED

;pin 8 0v

;AUTHOR: M.R.CUTLER

;DATE: 09/05/2012

;PROGRAM DESCRIPTION:

; Counts show pulses on reed switch input from 1mm/pulse rain gauge.

; Writes values to EEPROM (power cycle preserved data). (I know the 100k EE write limit, but that is 100m rain - over 10 years worth!)

; Outputs count on LCD 20x2 serial display. Flashes LED when pulse received too.

; Max count 99999999

symbol LCD =2

symbol reed = 1

symbol led = 0

symbol rainpulseH = w0

symbol rainpulseL = w1

symbol zeros = w2

symbol EErainL = 0

symbol EErainH = 2

;pick up original count

read EErainL, WORD rainpulseL

read EErainH, WORD rainpulseH

gosub LCD_clr

serout LCD,N2400,("Precipitation gauge:")

gosub dispLCD

do

setfreq m8

do

loop until pin1=0

setfreq m4

high LED

pause 200 'just to be sure of no false bounce triggers

;wait for fall back (theoretically not at all necessary, but useful in

; preventing reading being lost in the event of cable dead-short situation)

do

loop until pin1=1

inc rainpulseL

if rainpulseL>9999 then

inc rainpulseH

rainpulseL = 0

if rainpulseH>9999 then

  rainpulseH = 0

endif

write EErainH, WORD rainpulseH

endif

write EErainL, WORD rainpulseL

gosub dispLCD

low LED

loop

LCD_clr:

serout LCD,N2400,(254,1)

pause 30

return

dispLCD:

serout LCD,N2400, (254,192)'set to beginning of line2

' print leading zeros

zeros = rainpulseH / 1000

if zeros = 0 then

serout LCD,N2400,("0")

zeros = rainpulseH / 100

if zeros = 0 then

  serout LCD,N2400,("0")

  zeros = rainpulseH / 10

  if zeros = 0 then

    serout LCD,N2400,("0")

  endif

endif

endif

serout LCD,N2400,(#rainpulseH)

'print leading zeros

zeros = rainpulseL / 1000

if zeros = 0 then

serout LCD,N2400,("0")

zeros = rainpulseL / 100

if zeros = 0 then

  serout LCD,N2400,("0")

  zeros = rainpulseL / 10

  if zeros = 0 then

    serout LCD,N2400,("0")

  endif

endif

endif

serout LCD,N2400,(#rainpulseL,"mm ")

return

'initial value for testing 09999998.

EEPROM 0,(0E,27,E7,03)

;EOF


Comments

No comments yet. Be the first!

Leave a Comment

Please sign in or create an account to comment.

Revision History

Only the circuit's creator can access stored revision history.