LIRs and TIRs S5 to S7 conversions

AD77

Member
Join Date
Feb 2010
Location
Southern England
Posts
11
Hi,

LIRs and TIRs in S5 to S7 conversions...
I know this has been covered a few times on the forum, but I still can't get my head round it.

Please can someone show and explain to me (using the code below). How to convert this 'Converted' S5 code into S7 using the SFC20?

I'd be eternally greatfull!

Cheers!

OPN "DB021"
L #XANZ
SLW 1
T DBW 22
L DBW 18
SLW 1
L W#16#BA00
+I
// LIR 1;
// *** Error in Line 66 (FB 103): Command not defined. ***
T DBB 2
L DBW 18
SLW 1
L W#16#BA01
+I
// LIR 1;
// *** Error in Line 73 (FB 103): Command not defined. ***
T DBB 3
L #XDBZ
SLW 1
L W#16#BA00
+I
// LIR 1;
// *** Error in Line 80 (FB 103): Command not defined. ***
T DBB 4
L #XDBZ
SLW 1
L W#16#BA01
+I
// LIR 1;
// *** Error in Line 87 (FB 103): Command not defined. ***
T DBB 5
L W#16#0
L DBW 4
<I
JC M001
L DBW 22
+I
L #XDWZ
SLW 1
+I
+ -1
T DBW 10
L DBW 2
L DBW 22
+I
L DBW 20
SLW 1
+I
+ -1
T DBW 8
L DBW 10

//CALL SFC 20 (
// SRCBLK := P#????? BYTE 0 ,
// RET_VAL := conv_ret_val,
// DSTBLK := P#????? BYTE 0
// );
// *** Error in Line 115 (FB 103): CALL SFC20 generated. Please complete parameter list. ***

BEU
M001: L #XANZ
T DBW 22
+I
L #XDWZ
+I
+ -1
T DBW 10
L DBW 2
L #XANZ
+I
L DBW 20
+I
+ -1
T DBW 8
L DBW 10

//CALL SFC 20 (
// SRCBLK := P#????? WORD 0 ,
// RET_VAL := conv_ret_val,
// DSTBLK := P#????? WORD 0
// );
// *** Error in Line 139 (FB 103): CALL SFC20 generated. Please complete parameter list. ***
 
... so what is the CPU ? e.g. 928

.. and can you post the original S5 code.
 
Last edited:
Sorry, it helps if I actually tell you the CPU doesnt it šŸ™ƒ

It's a 921.

The original S5 code is below:

FB 103 -BLOCK-TR C:QC4891ST.S5D LEN=93
Page 1
Segment 1
Name :BLOCK-TR
Decl :XDBZ I/Q/D/B/T/C: D KM/KH/KY/KS/KF/KT/KC/KG: KF
Decl :XDWZ I/Q/D/B/T/C: D KM/KH/KY/KS/KF/KT/KC/KG: KF
Decl :XANZ I/Q/D/B/T/C: D KM/KH/KY/KS/KF/KT/KC/KG: KF

:C -DB021
:LW =XANZ
:SLW 1
:T DW 11
:L DW 9
:SLW 1
:L KH BA00
:+F
:LIR 1
:T DL 1
:L DW 9
:SLW 1
:L KH BA01
:+F
:LIR 1
:T DR 1
:LW =XDBZ
:SLW 1
:L KH BA00
:+F
:LIR 1
:T DL 2
:LW =XDBZ
:SLW 1
:L KH BA01
:+F
:LIR 1
:T DR 2
:L KH 0000
:L DW 2
:<F
:JC =M001
:L DW 11
:+F
:LW =XDWZ
:SLW 1
:+F
:ADD BN -1
:T DW 5
:L DW 1
:L DW 11
:+F
:L DW 10
:SLW 1
:+F
:ADD BN -1
:T DW 4
:L DW 5
: DO DW 11
:TNB 0
:BEU
M001 :LW =XANZ
:T DW 11
:+F
:LW =XDWZ
:+F
:ADD BN -1
:T DW 5
FB 103 -BLOCK-TR C:QC4891ST.S5D LEN=93
Page 2
:L DW 1
:LW =XANZ
:+F
:L DW 10
:+F
:ADD BN -1
:T DW 4
:L DW 5
: DO DW 11
:TNW 0
:BE


DB 21 = DB021 DB FUER BLOCKTRANSFER
 
I can't locate a manual that gives details about what exactly is located in memory area BA00 in the 921 CPU

I'm guessing it is the base address of a block list but without full details I'm stuck.

Does anyone have details of the memory areas for the 921 ?
 
@AD77: If I remember right, you can read out the start adresses of the IO areas and the DB block list if you go online with STEP5 and select ...hmmm...what was the key name....PC INFO or ADR INFO ? (the key is close to the I-stack key).

K
 
Here's an FC that performs the block transfers.

