Shop OBEX P1 Docs P2 Docs Learn Events
Determining flow rate, using a Ping)) sensor — Parallax Forums

Determining flow rate, using a Ping)) sensor

tenslowtenslow Posts: 6
edited 2014-09-24 19:52 in BASIC Stamp
Hello, Forum!

Long time forum lurker, first time posting :)

I have an open tank, 3ft x 2ft x 1ft, with a drain at the bottom. Once the drain is opened, the water level decreases. I am trying to use a Ping)) sensor to determine the rate the level (dy) is dropping over time (dt). Once I know dy/dt I can use the tank's geometry to find the flow rate out of the tank.

My question is: how can I find this dt? In Paralax's 'Process Control' book and in every PID control forum thread I've read unit-less samples are taken at intervals to find dt. I need my dt in seconds... is there a clever way for me to figure out the time elapsed, between Ping))

The code I'm working on is attached.

Thanks!!
Tony

Ultrasonic_Flow_R0.bs2

Comments

  • ercoerco Posts: 20,257
    edited 2014-09-24 12:51
    Welcome to the forums, tenslow.

    I'm assuming a downward-facing PING can get a good reading off of the top of the fluid. Write your program to take a PING reading at any interval you like, a simple PAUSE statement will wait for a specified time. For instance (pseudocode):

    Read PING sensor, dist= Yold

    PAUSE 10000 (wait 10 seconds)

    Read PING sensor, dist= Ynew

    change=Ynew-Yold

    rate =change/10



    Does that help?

    Edit: After looking at your program, I see
    dt = timeOLD - timeNEW                 'HOW CAN I MAKE THIS LINE WORK???
    

    So you're very close already, you just need to structure your program as above, take two PING readings (and call me in the morning, ha) a few seconds apart using the PAUSE command, and dt is whatevet PAUSE interval you choose.


    Way back in college we had a theoretical problem like this, we had to use CSMP to model a water tank and drain line to calculate the flowrate as a function of time. Good times!
  • tenslowtenslow Posts: 6
    edited 2014-09-24 13:44
    Thank you, so much, erco!

    This is just the sort of insight I was looking for... wonderfully simple! I've taken your advice and am tinkering with my program, now. After I get a few other details ironed out, with the program, I think she'll work pretty well.

    This is for a little personal project I've been working on, all summer, and you helped me make some good headway on the last part of it- which is nice especially since the first day, of my last quarter in school, starts tomorrow!
  • ercoerco Posts: 20,257
    edited 2014-09-24 19:52
    HTH, hope you get all working fine. Sounds like a good problem.
Sign In or Register to comment.