Help for convert s5 to s7

tulip

Member
Join Date
Oct 2005
Location
ist
Posts
236
Hi all,
I'm trying to transfer some S5 software to S7.

The S5 PLC is a 115U 943B and the S7 PLC is a 314.

I've copied the code below and my interpretation of it but I have a couple of queries:

:JU=INIT
M005:G DB101
:JU=M004
INIT:LW=CPU (CPU=115U or 135U Query)
:L KF+115
:><
:JC=U135
:L KH DE00 (FB's initial address of plc)
:T FW250
:L KH E400 (DB's initial address of plc)
:T FW252
:JU=STAR
U135:LW=CPU
:L KF+135
:><
:JC=ENDE
:JU=ENDE
:C DB0
:NOP 0
:T FW250
:NOP 0
:T FW252
STAR:LW=PROG
:T FW240 ( program number)
:L KF+0
:>F
:JC=NEX1
:L KF+1
:T FW240
:JU=NEX2
NEX1:LW=PROG
:L KF+48 (max.program number)
:<=F
:JC=NEX2
:L KF+48
:T FW240
NEX2:L KF+101 (db101 address)
:T FW254
M007:L FW254
:L FW240
:I 100
:>F
:JC=ENDE
:L FW254
:SLW 1
:L FW252
:+F
:LIR 0 ( LOAD CONT.OF A MEMORYWORD INDIRECT.INTO THE ACC1)
:L KB 0
:><F
:JC=M004
:L FW250
:L KF+402
:+F
:LIR 0
:L KF+58
:+F
:T FW242
:L FW254
:L FW242
:TIR 2 (TRANSFER CONT.OF ACC1.TO ACC2.)
:L KF+10 (created DB's length DB101)
:JU=M005
M004:L FW254
:L KF+1
:+F
:T FW254
:JU=M007
ENDE:...
:...
:...



What is equivalent these codes in S7?
 
...What is equivalent these codes in S7?

There are no (known) equivalents to LIR/TIR in S7.
You will have to rewrite the program completely, I'm afraid.

Kalle

Edit: Is there a FB201 / how does it look like?
Edit2: It's a long time since I was doing such coding, but to me it might look like it writes the physical memory address of DB[Program number] directly into a program line in FB201 (nasty coding!).
Hopefully LD, PeterW, LiamMoran or some of the other S5-guys could double check.
 
Last edited:
ENDE:...
:...
:...

Does this mean there is more code? If so please post all the code and the full argument list. Without it we can only guess....

...and my guess is this code is FB201 and it searches the list of DB's for matches against the PROG If the DB does not exist then it modifies itself (the G DB101 instruction) to automatically generate the DB
 
Last edited:
Yes ,this is FB201 Name:ANLAUF
FB201
NAME:ANLAUF
PROG D,KF (Prog.number=+2)
LAGE D,KF (Location number=+0)
ZWLA D,KF (One liners yes/no=+0)
PROZ D,KF (Process data=0...16=+0)
FREM D,KF (Foreign language yes/no=+0)
CPU D,KF (CPU type=+115)
LINE D,KF (Number of lines for retrieval=+0)

:JU=INIT DB PRODUCTION
M005:G DB101
:JU=M004
INIT:LW=CPU (CPU=115U or 135U Query)
:L KF+115
:><
:JC=U135
:L KH DE00 (FB's initial address of plc)
:T FW250
:L KH E400 (DB's initial address of plc)
:T FW252
:JU=STAR
U135:LW=CPU
:L KF+135
:><
:JC=ENDE
:JU=ENDE
:C DB0
:NOP 0
:T FW250
:NOP 0
:T FW252
STAR:LW=PROG
:T FW240 ( program number)
:L KF+0
:>F
:JC=NEX1
:L KF+1
:T FW240
:JU=NEX2
NEX1:LW=PROG
:L KF+48 (max.program number)
:<=F
:JC=NEX2
:L KF+48
:T FW240
NEX2:L KF+101 (db101 address)
:T FW254
M007:L FW254
:L FW240
:I 100
:>F
:JC=ENDE
:L FW254
:SLW 1
:L FW252
:+F
:LIR 0 ( LOAD CONT.OF A MEMORYWORD INDIRECT.INTO THE ACC1)
:L KB 0
:><F
:JC=M004
:L FW250
:L KF+402
:+F
:LIR 0
:L KF+58
:+F
:T FW242
:L FW254
:L FW242
:TIR 2 (TRANSFER CONT.OF ACC1.TO ACC2.)
:L KF+10 (created DB's length DB101)
:JU=M005
M004:L FW254
:L KF+1
:+F
:T FW254
:JU=M007
ENDE:L KF+150
:G DB10
:G DB11
:L KF+160
:G DB12
:***
MAX.PROGRAM SELECTION
:C DB10
:JU PB200 ( PULSE GENERATOR PB)
:L KB0
:T DR 29
:LW=PROG
:L KF+0
:!=F
:JC=PROO
:LW=PROG
:L KF+48
:>F
:JC=PRO1
:LW=PROG
:T DW33
:JU=ENDE
PROO:L KF+1
:T DW33
:JU=ENDE
PRO1:L KF+48
:T DW33
ENDE:***

:L DW1 ACTUAL PROGRAM QUERY
:L KF+0
:><F
:JC=NINU
:L KF+1
:T DW1
:T FY5 (SELECTED PROGRAM NO.BY HMI)
:JU=LOAD
NINU:L DW1
:L DW33
:<=F
JC=OK
:L DW33
:T DW1
:T FY5
:JU=LOAD
OK:L DW1
:T FY5
LOAD:JU=FB221 MAX.NUMBER LOCATION STORE
(NAME:LAD:MAX)
:JU=FB222 CHARGING THE PRESENT SITUATION NUMBER
(NAME:LAD:AKT)
(PROG:FY5)
:JU=FB224 STORE BETWEEN DOCUMENTS
(NAME:LAD:ZLE)
(PROG:FY5)
:JU=FB220 WORKING DB FOR PULT SOFTWARE
(NAME:pRG:BIN)
(PROG:FY5)
:L DW1
:T FY5
:***

:LW=LAGE LOCATION NUMBER
:L KF+0
:><F
:JC=LAGE
:JU=ENDE
LAGE:L DR29
:T FY240
:AN F 240.0
:S F 240.0
:L FY240
:T DR29
:C DB12
:LW=LAGE
:L KF+32
:<=F
:JC=M001
:L KF+32
:T FY240
:JU=M002
M001:LW=LAGE
:T FY240
:T FY241
M002:L KF+1
:T FW242
LOOP:L FW240
:DO FW242
:T DW0
:L FW242
:L KF+1
:+F
:T FW242
:L KF+25
:<F
:JC=LOOP
:JU=FB221
(NAME:LAD:MAX)
(PROG:FY5)
JU=FB222
(NAME:LAD:AKT)
(PROG:FY5)
ENDE:C DB10
:***

:LW=ZWLA ONE LINERS YES/NO
:L KF+0
:><F
:JC=ZWLA
:JU=ENDE
ZWLA:L DR29
:T FY240
:AN F240.1
:S F240.1
:L FY240
:T DR29
ENDE:***

:LW=PROZ PROCESS DATA 0....16
:L KF+0
:!=F
:JC=ENDE
:LW=PROZ
:T DW34
:L DR29
:T FY240
:AN F240.2
:S F240.2
:L FY240
:T DR29
ENDE:***

:LW=FREM FOREIGN LANGUAGE QUERY
:L KF+0
:!=F
:JC=ENDE
:L DR29
:T FY240
:AN F240.3
:S F240.3
:L FY240
:T DR29
ENDE:***

:LW=LINE NUMBER OF LINES FOR RETRIEVAL
:L KB0
:!=F
:JC=NEIN
:TAK
:T DW24
:L KF+100
:G DB13
:JU=ENDE
NEIN:L KH0000
:T DW24
ENDE:***

:L KH0000 SOFTWARE INITIALIZE
:T FW194
:A F4.0
:R F4.0
:A F3.5
:R F3.5
:C DB10
:T DW10
:T DW11
:T DW12
:T DW13
:T DW14
:T DW15
:T DW16
:T DW17
:T DW18
:T DW19
:T DW80
:T DW81
:T DW99
:***

:L KT120.1 DEFAULT TEXT DISPLAY
:T DW58
:L KT004.0
:T DW59
:C DB11
:L KF+0
:T DW15
:C DB10
:A F0.0
:AN F0.0
:SD T 118
:SD T119
:SD T 120
:SD T 122
:L KH0000
:T FY0
:T FY2
:BE






:
 
I've only got access to a 928CPU programming manual, but the LIR addresses for the 943 appears to be double the word address. FB201 is modifying itself at offset +58 which I read to be word +29, looking at the addresses for the step 5 code this does tie up with the data part of the G DB101 instruction.

fb201.JPG
 
The S5 code brings back old memories...
I mean I can recall that the 115U does not take an argument to G DB X, i.e. DO FWz/G DB0 was not allowed. I don't think the DO BS60 trick was allowed either. So we used to generate a fixed DB, f.x. DB255 and then write that address into the addres of the wanted DB-number.

So the good news must be that generating a DB is done easy and with 'clean' code in S7.;P


Kalle
 
FB201
NAME:ANLAUF
PROG D,KF (Prog.number=+2)
LAGE D,KF (Location number=+0)
ZWLA D,KF (One liners yes/no=+0)
PROZ D,KF (Process data=0...16=+0)
FREM D,KF (Foreign language yes/no=+0)
CPU D,KF (CPU type=+115)
LINE D,KF (Number of lines for retrieval=+0)
address
001B:JU=INIT DB PRODUCTION
001C: M005:G DB101
001E:JU=M004
001F: INIT:LW=CPU (CPU=115U or 135U Query)
0020:L KF+115
0022:><
0023:JC=U135
0024:L KH DE00 (FB's initial address of plc)
0026:T FW250
0027:L KH E400 (DB's initial address of plc)
0029:T FW252
002A:JU=STAR
002B:U135:LW=CPU
002C:L KF+135
002E:><
002F:JC=ENDE
0030:JU=ENDE
0031:C DB0
0032:NOP 0
0033:T FW250
:NOP 0
:T FW252
STAR:LW=PROG
:T FW240 ( program number)
:L KF+0
:>F
:JC=NEX1
:L KF+1
:T FW240
:JU=NEX2
NEX1:LW=PROG
:L KF+48 (max.program number)
:<=F
:JC=NEX2
:L KF+48
:T FW240
NEX2:L KF+101 (db101 address)
:T FW254
M007:L FW254
:L FW240
:I 100
:>F
:JC=ENDE
:L FW254
:SLW 1
:L FW252
:+F
:LIR 0 ( LOAD CONT.OF A MEMORYWORD INDIRECT.INTO THE ACC1)
:L KB 0
0057:><F
0058:JC=M004
0059:L FW250
005A:L KF+402
:+F
:LIR 0
:L KF+58
:+F
:T FW242
:L FW254
:L FW242
:TIR 2 (TRANSFER CONT.OF ACC1.TO ACC2.)
:L KF+10 (created DB's length DB101)
:JU=M005
M004:L FW254
:L KF+1
:+F
:T FW254
:JU=M007
ENDE:L KF+150
:G DB10
:G DB11
:L KF+160
:G DB12
:***
MAX.PROGRAM SELECTION
:C DB10
:JU PB200 ( PULSE GENERATOR PB)
:L KB0
:T DR 29
:LW=PROG
:L KF+0
:!=F
:JC=PROO
:LW=PROG
:L KF+48
:>F
:JC=PRO1
:LW=PROG
:T DW33
:JU=ENDE
PROO:L KF+1
:T DW33
:JU=ENDE
PRO1:L KF+48
:T DW33
ENDE:***

:L DW1 ACTUAL PROGRAM QUERY
:L KF+0
:><F
:JC=NINU
:L KF+1
:T DW1
:T FY5 (SELECTED PROGRAM NO.BY HMI)
:JU=LOAD
NINU:L DW1
:L DW33
:<=F
JC=OK
:L DW33
:T DW1
:T FY5
:JU=LOAD
OK:L DW1
:T FY5
LOAD:JU=FB221 MAX.NUMBER LOCATION STORE
(NAME:LAD:MAX)
:JU=FB222 CHARGING THE PRESENT SITUATION NUMBER
(NAME:LAD:AKT)
(PROG:FY5)
:JU=FB224 STORE BETWEEN DOCUMENTS
(NAME:LAD:ZLE)
(PROG:FY5)
:JU=FB220 WORKING DB FOR PULT SOFTWARE
(NAME:pRG:BIN)
(PROG:FY5)
:L DW1
:T FY5
:***

:LW=LAGE LOCATION NUMBER
:L KF+0
:><F
:JC=LAGE
:JU=ENDE
LAGE:L DR29
:T FY240
:AN F 240.0
:S F 240.0
:L FY240
:T DR29
:C DB12
:LW=LAGE
:L KF+32
:<=F
:JC=M001
:L KF+32
:T FY240
:JU=M002
M001:LW=LAGE
:T FY240
:T FY241
M002:L KF+1
:T FW242
LOOP:L FW240
:DO FW242
:T DW0
:L FW242
:L KF+1
:+F
:T FW242
:L KF+25
:<F
:JC=LOOP
:JU=FB221
(NAME:LAD:MAX)
(PROG:FY5)
JU=FB222
(NAME:LAD:AKT)
(PROG:FY5)
ENDE:C DB10
:***

:LW=ZWLA ONE LINERS YES/NO
:L KF+0
:><F
:JC=ZWLA
:JU=ENDE
ZWLA:L DR29
:T FY240
:AN F240.1
:S F240.1
:L FY240
:T DR29
ENDE:***

:LW=PROZ PROCESS DATA 0....16
:L KF+0
:!=F
:JC=ENDE
:LW=PROZ
:T DW34
:L DR29
:T FY240
:AN F240.2
:S F240.2
:L FY240
:T DR29
ENDE:***

:LW=FREM FOREIGN LANGUAGE QUERY
:L KF+0
:!=F
:JC=ENDE
:L DR29
:T FY240
:AN F240.3
:S F240.3
:L FY240
:T DR29
ENDE:***

:LW=LINE NUMBER OF LINES FOR RETRIEVAL
:L KB0
:!=F
:JC=NEIN
:TAK
:T DW24
:L KF+100
:G DB13
:JU=ENDE
NEIN:L KH0000
:T DW24
ENDE:***

:L KH0000 SOFTWARE INITIALIZE
:T FW194
:A F4.0
:R F4.0
:A F3.5
:R F3.5
:C DB10
:T DW10
:T DW11
:T DW12
:T DW13
:T DW14
:T DW15
:T DW16
:T DW17
:T DW18
:T DW19
:T DW80
:T DW81
:T DW99
:***

:L KT120.1 DEFAULT TEXT DISPLAY
:T DW58
:L KT004.0
:T DW59
:C DB11
:L KF+0
:T DW15
:C DB10
:A F0.0
:AN F0.0
:SD T 118
:SD T119
:SD T 120
:SD T 122
:L KH0000
:T FY0
:T FY2
:BE

I could not understand.There is a offset value +58.Is it call 58.address in FB201 or 29.address ?.Another question ,FB201 is called startup in OB21 and since it searches the list of DB's for matches against the PROG If the DB does not exist then it modifies itself to automatically generate the DB .If do I load all of DB's in CPU,is the prog.work?....
 
FB201

I could not understand.There is a offset value +58.Is it call 58.address in FB201 or 29.address ?

.Another question ,FB201 is called startup in OB21 and since it searches the list of DB's for matches against the PROG If the DB does not exist then it modifies itself to automatically generate the DB .If do I load all of DB's in CPU,is the prog.work?....

The 115U has 8 bits memory, and an instruction need 2 or 4 bytes depending of the type.
So address offset 58 will appear as line 29 in Step5. I think you can switch in Step5 to show the byte adressing also. My old S5/Stufe3 could.



To your second question; maybe. It might work, but there could f.x. be some missing initalizations.

It looks like this is a quite complex system of FBs and DBs. I think you will need to analyze and understand the complete system to manage to convert it to S7.

Kalle
 
Last edited:
I made some simplification on FB201 block and I will try but when I convert S5 to S7 some warnings occured.One of them:

S5 side S7 side
------- ---------
C DB10 OPN DB10
L DW1 L DB10.DBW1

This is okay I solved but the other warning ;

S5 side S7 side
------- ---------
T FW242 T MW242
DO FW242 T conv_akku1
L DW 0 L STW
T FW244 T conv_stw
L MB243
SLW 4
LAR1
L conv_stw
T STW
L conv_akku1
L DBW (AR1,P#0.0)
T MW244

And ''Make sure that your global DB is set correctly.'' message is exist.Cursor is showing L DBW (AR1,P#0.0).How can I correct this warning?Thanks in advance...
 
Hi Kalle,I converted from S5 to S7.But when I simulate prog.cpu went to stop.I looked diagnostic side I saw OB121 not loaded( prog.fault)message.
Program is:
FB203
NAME:HAND
L MB 10 // BCD-CODED SELECT SWITCH
L W#16#F //MASKING
AW
T MB 240
CALL FC 31
L MB 241
T MB 234
L 12 //COMPARE This value between 1 and 12
<=I
JC M002
L 12
T MB 234
JU M003
M002: L MB 234
L 1
>=I
JC M003
L 1
T MB 234
M003: NOP 0

Above block is calling FC31.
FC31
NAME:BCDBIN // BCD-BIN TRANSFER
L MB 240
A M 0.0 // SET0
S C 127
A M 0.1 // SET1
S C 127
L C 127
T MB 241
Here is an oddity because C127 hasnt got process value.C127 was used here from BCD to binary.(in S5 file)
 
Your BCD coded select switch can only have the values 0..9 as any other value is not a valid BCD digit. The timer instructions must have valid BCD digits in the accumulator.
 
MB10 -----> 76543210 BİT
2^0--------0.bit
2^1--------1.bit
2^2--------2.bit
2^3--------3.bit
therefore I can select switch up to values 15.There is odd, C 127 how can set without processvalue?
How can I convert BCD value to binary value directly?
 

Similar Topics

i hope you could help me to convert the network Stl to lad it's apart from program of machine and i try to find solution for the reason of error...
Replies
10
Views
1,908
Hello everyone, I am migrating a program from STL to SCL via S7-1200 portal, I would like you to help me by converting these lines of code...
Replies
4
Views
1,618
Hi All i was wondering if any one would be able to help me. My version of studio5000 only allows ladder and FB. i have an AOI written in structure...
Replies
2
Views
1,528
Can someone please help me out and print this entire program to a PDF. Tried to zip and upload but too big so Google drive Link below to the adc...
Replies
2
Views
1,246
Hello, I am trying to figure out how to create / write / delete a .csv file on the SD card of an Allen Bradley PLC. There is a sample project...
Replies
1
Views
1,429
Back
Top Bottom