PDA

View Full Version : A bit of a math problem



Ioannis
- 8th February 2018, 00:22
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

richard
- 8th February 2018, 03:10
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

Ioannis
- 8th February 2018, 09:09
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

pedja089
- 8th February 2018, 11:01
Take measurement ever XYZ sec.
Discharge rate is First-Second.
Eg do something like this:

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.

Ioannis
- 8th February 2018, 15:02
Thanks Richard. I see what you mean.

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

Ioannis

mpgmike
- 8th February 2018, 17:26
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

Ioannis
- 9th February 2018, 11:26
Thanks mpgmike. Good one too!

Ioannis