7/13/2010 10:31 AM | |
Joined: 10/7/2005 Last visit: 11/4/2024 Posts: 3025 Rating: (1055)
|
Hello herumang "DO =DB" opens the DB hat is attached to the formal operand "DB" of the FB, which isDB180 in your code code example. "LW" is command that loads the bitpattern of the formal operandinto accu1 Low (the lowest 16 bit of accu1). "LW =DB" is in your case used to get the the DB number "180". Sincethe bitpattern value for the "DB" part of "DB 180" is of no use, it is masked out with the next two STL lines ("L KB 255" and"AW"). The result is that accu1 has an Integer value of 180 in it. Just in case you don't have it yet, all commands and more are explained in the CPU 928 programming manual which you can download from HERE. P.S: Very nice explanation by jklmandI agree with his advise on what the logic does and only haveone little addition to it: DW 1 in has a value of 199hex (=409 decimal) in your example DB180. As 409 is bigger than 49 (the minimum allowed value that your FB checks for) this means that DW390->409 arecurrently copied to DW 10->29. I suggest you check if DW 1is changed elsewhere in the code as its value determines what source address range is copied into thefixed (DW 10->29) destination address range and ideally you test run the S5 logic in a 928 CPU to verify its functionality fully. I hope this helps and good luck with your conversion |
Cheers |
|
7/15/2010 12:31 PM | |
Joined: 10/7/2005 Last visit: 11/4/2024 Posts: 3025 Rating: (1055)
|
Hello again herumang nice effort and good on you for giving it your best shot, but I would have a slightly different take on on what yourcode snippet does. [code]L RS 34 // Load Start address of DB address list into accu1 ADD KF +255 // Add 255 to accu1 (= point to memory cell that contains the start address of DB255) LIR 1 // Load Register 1 (=accu1) with the contents of the memory cell whose address is in accu1. Result: accu1 contains thestart address of DB255 (to be precise, the absolute memory address of DB255's DW0) L DW 11 // Loada value tocreate a DW offset, we assume for this example DW11 in DBxyz has a value of 10 +F//accu1now containsthe absolute memory address of DB255's DW 10 T FW 252 // store thisaddress in FW252for later use LIR 1 // load the contents of DB255's DW 10 T FW 254 // store this value in FW254 A F 250.0 // change/manipulate some bits in FW254 = F 255.0 // . A F 250.1 // . = F 255.1 // . A D 7.9 // . = F 255.3 // . L FW 254 // load changed FW254 L FW 252 // load FW252 into accu1 (=the absolute memory address of DB255's DW 10) TIR 3 //Transfer the contents of register 3 (=accu2 Low=value of changed FW254) to the memory cell whose address is in accu1 (which is DB255's DW 10 in this example). [/code] To surmise, your S5 logic does the following: A Dataword from DB255 is loaded, some bits in it are changed and the changed value is written back into the same Dataword. Which Dataword is loaded depends on the value of DW 11. Note that your code snippet does not reveal in which DB this DW 11 and that the employed absolute address access does NOT open DB255 via the DB Registers. As you can see from this example, dealing with absolute address access in S5 can be pretty hair-raising stuff. While this addressing mechanism doesn't exist anymore in S7 (and there is really no need for it in S7 anymore either) I still strongly recommend that you get hold of a 928B CPU and test some of the blocks you are dealing (it greatly helps in verifying that the manully decoded functionality is understood correctly before you create your S7 equivalent for it). Have another look too at Chapter 8 and 9 of the previously supplied manual,they do contain a few examples concerning this and are worthwhile having as a printout while dealing with this kind of S5logic (I fear you will discover more of this kind of hardcore S5 logic). I hope this helps |
Last edited by: fritz at: 7/16/2010 4:13 AMAdded summary Cheers |
|
7/16/2010 10:30 AM | |
Joined: 10/7/2005 Last visit: 11/4/2024 Posts: 3025 Rating: (1055)
|
I wouldn't call it a trick dear herumang, but rather one way out of a few thatallowedyou to get access to DB Words past the magic 255 boundary that existed in S5 (DB's could always be longer than 256 Words, but 255 was the highest value you could access directly in your logic as only one Byte was available to store this address value).
There better be a DB255 as it is what your logic is aiming for. Then again, perhaps the FBis not called orDB255 is created via logic on startup and does not exist in your program backup or I got my logic explanation wrong ... |
Cheers |
|
7/20/2010 9:52 AM | |
Posts: 6 Rating: (0) |
Dear fritz, Thanks for your explanation. regards, herumang |
Follow us on