s5-s7 conversion 'ASM' command and Special FB's

emokar

Member
Join Date
Sep 2006
Location
turkiye
Posts
77
Hello,

I am working on a project of converting an S5 plc to S7-300.
I used the converter tool provided with Simatic Manager and it converted most of the program quite succesfully. I have some problems , and i thougt i could get some help here.

Problem 1 : 'ASM' command in S5 STL.

Here is a list of special function blocks in which the 'asm' command is used.

FB238 COMPR
FB239 DELETE
FB240 COD:B4
FB241 COD:16
FB242 MUL:16
FB243 DIV:16
FB244 SEND
FB245 RECEIVE
FB246 FETCH
FB247 CONTROL
FB248 RESET
FB249 SYNCHRON
FB250 RLG:AE
FB251 RLG:AA

And here is an example of how it is used. The usage is the same in every block.
FB 248 C:CTCSONST.S5D LEN=22
Page 1
Segment 1
Name :RESET
Decl :SSNR I/Q/D/B/T/C: D KM/KH/KY/KS/KF/KT/KC/KG: KY
Decl :A-NR I/Q/D/B/T/C: D KM/KH/KY/KS/KF/KT/KC/KG: KY
Decl :pAFE I/Q/D/B/T/C: Q BI/BY/W/D: BY

:ASM KH 0000
:BE

I could not find anywhere, what this command does. A stanger thing is that none of those special FB's are called in the rest of the program. They are defined, and in all of them only two commands are used just the same way in the example i gave above.
I could not understand the reason of defining the blocks. Why did the programmer defined them if they aren't called in any line of the code?
I mean, wouldn't the system work without those unused blocks? If they aren't called anywhere, does that mean that it is ok if i avoid them while programming the s7-300? If so , i don't need to deal with 'asm' code , too.

Problem 2: Special OB's. OB21,OB22 and OB31.

OB21 and OB22 are special OB's for hot and warm restart. I have converted them into OB101 and OB100 in s7. is this correct?
OB31 is used for set cycle monitoring time.

the only code written in ob 31 is :
OB 31 C:CTCSONST.S5D LEN=8
Page 1
Segment 1
:NOP 1
:BE

I could not understand its use and so i could not decide if i should use anything to stand for OB31 in the s7 program.


Problem 3: FB167 and FB168, counter module IP240.

There is an encoder in the system and it is read with ip240 counter module. In the program, FB168 and FB167 are called several times. there are some variables like KANR,BGAD etc. I found explanations for all those parameters. But i could not find out from which address the counted value is going to taken. Here is an example of FB168's use:
FB 140 C:CTCSONST.S5D LEN=29
Page 1
Segment 1
Name :X-ACHSE

:C DB 140
:JU FB 168
Name :STEU.POS
DBNR : KF +140
FKT : KY 1,0
PAFE : FY 200
:
:L FY 200
:L KH 0000
:><F
:S F 145.7
:
:L DR 28
:T FY 146
:L DR 29
:T FY 143

PAFE parameter is addressed at FY200 and it represents the error byte. So, in the block above, an error check is processed. But where is the counted value?
Here is an example of FB167's use:
Segment 4
: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
:
:L FY 200
:L KF +0
:><F
:S F 145.7
:
:C DB 140
:L DW 10
:C DB 142
:T DW 0

Same problem, i could not understand where is the value written or read from the counter card? How should i convert the parts related with counter card to s7?

I am desperately looking forward to get some help. Please help me if you can.
Thank you for your attention,
Regards,
 
I think the counter value gets written into the DB number passed as DBNR (DB140 in one of your examples)
 
I'd searched this forum about the 'asm' command. Yes,there are some topics about it, but none of them made me understand the issue.

The parts about the Counter card are seem to be relatively easier but i have no clue about the 'asm' command. Anybody to help?
 
S5 ASM command

Some standard function blocks include the instruction ASM which is 'switch to ASSEMBLER operation'.

Although the programming unit may interpret and display subsequent data as STEP5 instructions, they should be disregarded since the raw data is assembler data and not MC5.

