Hi again! I'm using waterflow meter like: http://www.ebay.com/itm/261152910400?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
I have made a code for that and I can measure water consumption. When testing 1,5 l amount of water the lcd shows exatly 1.5l.
Problem is that when passing water fast through watermeter Picaxe cannot register hall sensor's click enough accurately. So amount of 1.5l consumpted water can be in lcd 0,7l. That's not good.
I have tested that hall sensor and it give voltage values 0,02V(because of leakage current?) and 2,68V. Because of that I ended up to use readadc10 command.
EDIT:
Idea of measuring: 0,02V get adc value 6 and 2,68V get adc value 530.
Every time adc value is >300 and b2 = 2 then it increases b3. When it have done that 40 times it means 1 desilitre is passed.
every time adc value is < 100 b2 is setted to number 1. That method prevents that b3 is not increasing more than 1 click
QUESTION?
So...Do you have any idea how I could improve my code so that it could measure consumpted water faster?
I have made a code for that and I can measure water consumption. When testing 1,5 l amount of water the lcd shows exatly 1.5l.
Problem is that when passing water fast through watermeter Picaxe cannot register hall sensor's click enough accurately. So amount of 1.5l consumpted water can be in lcd 0,7l. That's not good.
I have tested that hall sensor and it give voltage values 0,02V(because of leakage current?) and 2,68V. Because of that I ended up to use readadc10 command.
EDIT:
Idea of measuring: 0,02V get adc value 6 and 2,68V get adc value 530.
Every time adc value is >300 and b2 = 2 then it increases b3. When it have done that 40 times it means 1 desilitre is passed.
every time adc value is < 100 b2 is setted to number 1. That method prevents that b3 is not increasing more than 1 click
QUESTION?
So...Do you have any idea how I could improve my code so that it could measure consumpted water faster?
Code:
readadc10 c.0, w0
if w0 > 300 and b2 = 1 then inc b3 ' If voltage 2,7V and b2 = 1 -> let's increase 1 click
else if w0 > 300 and b2 = 1 then let b2 = 2 ' Let's set b2 back to value 2
end if
if w0 > 300 then let b2 = 2 ' if voltage 2,7V, sp b2=2
end if
if w0 < 100 then let b2 = 1 ' if voltage 0,02V, so b2=1
end if
if b3 > 40 then goto increasing
goto main
increasing:
if b3 > 39 then inc b4 ' 40 click = 1 dl
end if
if b3 > 39 then let b3 = 0
end if
if b4 > 9 then inc b5 ' 10 dl = litre
end if
if b4 > 9 then let b4 = 0
end if
if b5 > 9 then inc b6 ' tens litres
end if
if b5 > 9 then let b5 = 0
end if
if b6 > 9 then let b4 = 0 '
end if
if b6 > 9 then let b5 = 0
end if
if b6 > 9 then let b6 = 0
end if
serout b.0, n2400, (254, 128)
serout b.0, n2400, (#b3)
serout b.0, n2400, (254, 192) ' Show tens litres
serout b.0, n2400, (#b6)
serout b.0, n2400, (254, 193) ' Show litres
serout b.0, n2400, (#b5)
serout b.0, n2400, (254, 194) ' Show comma
serout b.0, n2400, (",")
serout b.0, n2400, (254, 195) ' Show desilitres
serout b.0, n2400, (#b4)
serout b.0, n2400, (254, 197) '
serout b.0, n2400, ("Litres")
goto main
Last edited: