How to program math functions in STL...

PLJ

Member
Join Date
Oct 2003
Location
KSA
Posts
6
For Simatic s5-135U/155U programming we use the following STL codes for addition, substraction, multiplication and division:
+, -, X and ::
How do we perform the following functions in STL?

1. Power, for eg. 3.5^1.45
2. Square root function, for eg. Sq. root of 3455.67
3. Logarithm functions, for eg. Log(n) 12.55 and so on...

I understand there are some special function blocks for various use. Can we use them for such operations? How do I can obtain a copy of such functions? Could somebody help please?
 
May I help you, May be

Dear BLJ

I do not use simatic 4 seiemns, But i use Isagraph to program PEP/ Smart1.
and the STL looks like Structured text ST, in it many blocks like SR, &, OR, LOG,....

Just you write something like that:

result:=and(x1,x2)

or

x2:=log(30) , I repeat something like that.

or you just enter the site for siemens, ank ask the customer Help.
 
PLJ said:
1. Power, for eg. 3.5^1.45
2. Square root function, for eg. Sq. root of 3455.67
3. Logarithm functions, for eg. Log(n) 12.55 and so on...
If You need that kind of math, you have very wrong PLC for that.
This is my opinion only.
 
STL Math Function

For S5 Math Function is existing an special library (It's a product of Siemens). Unfortunetely it is necessary to buy it :-(.
 
PLJ,

as I see it you only need calculation of LN and EXP. The other formulaes can be reduced to these two calculations:

  1. Power, for eg. 3.5^1.45 -> EXP(LN(3.5)*1.45)
  2. Square root function, for eg. Sq. root of 3455.67 -> = 3455.67^0.5 (see 1)
  3. Logarithm functions, for eg. Log(n) 12.55 and so on... -> LN(12.55)/LN(n)
    [/list=1]

    Of course, the mentioned PLC's don't have LN and EXP functions on board, but don't panic: you can find some formulaes to calculate these functions using only ADD, SUB, MUL and DIV instructions on the web. Visit the Wolfram website - Elementary functions and check out the vast number of mathematical formulaes.

    But don't forget: if you want it cheaper, you have to program more and the program will be slower. You can't have it both ways! :confused:

    Kind regards,
 
Another source of information about calculation of those not so basic math functions is SourceForge . There you will find descriptions about how to implement these kind of calculations on microprocessors and so. It should be fairly easy to implement these on PLC too.

I'm sure there are plenty of sites with the same kind of info. All you have to do is search. Use searchterms like Chebyshev polynomials or infinite series, combined with listing, exp, ln, machinecode, microprocessor and so on.

Kind regards,
 
Hai everybody,
Thanks for the replies on Maths functions. I posted an enquiry on these functions only to explore the possibilities of using our existing PLC (Simatic 155U) for measuring gas flow to our Gas turbines. The esxisting S5 program does not support such functions. But recently I made an enquiry with Siemens on the subject. These functions are available with them for sales. I think I will place an order for it if available on reasonable price. I shall be in touch with you later. Thanks again, especially to jvdcande for his sincere efforts to help me.
 

Similar Topics

Hi guys, I have a stupid question, I used a lot of Math & Compare instruction (MUL, CPT, .. )in my PLC, will it harm or one day PLC will cause...
Replies
8
Views
2,685
hi im a new here and still studying s7 200, does any here can give me a sample problem and program on how to use the math instructions so that i...
Replies
0
Views
1,661
my ccw softwer stops working when i add and try to open a ladder program.
Replies
0
Views
36
I have an old Sentry Palletizer (S/O Number 3007 / Serial Number 1172) that has lost its program as the backup battery died years ago. I can...
Replies
0
Views
107
Hi All, As a precaution my company has been collecting copies all the HMI and PLC programs. I have recorded copies of most of our sites...
Replies
0
Views
73
Back
Top Bottom