Structured Text Pump Control

WuShockKS

Member
Join Date
Mar 2021
Location
Kansas
Posts
4
Hello,
I am new to plcs and using structured text IEC 61131-3.

I want to turn off and on a pump based on level setpoints from an analog signal. I have the text.

if tankLevel > HighSP then
hspump1out := 0.0;
elsif tanklevel < LowSP then
hspump1out := 1.0;
end_if;

But how do I get the program to repeat? Once the level lowers to kick on the pump the program ends and does not turn off at the top setpoint.

Thanks
 
Post a screen shot of your code running with the level greater than the setpoint. Also post how your floating point hspump1out controls the pump off/on
 
Never seen that normally it should be true or false as outputs for pumps etc. will be digital (Boolean) not floats.
The code would normally be called cyclically in a task so runs every scan.
 
Silly question, but what platform is this? This reminds me of the OMRON (20 odd years ago) that needed an instruction to tell them to cycle the program at the end of the program. Perhaps your platform has similar?
 
Is it ELSIF or ELSEIF in this implementation? help.codesys.com seems to use ELSIF, but there are a few occurrences of ELSEIF there.
 
Here is an example showing the value of the variables when the plc is running. Your screen shot does not show any, it is a repeat of your original post in a different format.

pump1.jpg
 
Pump is turned ON if the value is higher than HighSp and OFF if value is lower than LowSp. My question is: what if the value is BETWEEN the low- and high limit?

Edit: You will need something like this (don't know exactly since i don't know your application)

IF Level < LowSp AND level <HighSp THEN

Pump:=TRUE;

ELSE

Pump:= FALSE;

END_IF
 
Last edited:
Pump is turned ON if the value is higher than HighSp and OFF if value is lower than LowSp. My question is: what if the value is BETWEEN the low- and high limit?


No change from the previous scan's value; this is bang-bang control with a hysteresis gap.
 

Similar Topics

Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,170
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating...
Replies
3
Views
440
Trying to put these equations in structured text program in a Micro 830. when I run the verify I get this error. ;:expected before this new...
Replies
4
Views
395
Hey all, Studio v20.05 Background. We are piggy backing another system to record attributes for product travelling down the line and several...
Replies
21
Views
3,422
Hi, In our company (programming mainly Beckhoff PLCs) we are establishing internal coding guidelines for ST. Until now, the conventions were...
Replies
5
Views
1,018
Back
Top Bottom