ADD Function in TIA PORTAL

Abouda

Member
Join Date
Mar 2024
Location
Algeria
Posts
21
Im trying to create a level indicator for water Tank
i have used the ADD function while the pump is on and level increasing
everything works well, except that the addition operation is kind of weird
once it worked fine then after that its just adding numbers in high speed once it starts it gets over 33k
what can be the solution for such problem without need of frequency tool?
 

Attachments

  • 01.JPG
    01.JPG
    18.9 KB · Views: 22
  • 02.JPG
    02.JPG
    23.2 KB · Views: 22
J
how fast do you want it to increase when the pump is on?
Ust not that fast, because i'm using HMI and its rising super fast showing full tanks at the start
In real life i'll be using analog input from the level sensor i supose, unless im using degital Level indicator
 
J

Ust not that fast, because i'm using HMI and its rising super fast showing full tanks at the start
In real life i'll be using analog input from the level sensor i supose, unless im using degital Level indicator
if you make the level variable an LREAL data type, and add an increment with a value of 512.0-1 each scan cycle when that pump output bit's value is 1, then the "level" will increase about 2 units per second (assuming mean scan cycle rate of 1kHz). Changing the increment will change the rate.
 
I
if you make the level variable an LREAL data type, and add an increment with a value of 512.0-1 each scan cycle when that pump output bit's value is 1, then the "level" will increase about 2 units per second (assuming mean scan cycle rate of 1kHz). Changing the increment will change the rate.
I'll give that a try and see how it'll work.
 
It will, what about emptying ? you need some idea of how long it takes to fill a tank do it in perhaps seconds & limit it to say 100 for % or if you know the tank capacity time it from empty to full, then simple maths to give some sort of level i.e. percent, litres etc. you also need to decrement it when the tank is emptying in reality, this is not practical as even the slightest difference in timing or pumps delivery/drain you will end up with a situation where it is either displaying full or empty when it is not.
 
My suspicion is that OP is a conventional (non-PLC) programmer and they are trying to build a simulation of the process to program and test against, but they do not yet understand the PLC scan cycle and its significance. I suggest they watch @Ron Beaufort's PLC bootcamp video series.

@Abouda: if you have experience with AWK/GAWK, the PLC program is like a GAWK script: the parsing of the input data in GAWK is analogous to the the input scan of the PLC, and the program you write (e.g. gawk -F: '{print "username=" $1 "; groupid=" $4 "; userid=" $3') is analogous to the PLC program.
 
It will, what about emptying ? you need some idea of how long it takes to fill a tank do it in perhaps seconds & limit it to say 100 for % or if you know the tank capacity time it from empty to full, then simple maths to give some sort of level i.e. percent, litres etc. you also need to decrement it when the tank is emptying in reality, this is not practical as even the slightest difference in timing or pumps delivery/drain you will end up with a situation where it is either displaying full or empty when it is not.
i can use equation to simulate emptying the tank same as filling it instead of ADD function i can use SUB function, i suppose it will work with same speed,
i already made it the first time filling 0=>100% in 60 seconds then use 20% for different process, and when tank is empty it refills it again, and manual emptying using SUB function worked perfectly then i had an error while finishing the project, after that it was all downhill even redoing everything from scratch didn't end up with same result as first time

in reality i can use the analog sensor and norm-x, scale-x to translate the signal into data that i can use to display the level.
 
My suspicion is that OP is a conventional (non-PLC) programmer and they are trying to build a simulation of the process to program and test against, but they do not yet understand the PLC scan cycle and its significance. I suggest they watch @Ron Beaufort's PLC bootcamp video series.

@Abouda: if you have experience with AWK/GAWK, the PLC program is like a GAWK script: the parsing of the input data in GAWK is analogous to the the input scan of the PLC, and the program you write (e.g. gawk -F: '{print "username=" $1 "; groupid=" $4 "; userid=" $3') is analogous to the PLC program.
unfortunately no i don't have any experience with AWK/GAWK, but i'll make sure to watch the bootcamp you have suggested to benefit the most out of it, thank you
 
It sounds like you already have a sensor, so why do it the hard way, as I said before although it may seem to work short term, over a long period just adding/subracting a constant based on a pump running it will go out of sync, a pump does not deliver a constant flow on startup & shut down & other possible interferences i.e. friction, pressure etc. the only other way is to have full & empty probes, that way when full or empty could use the probes to re-calibrate the levels.
 
When I am simulating a tank level, for example in a tank that is supplying a process but has a feed pump to implement control of it's level, I have the code
  • subtract 1 "level unit" (e.g. 512.0-1]) every scan cycle to emulate the process, and
  • add 2 level units every scan cycle when the pump is running.
So if the pump is not running, the level decreases, but if the pump is running then the level increases. Obviously I can play with the ratio between those [level units per scan cycle] rates.

If the "process" could also be running or not, then the subtract is also conditional.

If the control is via feedback, for example via a PID (though D is turned off, and sometimes I as well), then the add increment (per scan cycle rate) is scaled from the PID output CV.
 

Similar Topics

I have a small system controlled by a Siemens S7-1200 PLC. I created a totalizer function block (TIA v17), where I'm counting total revolutions...
Replies
16
Views
3,138
I know this sounds really stupid, but I have a function block program I have written and have been debugging. I have an ADD block that will not...
Replies
10
Views
2,354
I am troubleshooting an outside vendor program where add on instructions are used as well as these user defined function blocks. I am trying to...
Replies
3
Views
1,599
Good afternoon, I'm using RS Logix 5000 on an AB 1769 L24ER-QBFC1B, and basically in my logic, whenever a prox switch is made, I want the...
Replies
5
Views
5,034
Hey everyone, I am new to using the LogicMaster 90-30 software for the GE Fanuc 90-30 PLC, and I needed some help in incrementing registers...
Replies
16
Views
5,928
Back
Top Bottom