×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Matlab pump control

## Matlab pump control

(OP)
I need to use the Matlab for controling water pump speed which will control water level in a small tank. Water pump (windshield-water pump, 12v) is connected to DC-DC converter controller which is control by Matlab (0-5V).
Water level is messured by pressure sensor and this is INPUT.
So this is what i need from Matlab:

When input in Matlab is 0-0.5V, OUT must be 5V.
When IN is 2.5V, OUT must be 3V. If Input then raises, OUT must decrease for 0.5V. If it raises again, then OUT must again decrease by 0.5V. And so on.
If Input lowers then OUT must raise for 0.5V. And if it sill raises, again 0.5V increase in OUT and so on...
When IN is 4V, OUT must be 0V.

So if someone can help me to write code in Matlab that will do that.
Thank You.
Replies continue below

### RE: Matlab pump control

For real-time simulation?
Why not use an embedded function in Simulink that has a few if statements that say exactly what you said.

"When input in Matlab is 0-0.5V, OUT must be 5V."

%
while input<=0.5 & input>=0
output=5;
end
%

ect.

Fe

### RE: Matlab pump control

There's some missing information here:

- What is the sampling rate of your system?  Over what period is a raise or fall in voltage measured?

- What's the desired behaviour between 0.5V and 2.5V?

- Steve

### RE: Matlab pump control

(OP)
Yes it is for real time simulation.
I must control water level in one tank. Motor is pumping water, and water is flowing out through manual valve. And pressure sensor is there to "see" water level.

So my system must fill tank with water and then control level fluid to be lets say around 30-32cm (pressure sensor reading 2.5-2.7V).

As a read on web and getting familiar to Matlab and Simulink, i see that for controling water level is maybe better use some PID controller.
With this IF statements it can be done too i think, but maybe it is simplier with PID? But how to do it.

Sample rate i don't know. I need something to start with that my system work, then i will fine tune it.

### RE: Matlab pump control

Without a sample rate, your problem statement is meaningless.  How much must the input raise to decrease your voltage by 0.5V?  And is that a raise over a period of 1 microsecond or one hour?

- Steve

### RE: Matlab pump control

(OP)
Sorry if i don't understand you or you me because of my english is not so good, and i am not that tehnical about this stuff.

When input raise 0.3V over 2.5V (which will be refferent fluid level), then out must decrease so that motor pumps water slower.
0.3V raise is done in 2 seconds.

### RE: Matlab pump control

Is it a homework assignment?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

### RE: Matlab pump control

(OP)
A something like that. I need it for my faculty work, and we didn't learnt Matlab much, just some basic stuff.

### RE: Matlab pump control

Seems like you have zero knowledge of control.
Without the basics, it will be difficult to help....

Aside from this, my opinion is to use a PD or PI with set point diversion.

Fe

### RE: Matlab pump control

lol...Gregs comments always make me laugh....but always soo true.

Fe

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!