Code:
FUNCTION FC5 : VOID
TITLE =
VERSION : 0.1


VAR_INPUT
  XDBZ : INT ;    //Destination DB number
  XDWZ : INT ;    //Offset into Destination DB
  XANZ : INT ;    //number of words to transfer
END_VAR
VAR_TEMP
  pSrc : ANY ;    
  pDest : ANY ;    
  iSFC20Return : INT ;    
END_VAR
BEGIN
NETWORK
TITLE =

//destination DB and offset specified by passed parameters
//..
      LAR1  P##pDest; 
      L     W#16#1004; 
      T     W [AR1,P#0.0]; 
      L     #XANZ; 
      T     W [AR1,P#2.0]; 
      L     #XDBZ; 
      T     W [AR1,P#4.0]; 
      L     #XDWZ; //number of words to transfer passed parameter
      SLD   4; //convert to pointer format
      L     P#DBX 0.0; 
      +D    ; 
      T     D [AR1,P#6.0]; 

//source DB and offset specified in DB21
//..
      LAR1  P##pSrc; 
      L     W#16#1004; 
      T     W [AR1,P#0.0]; 
      L     #XANZ; 
      T     W [AR1,P#2.0]; 
      L     DB21.DBW   18; //source DB number
      T     W [AR1,P#4.0]; 
      L     DB21.DBW   20; //source offset
      SLD   4; 
      L     P#DBX 0.0; 
      +D    ; 
      T     D [AR1,P#6.0]; 
      CALL sfc20 (
           SRCBLK                   := #pSrc,
           RET_VAL                  := #iSFC20Return,
           DSTBLK                   := #pDest);

END_FUNCTION
The Step 5 code uses the DB number added to the base address of the block list table (which starts at BA00) to give the address in memory of the source and destination DB's. If the destination DB exists at an address greater than 8000H the block transfer is done a byte at a time, else the block transfer is done a word at a time.
The TNB TNW instructions perform the block moves and the two accumulators are set to the end address of the source and destination areas. The number of elements copied is specied by the DO instruction prior to the TNB/TNW instructions.

DB21.DBW10 and DB21.DBW4 were used to store the end addresses but have no use in the Step 7 implementation. You should check if these locations are referenced anywhere else in the code (but my guess is that they are temp variables that are not used elsewhere)
 
Last edited:
Hmm...

Here is a link to the processor manual.

http://support.automation.siemens.c...ction=cssearch&searchinprim=0&nodeid0=4000024

BA00 is listed as the start address of block lists.

I've translated similar code before in a 943 where the start address was E400. I find it helps to look at each instruction in turn and try to understand what it is doing. Below is a segment of code that I commented during a translation a couple of years ago.

Nick

Code:
//      L     W#16#E400                   // Start Address of DB1
//      L     "Source-DB"                 // Source DB Number
//      SLW   1                           // Mul by 2 (2 bytes per address)
//      +I                                // Add to Memory offset address
//      LIR 0;                  // Load Accu1 with Start address
// *** Error in Line     273  (FB  89):  Command not defined. ***
//      +     254                         // Point to Byte 255
//      T     "SourceBlock1"              // Save end address of block
//      +     254                         // Point to end of Next Block
//      T     "SourceBlock2"              // Save End address of block
//      +     4                           // Point to end of Last block
//      T     "SourceBlock3"              // Save end address of last block
//;
//      L     W#16#E400                   // Start Address od DB1
//      L     "Destination-DB"            // Destination DB Number
//      SLW   1                           // Mul by 2 (2 bytes per Address)
//      +I                                // Add to Memory Offset address
//      LIR 0;                  // Load Accu1 with Start Address
// *** Error in Line     286  (FB  89):  Command not defined. ***
//      +     254                         // Point to byte 255
//      T     "DestBlock1"                // Save end address of block 1
//      +     254                         // Point to end of next block
//      T     "DestBlock2"                // Save end address of next block
//      +     4                           // Point to end of last block
//      T     "DestBlock3"                // Save end address of last block
//;
//      L     "SourceBlock1"
//      L     "DestBlock1"
 
Last edited:

Similar Topics

Made a rookie mistake with trusting an implicit conversion and thought I'd post it here for google results. I've never had an implicit...
Replies
5
Views
1,285
Importing a number of SE, ME, PB, View32, WinView apps into View SE 11. Looking for a way to find and consolidate all the images into the one HMI...
Replies
3
Views
1,879
Can someone help me convert a PL7 file to Unity and Magelis file to Vijeo? Thanks in advanced.
Replies
0
Views
1,350
Good morning, I have a S5 project which I would like to convert into ABB 800 M compact control builder project V4.1. Has anyone any information...
Replies
0
Views
1,240
Has any one heard of, or used this site? They specialize in PLC logic conversions to Controllogix and other AB PLC platforms. However, they also...
Replies
3
Views
1,745
Back
Top Bottom