Sign in to follow this  
Followers 0
Geek

S5 TO S7 Conversion

10 posts in this topic

Dear All, I need help to convert the S5 program below to S7. Why is the reserved data block DB0 being called and what is OB31? I check OB31 and it is empty. Your help will be very much appreciated. Thank You M001: DO FW 219 C DB 0 DO FW 221 L DW 0 DO FW 220 C DB 0 DO FW 224 T DW 0 L FW 224 I 1 T FW 224 JU OB 31 L FY 222 I 1 T FY 222 L FY 223 <=F JC =M001

Share this post


Link to post
Share on other sites
DO FW219 C DB0 This is treated as one statement. In simple terms it opens the Data Block pointed at by FW219. In otherwords indirect addressing. FW219 will contain a value between 1 and 255. The DO FW and DO DW statement work with a number of instructions, for complete details you need to read the programming reference guide for the CPU you are using. I have to honest, the manuals do explain the instruction, however the explanation is always the one that people new to S5 have trouble with. OB31 can often be a scan time watchdog retrigger, so that the watchdog doesnt trip when moving lots of data again check the CPU manual Hope this helps

Share this post


Link to post
Share on other sites
Thanks Mike, You have really been of great help.

Share this post


Link to post
Share on other sites
Just spotted a nasty little gotcha in the example code you give, FW... refers to 2 bytes, eg FW219 occupies FY219 and FY220. So there could be some problems with this code, does it work now? Mike

Share this post


Link to post
Share on other sites
Thanks Mike, I'm still converting and haven't yet run the code. The entire program is quite big and I'm about 90% through. At the moment I'm struggling with a portion that includes an LIR instruction and I read from the forumn I need to understand the code to be able to convert to S7. Below is the code and I hope I will be able to make it. Thanks once again. FUNCTION BLOCK FB 221: NAME: TRANSFER DECL: DBQZ DKY LW =DBQZ T FW 210 L FY 211 SLW 1 L KH E400 +F LIR 0 L KB 0 ><F BEC L KB 49 G DB 211 T FW 212 BE This function block is called passing "KY 161, 211" to DBQZ from OB21 as below: JU FB 221 NAME: TRANSFER DBQZ: KY 161,211

Share this post


Link to post
Share on other sites
I have been able to figure out what the code is doing but have some questions. I realized the address of the data being loaded by the LIR instruction is E5A6 which is the address of the data block DB211. DB211 in the program contains 50 data words: 0 to 49. My question is which of the elements in the data block is the LIR instruction loading. How is the offset specified. For example to load data word 1 it will be DW1 but how is this acheived with the LIR instruction. The manual says Data words 256 to 2042 can only be accessed using the "LIR", "TIR" and "TNB" operations. So, for example, how will data word 257 be loaded using the LIR instruction? Thank You.

Share this post


Link to post
Share on other sites
My GUESS is that the code is transfering one DB to another If you use LIR to access a dataword beyond DW255 in S5 steps to find address are 1. Find DB start address in block address list 2. Add offset for header 3. Add 257 for DW257 LIR Next problem you will hit is S7 Datablocks are 8 bits wide, S5 are 16 bits wide. My advice: Dont try and convert the code, find the functionality of the code and rewrite it using S7, results will be better and you can use S7 instructions to optimise the code.

Share this post


Link to post
Share on other sites
Hello Mike, Thanks once again for your help. Your advice is well noted. I have some questions: Block Address List 1. From the block address list, the starting address for the data blocks is E400 and each data block has two addresses. That is DB0, for example, has E400 and E401. This means the starting address for DB211 is E5A6. So does it mean that to access DW257 in DB211 I have to do this, Address = E5A6 + (offset of header) + 257? 2. From the code I posted earlier, the LIR 0 instruction is loading from address E5A6. What does this mean as this address is the starting address of DB211. Is it loading DW0? Thank you. Edited by Geek

Share this post


Link to post
Share on other sites
The reason two addresses are specified, eg E400 and E401 is because the block address list on many CPU's is only 8 bits wide, so you need two 8 bit addresses to store one 16 bit address Although DW's are 16 bits many S5 CPUs have 8 bit memory, so the first question is which CPU are you using? If it's 8 bit then you need start address + (offset * 2) If it's 16 bit then just Start address + offset

Share this post


Link to post
Share on other sites
Thanks for the reply, My CPU is S5 115U CPU 941. I still dont understand what the LIR 0 instruction is loading. The address in ACCUM 1 is E5A6. What does this mean as this address is the starting address of DB211. Is it loading DW0? Many thanks for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0