S5 code

Guinness

Member
Join Date
Jun 2011
Location
Helsingborg
Posts
11
I have this code in S5 and are trying to convert it to S7 ladder. But I'm stuck and don't get it. Please help

LW =BG
LW =KNKT
T FY 254
SRW 8
SLW 1
+F
T FY 253
LW =P/Q
L KS Q
!=F
= F 252.0
JC =M001
DO FW 252
L PW 0
JU =M002
M001: DO FW 252
L OW 0
M002: T FW 250
 
Code:
LW =BG      // This will be an Input to the block call, an integer number
LW =KNKT  // This too will be an Input to the block call, an integer number
T FY 254   // Store KNKT in FY254, it will store the right LSB
SRW 8      // Remove section of word stored in FY254 
SLW 1      // and multiply left potion by 2
+F           // Add it to BG
T FY 253   // and store in FY253
LW =P/Q    // This will be an Input to the block call, an integer number
L KS Q       // ASCII 'Q'
!=F            // if equal 
= F 252.0   // set bit 
JC =M001   // and jump to M001

DO FW 252  // so it loading a peripheral word whose address is the number
L PW 0       // Calculated into FY253, This is an INPUT
JU =M002   

M001: DO FW 252  // The same as above  plus the least sig bit in the high 
L OW 0     //   byte, this is an output (cannot access periphery)

M002: T FW 250   transfer the value into FW250
 
Not sure why the number is stored in FY254, unless its used further down.

Say BG = KF10, KNKT = KY 2,8 and P/Q = P

FY254 = 8 (its a byte so it would only accept the LSB from the word stored in the accumulator.

SRW8 and SLW1 would leave 4 in acc 1


+F would add that 4 to 10, so you would have 14

F 252.0 would be off as P/Q = P

DO FW252 would offset the pointer by 14

L PW0 would actually load PW14 ( so instant update of input word 14)


example 2

Say BG = KF11, KNKT = KY 1,5 and P/Q = Q

FY254 = 5 (its a byte so it would only accept the LSB from the word stored in the accumulator.

SRW8 and SLW1 would leave 2 in acc 1


+F would add that 2 to 11, so you would have 13

F 252.0 would be on as P/Q = Q

DO FW252 would offset the pointer by 256+13 so = 269 (as 252.0 is on)

L QW0 would actually load QW269
 
it's the fb40 in s5. I'm looking to find the same in s7, but I can't find what block I should use


FB40 means nothing to me, its not a Siemens block as you can see the code.

Pointers are done differently in S5 to S7, the above shows what it is doing, you need to look at the code as a whole to know why it is doing it and then re-write using S7 method.

It may be easier to change the format, it may be easier to keep to the same, wouldn't know without looking at the 'whole' so to speak.
 
I have this code in S5 and are trying to convert it to S7 ladder. But I'm stuck and don't get it. Please help

LW =BG
LW =KNKT
T FY 254
SRW 8
SLW 1
+F
T FY 253
LW =P/Q
L KS Q
!=F
= F 252.0
JC =M001
DO FW 252
L PW 0
JU =M002
M001: DO FW 252
L OW 0
M002: T FW 250

This must defenitely be an analog input FB. You can mmost likely use the standard SCALE (was it FC 105?)

Kalle
 
It reads PWxx or OWxx and puts it into the FW250.
If it isn't more code hidden below (scaling), the whole batch of code could be substituted in S7 by

L PIWxxx
T MW250

Kalle

Edit: The 'L OW' is loading of extended input pheriphery, and NOT an output word.
 
Last edited:
As already stated, the calling data is the key. If the calling data specifying the address is entered as constants, then you can replace the code with L PIWxxx as pointed out by Kalle. If the data specifying the address is stored in a DB then you will have to take a different approach.
 
As already stated, the calling data is the key. If the calling data specifying the address is entered as constants, then you can replace the code with L PIWxxx as pointed out by Kalle. If the data specifying the address is stored in a DB then you will have to take a different approach.

As LW is used (instead of L ) on both BG and KNKT, there are bound to be constansts used. BG is normally KF format and KNKT is KY.

If you use LW on an D-KF, or an I-W, you will in this code, find the address in the rightmost byte.

o_OI'm getting old, don't remember the weather forecast i saw 15 mins ago, but this **** from 20 years back is still existing in the cabeza.

Kalle
 
It reads PWxx or OWxx and puts it into the FW250.
If it isn't more code hidden below (scaling), the whole batch of code could be substituted in S7 by

L PIWxxx
T MW250

Kalle

Edit: The 'L OW' is loading of extended input pheriphery, and NOT an output word.

Ah right, its a long time since I did any S5, I know S flags were extended memory flags, but never used O for periphery, just thought that was a mistyped Q.

I still say this portion of the code is not scaling the analog, its reading in the raw data, it may well be scaled afterwards.

BG will be the basic offset to the start of data (probably the card address)
KNKT, the left byte is the offset on the card.

BG = 256 and KNKT = 0,x then PIW256 is the address, if KNKT = 1,x then PIW258 is the address, etc.

Unsure what the right byte signifies as that part of the code is not supplied.

The one question I do ask, if that is NOT a mistype and it is O and not Q, then why is the input parameter P/Q and not P/O?

Code:
LW =P/Q
L KS Q
!=F

I'm not convinced it is O to be honest.
 

Similar Topics

Hi All, Someone at work has put a PLC system on my desk, that's just been taken off an idle production line. He said "It's an S7 PLC. We don't...
Replies
10
Views
230
hello, I'm a student and for my final grade I have to repare a sepro robot. the only problem I have for now is that i have an error code 3...
Replies
0
Views
35
I received an email from a student with the following code attached. This is supposed to control a floodgate system, and supposed to be written...
Replies
23
Views
780
I have a machine which is undergoing upgradation. As part of the process two SEW drives are being replaced., existing Gen B with new Gen C. The...
Replies
3
Views
197
I want to set user security level based on the value of a tag in my PLC called "ActiveUser". That tag will contain the A-P code which we use for...
Replies
6
Views
214
Back
Top Bottom