buntay
Senior Member
Chip = 08m2
Purpose= water meter monitor
code:
Greetings all!!
So, I have a water meter I am installing for a renter that uses roughly 1500 gallons a month. The purpose for this project is so I can get that meter reading from my house through a ttl to Ethernet connection for billing purposes, that part is not the problem I need help with.The water meter has a pulse for each gallon that passes through it and I am counting those pulses. I decided to put each new count into the eprom in case the power drops out or some type of reset happens.
I am aware of the 100,000 cycles to a single address on the eprom. My question is how do I maximize eprom use by writing to a different address of the eprom at a given point, say at 75,000 cycles.
Thanks in advance for any suggestions
Purpose= water meter monitor
code:
Code:
'c.0= USB out
'c.1= meter input
'c.2= serout
'c.3= serin
'c.4= water valve
'c.5= USB in
setfreq m16
read b15,WORD w0
b4=1
pause 10000
main:
b7=0
if w0> 9999 then let w0=0
end if
SERIN [1000], c.3,t9600_16,#b7
if b7=22 then goto control
w1=w0
if pinc.1 =1 then let w0=w1+b4: write b15,WORD w0:goto safe
else goto main
end if
safe:
pause 500
if pinc.1 =0 then goto main
goto safe
control:
b7=0
serout c.2,t9600_16,("ok",cr)
again:
SERIN [1000], c.3,t9600_16,#b6
if b6=2 then goto readout
if b6=3 then goto wateroff
if b6=4 then goto wateron
if b6=5 then goto logout
goto again
readout:
serout c.2,t9600_16,(w0,cr)
serout c.2,t9600_16,("ok",cr)
b6=0
goto again
wateroff:
high c.4
serout c.2,t9600_16,("Water Off",cr)
serout c.2,t9600_16,("ok",cr)
b6=0
goto again
wateron:
low c.4
serout c.2,t9600_16,("Water ON",cr)
serout c.2,t9600_16,("ok",cr)
b6=0
goto again
logout:
serout c.2,t9600_16,("LOGGGED OUT",cr)
serout c.2,t9600_16,("ok",cr)
b6=0
goto main
So, I have a water meter I am installing for a renter that uses roughly 1500 gallons a month. The purpose for this project is so I can get that meter reading from my house through a ttl to Ethernet connection for billing purposes, that part is not the problem I need help with.The water meter has a pulse for each gallon that passes through it and I am counting those pulses. I decided to put each new count into the eprom in case the power drops out or some type of reset happens.
I am aware of the 100,000 cycles to a single address on the eprom. My question is how do I maximize eprom use by writing to a different address of the eprom at a given point, say at 75,000 cycles.
Thanks in advance for any suggestions