S5 STL for Counter Card

emokar

Member
Join Date
Sep 2006
Location
turkiye
Posts
77
Hello,
I have a question about S5 STL programming. I have been working on those three networks for days , however i could not understand the operation yet.

In the code part below, DB 140 , used for Counter card is called and real encoder values are read. In the manual of IP240 counter card, these explanation for DW 30 & DW 31 can be found.

While configuring the counter card with fb167:
:JU FB 167
Name :STRU.POS
BGAD : KF +128
KANR : KF +1
DBNR : KF +140
AFL : KF +1
IMP : KF +0
BCD : KY 0,0
PRA1 : KM 00000000 00000000
PRA2 : KM 00000000 00011101
RUND : KF +0
LOSE : KF +0
DAV : KF +0
PAFE : FY 200

i could not realize the line
BCD : KY 0,0

Does this mean i read the encoder value binary or BCD?

No matter if BCD or binary is used , i could not understand the shifting commands SRW 2 and SLW 14.

At the end i read the encoder value from DW103 but i just could not understand how?

The mentioned code is below , thank you for your help.

Best Regards ,
Emre


Segment 1
Name :FAHREN

:C DB 140
:***


Segment 2
:L DW 31
:SRW 2

:T DW 101
:
:L DW 30
:T FW 160
:SLW 14

:T DW 102
:L DW 101
:OW
:T FW 162
:A F 160.7
:= F 162.7
:
:L FW 162
:T DW 103
:***


Segment 3
:L DW 103
:L KF +17900
:>=F
:= F 150.0
:
:L DW 103
:L KF +17750
:>=F
:= F 150.1
:***
 
krk said:

Thanks. Do you have any idea why srw and slw are used?
i read in the manual thar srw 2 means dividing by
2^2=4 and SLW 14 means multiplying with 2^14=16384.
i am confused :(
 
Hi Emre,

Yes, you're correct about the division and multiplication effect of SRW & SLW on a word, but they can also be used to manipulate bits to required positions when you have split functions within a word. (for example analog I/O words which have status bits in the same word that holds the actual value).

I had a quick attempt at analysing the bit movement in Segment 2. (see attached file)

I initially thought that the code was attempting to divide (doubleword) DD30 by 4, place result in a single word and recreate the original sign bit.

This is most likely incorrect as does not explain why the LSB of DW30 ends up in the second position of DW162/DW103.

Without knowing the format and meaning of the actual data held in DW30 & DW31 it is very difficult to see what's going on. (for me anyway).


Kevin
 

Similar Topics

Hello friends, I have encoder connected with motor and i have did a counter in this encoder but i want your help to make a counter with one dp...
Replies
5
Views
2,101
Hi, am not an expert on Siemens STL, but I have and object to do on Siemens S7 400 using STL, kindly advice. Objective: - Cumulatively Count...
Replies
8
Views
4,991
Hello, I came across this block to convert a counter into a char. I have tried to use it, but I am getting some errors, I am sure it is probably...
Replies
2
Views
1,521
I am just learning S7 and STL. So please forgive me if this sounds basic. I am using a CPU 416F-2 PLC. I have a counter and it increments once...
Replies
0
Views
2,003
I am just learning S7 and STL. So please forgive me if this sounds basic. I am using a CPU 416F-2 PLC. I have a counter and it increments once...
Replies
0
Views
2,530
Back
Top Bottom