S5 to S7 "DO" translation question..

uptown47

Lifetime Supporting Member
Join Date
Feb 2008
Location
Over there, next to those boxes
Posts
1,146
Hi all,

When the 'automatic' S5 to S7 translates comes across a DO instruction it translates it but I have a question about the translation.

Could you tell me if I'm right here:

Code:
S5 CODE IS:
DO FW 240
C DB 0

I understand what this code is doing. It's taking the value of FW 240 and calling the corresponding Datablock (i.e. if FW 240 = 40 then its calling DB 40).

This is the S7 Conversion:
Code:
(#conv_akku1 = TEMP Dword
#conv_index = TEMP Word)
 
T #conv_akku1
L MB 241
T #conv_index
TAK
L #conv_akku1
OPN DB[#conv_index]

This is the same code again with my comments next to it for what I think is going on with the Accumulators etc...

Code:
T #conv_akku1       // Transfer the contents of Accumulator
                    // 1 into #conv_akku1 ?? WHY ??
 
L MB 241            // Load value of MB241 into Accumulator 1
                    // - old Accu 1 value moved to Accu 2
 
T #conv_index       // Transfer Accu 1 (value of MB241) into
                    // #conv_index
 
TAK                 // Swap contents of Accumulator 1 and 2 so
                    // now Accumulator 1 = whatever was in
                    // Accu 2 (Instruction pointer perhaps?)
                    // as all this code takes place in a FB.
                    // Accu 2 is now equal to value of MB241
 
L #conv_akku1       // Accu 1 now equal to #conv_akku1
                    // Accu 2 now got its instruction pointer?
                    // back 
 
OPN DB[#conv_index] // Open DB of value MB241

Am I right with this or am I off on a tangent here?

It seems like an awfully complicated way of doing a "DO" instruction? Is there no simpler way ??

Many thanks for any help / reassurance you can give me.

Cheers

uptown (John) ;-))
 
Remember the magic word, its automatic translator. It has to take into account that maybe there was data that will be used after opn in accus.

Im sure you can yourself find many ways to do it simpler ;)
 
Last edited:
Hi TU,

I did wonder why I couldn't just have:
Code:
OPN DB[MW 240]

?

What about my interpretation of the accumulators?? Am I on the right track or way off??

Thanks for your (very) prompt help

;-)
 
In Step5 you could only open data blocks up to DB255. The DB number is in MB241 and MB240 may contain some data which would not be used by the DO instruction, so to replicate the functionality in Step7, MB241 has to pass through the accumulator to get written to the temp variable for the indirect opening of the DB - this would have corrupted the accumulator so the accumulator is first copied to a temp for storage, MB241 can then be loaded to Accu 1 and stored in the temp used for the indirect opening of the DB. Accu1 and Accu2 are restored to their previous state and then the DB is opened.

If you know that MW240 contains the DB number then your coding is correct.
 
Accu1 and Accu2 are restored to their previous state and then the DB is opened.

Is it just me or isn't there a TAK missing right before the Load to completely restore ACCU1 and ACCU2 to what they were before the datablock is opened?
According to me, ACCU1 and ACCU2 will now have the same value, that of #conv_akku1.

If I'm mistaken......well erm......whoops?
 
No you are not mistaken - in my Berger there is a conv_accum2 used in the example DO conversion.

Here's confirmation of Uptown's code executing:

bbb.jpg
 
Last edited:
In Step5 you could only open data blocks up to DB255. The DB number is in MB241 and MB240 may contain some data which would not be used by the DO instruction, so to replicate the functionality in Step7, MB241 has to pass through the accumulator to get written to the temp variable for the indirect opening of the DB - this would have corrupted the accumulator so the accumulator is first copied to a temp for storage, MB241 can then be loaded to Accu 1 and stored in the temp used for the indirect opening of the DB. Accu1 and Accu2 are restored to their previous state and then the DB is opened.

If you know that MW240 contains the DB number then your coding is correct.

Thanks for the explanation re. Datablocks up to 255 et al.

Are my comments correct for how I interpreted the code?

And, reference Jeebs point, is this code incorrect then? This is the code that the 'auto' translator came up with?

Thanks again for all the help

;-)
 

Similar Topics

I'm pretty well a 100% GE/Emerson Rx3i programmer, and zero practical experience with Siemens programming. However I have just been given a PDF...
Replies
2
Views
1,590
Hi all. That will be a stupid question for a lot of you guys. I'm talking with ProSoft support and he sent me an example late yesterday: XIC...
Replies
9
Views
357
So I am sure many of you have run into this problem over the years. I know I have.... The customer has a machine that was built outside the...
Replies
14
Views
2,553
Hi, I'm trying to find the best way to translate a full TIA Project from German to English. I was looking into the TIA Translation tool and it...
Replies
2
Views
961
This may or may not be the right fit for this forum, but I'm hoping someone can recognize my issue and help me sort this out. I'm working to...
Replies
1
Views
2,165
Back
Top Bottom