Standard function blocks are identified by a Library number starting with 'P71200..' and are best regarded as 'black boxes'.

In S5-S7 conversions you should duplicate the functionality of non-converting standard functions rather than try to 're-create' them in STEP7.
 
hi krk,
so , in my situation , since none of the special function blocks is called anywhere in the program , i dont need to do anything about them while converting to s7. is it correct?
 
emokar said:
hi krk,
so , in my situation , since none of the special function blocks is called anywhere in the program , i dont need to do anything about them while converting to s7. is it correct?

Yup...that's right
 
The asm instruction is followed by ju=m001 then be
if you use a hex editor (if you can find the block) & change the be to nop1 then the code becomes readable as mc5 however it probably does not make much sense.
a lot of blocks you mentioned are for communications 525,535 & others for special function cards.
The others are maths routines for 115.
If none of these are called then it should "almost" convert.
The OB's if not programmed usually stop the plc if errors unless programmed with a be, the idea is that on an error the relevant OB is called, you can then process say errors & then you should stop the plc using STP command in the OB, however on some systems it may be you do not wish to stop the processor but beware, an error could cause a major catastrophe & be very dangerous.
 
I have investigated another system in the factory in which an S5 115u is used. This is relatively simpler system. I saw that same special FB's are seen in the program.
I learned that those FB's are not kept in PLC's memory. They are stored in an EEPROM in the CPU card! They say that Siemens did this because CPU memory was small nd it was a smart and practical way to use that small memory more efficient. Those blocks are kept in EEPROM and programmer can not write anything to them. You don't need to add them in your program but you can use them whenever you need by simply calling them in your program.
So,since they are not called in the program i am converting ,I have decided to disregard special FB's which are not called.
I am not going to do anything about them.


I will use OB100 and OB101 in S7 for OB21 and OB22 in S5. OB1 is easy to convert and i don't think OB31 will cause any trouble. I will make the first try without OB31 and i will work over it in case of a problem.

Now , my only problem is the use of counter card. There are weird codes in STL language for using the counter card in S5.
I could not find out how to adapt them in S7 but i am working on it.

Thank you all once more for your helpful replies.
And again , please let me know if something i mentioned about what i will do is wrong .

Regards,
Emre,
 
The chances are that the S7 version of the counter card will have it's own different way of controlling the data, in general the code used in the 115 version is probably only how to read & set the data/functions, once you know how they use the data & reset functions it should not be too difficult to reproduce this in S7.
 
Hello emokar;

if i could understand the way they used the card [in S5], i can write the s7 program

Are you planning to use the same counter cards on the S7 backplane? If not, I am not sure your assumption is correct. High-speed counter cards and integrated counters (in S7-31xC CPUs) all come with dedicated FBs/SFBs that are pre-built to use the S7 interrupt codes; they will not work the same way that their S5 counterparts did.
I followed your other thread, but I thought it was only as an exercice, not to implement a real counter card.

Daniel Chartier
 
I think i could not be clear enough. In the program of the S5 115U , some operations are made to the value which is taken from the ip240 counter card. I must first understand why those operations are done. After completely understanding what is going on , i will write s7 codes which will do the same job using fm350-1. that value of encoder is used in many places in the program. So i must get exactly the same value not to change the whole program.
 

Similar Topics

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
214
Currently I’m using ESA model VT155W0000 HMI and it’s communicate with Fanuc PLC. Can any one suggest can I convert ESA model to EXOR HMI eSMART07M
Replies
0
Views
97
hi... i have an issue in s7 300 plc, while we run the machine(in idle there is no fault) , plc cpu goes in SF mode, after restart the power cycle...
Replies
2
Views
128
I have a Type C to RS485 adapter connect to my Siemens RWF55. I use modscan to scan it to get a value from the Siemens controller. In the...
Replies
4
Views
106
Hi all, I'm in the process of upgrading a PanelView1200 HMI program to be developed in FactroyTalk View Studio. The filetype for PanelView 1200...
Replies
7
Views
286
Back
Top Bottom