![]() ![]() Just use math to convert the pulses to volume, and then use the time to convert to flow rate. You can keep track of time with the internal clock, instead of doing math to come up with the time. The idea behind interrupts is that it gets rid of delays and can count every change (pulse) as it happens. The problem with my first attempt is that it would display the results in a constant stream, which is why the part was added, as suggested by another forum member. Which is where I started with the original code I posted. This is the code guys tnx for your replies my application is to get the flow of water per minute and the total water that past the sensor but seems i couldnt understand this well Gallons = (float)totalPulses / PULSES_PER_GALLON Seconds = (float)(timeRun - startTime) / 1000 Gallons = (float)pulses / PULSES_PER_GALLON If(millis() - timeRun < FLOW_TIMEOUT) // still flowing If(millis() - timeRun < FLOW_TIMEOUT) // flow has started Volatile unsigned long lastPulseTime = 0 Here is another example of flow meter code where the pulses are called out at the top instead of mid-code - this one I did not write myself, I don't remember the name of the guy that helped me with it: #define FLOW_TIMEOUT 1000 If the application is to see how flow varies over time that might present difficulties. You have to have a pretty steady flow rate for them to have consistent readouts. The flow meter on the web page she listed in the OP says it's a hall effect sensor, but you're right about them not being super accurate. You would basically add somewhere in the code.įor calculating volume - I'd just run the thing into a bucket and weigh it (lbs), divide by 8.33 to get your gallons, do whatever conversions to get the unit you'll be using. That way, when you have dispensed your fluid and calculated the volume you can correlate it to the pulses in the flow meter. Gpm = (float)gallons * 60.000 / (float)seconds Īs far as calibration (that's the pulses if you're using a hall-effect sensor or something similar), I'd piggyback on the other replies - except have something in your code to display the pulses counted. If (pulseTime != 0) // when flow is active
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |