PDA

View Full Version : Hall Effect flow meter with 16F876



revelator
- 10th March 2010, 19:44
I've been trying t read a Seametrics SEB 3/4" flow meter which produces 330 pulses per gallon with a 16F876. This flow meter is a hall effect with three wires : Red 5-32 VDC, Wht (signal), and Blk Negative. I'm trying to use TIMER0 (pin 6 on the 16F876 RA4/TOCK1) to count to say 40 pulses then start a process.

I see that I can set pullup on the OPTION_REG but tried that with no reads. The other option is to hard wire a resistor (1-10k) to vdd and not use the pullup option. Is that typicaly what's used for a hall effect sensors?

Another question of confusion: Suppose I have a high flow rate of say 10 gals/minute on this flow meter, ~55 pulses/sec. Does Timer0 keeps tack of incoming pulses while the processor is running about with other tasks in the program, say reading a digital temp sensor in the main program loop.

Does it make a difference in the above if I'm using Timer0 interrupts or not. Would I miss pulses if I'm not using interupts?

First time using timers.....

thanks

Darrel Taylor
- 10th March 2010, 20:41
For a 16F876, the internal pull-ups are only on PORTB.
So you'll need an external pull-up resistor.

Yes, Timer0 will keep counting while the program is off doing other things, but it will only count to 255 on it's own, and you have to keep comparing the value in your program to know when the required amount has been dispensed.

If you use Timer1 instead using the T1CKI input, then it can count up to 65535 and you can put a CCP module in COMPARE mode which will watch for the Timer value to match what you've placed in the CCPR1L:H registers.
When it gets a match, it will fire a CCP interrupt that can immediately turn off the solenoid valve.

Actually responding to interrupts will be the fastest, or you can just poll the CCPIF flag in the main loop.

hth,

aratti
- 10th March 2010, 20:42
....I see that I can set pullup on the OPTION_REG but tried that with no reads

Internal pullups apply only to portB.


...Does it make a difference in the above if I'm using Timer0 interrupts or not

Yes it does. Since Timer0 will count up to 255 then start from zero again, The interrupt (will happen with an overflow) will tell you that you have to add 256 to the count following the overflow to obtain the total count.


...Suppose I have a high flow rate of say 10 gals/minute on this flow meter, ~55 pulses/sec. Does Timer0 keeps tack of incoming pulses while the processor is running about with other tasks in the program, say reading a digital temp sensor in the main program loop.

Yes it does.

Timer1 is a 16 bits counter and can count up to 65536 before overflow, it will give you planty of time for your count.

Al.