A bit of a math problem


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980

    Default A bit of a math problem

    I need to control 4 pumps in relation to the rate that the level of a tank is reducing.

    This could be solved with a derivative but there should be a better solution for an 8-bit humble PIC.

    There is a rate variable that the user sets, 4 outputs (to the pumps) and a sensor for the current water level.

    If the rate the tanks empties is small then one pump operates. If this rate increases then another pump up to four contribute to fill the tank.

    Thanks
    Ioannis

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    number of pumps = ((discharge rate) /(individual pump capacity))+1

    if the rate of change of tank level is not linear with discharge rate then use a lookup table
    Warning I'm not a teacher

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    Thanks Richard.

    My problem is to find that rate of change.

    I have a sensor that gives me the level of the tank. Also a variable 'rate' that is set by the user.

    Now I have to combine these two and decide how many pumps should work at a time.

    Ioannis

  4. #4
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    Take measurement ever XYZ sec.
    Discharge rate is First-Second.
    Eg do something like this:
    Code:
    RunFirstTime:
    ADCIN SensorValue' or whatever
    OldSensorValue=SensorValue' initialization at beginning of program
    return
    
    SubRoutineToRunEveryXYZsec:
    ADCIN SensorValue' or whatever 
    DischargeRate=OldSensorValue-SensorValue
    OldSensorValue=SensorValue
    RETURN
    Depending on how often you call SubRoutineToRunEveryXYZsec you can get quicker response, or better resolution(wider range of values). That all depends how quick your process is.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    Thanks Richard. I see what you mean.

    Greet help on that small hour that my mind is almost in literary sleep mode!

    Ioannis

  6. #6
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    Another approach would be:
    SELECT CASE Level
    CASE < 80 : HIGH Pump1 : LOW Pump2 : LOW Pump3 : LOW Pump4
    CASE < 70 : HIGH Pump1 : HIGH Pump2 : LOW Pump3 : LOW Pump4
    CASE < 60 : HIGH Pump1 : HIGH Pump2 : HIGH Pump3 : LOW Pump4
    CASE ELSE : HIGH Pump1 : HIGH Pump2 : HIGH Pump3 : HIGH Pump4
    END SELECT

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: A bit of a math problem

    Thanks mpgmike. Good one too!

    Ioannis

Similar Threads

  1. math function to change a value 1- 8 to a bit representation
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 21st October 2014, 03:14
  2. 32 bit math
    By fnovau in forum General
    Replies: 4
    Last Post: - 13th February 2008, 00:55
  3. Averaging 16 bit values without using 32 bit math
    By sirvo in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th October 2007, 23:18
  4. PIC18Fxx math 24 & 32 bit
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd December 2006, 13:52
  5. 32 bit math
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 28th August 2006, 14:34

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts