Posted 28 Dec 2015 Hi, I am relative new to plc, and was wondering in anyone could explain the data block adressing below? If you use #IndexDB = 50 and #IndexByte = 226. L #IndexDB //Load first DB number in data area T #DB_Source L 200 //The start byte number in Workspace DB T #Word_Dest L 20 T #DB_Dest L 10 //10 DB is to be copied MrkA: T #Loop_Counter L #IndexByte T #Source_Word L #Source_Word SLD 3 T #Source_Word L #Word_Dest T #Dest_Word L #Dest_Word SLD 3 T #Dest_Word L 2 next: T #Loop_Counter1 OPN DB[#DB_Source] L DBW[#Source_Word] OPN DB[#DB_Dest] T DBW[#Dest_Word] L #Source_Word L P#2.0 +D T #Source_Word L #Dest_Word L P#2.0 +D T #Dest_Word L #Loop_Counter1 LOOP next L #DB_Source //Increment Active DB number by one L 1 +I T #DB_Source L #Word_Dest //Increment Active Word number by Length L 2 //(2 x Length because off Byte number) +I L 2 +I T #Word_Dest L #Loop_Counter LOOP MrkA //Loop 10 times for 10 DB´s Thank you. Share this post Link to post Share on other sites
Posted 8 Jan 2016 L #Source_Word SLD 3 T #Source_Word This is moving the address of the data word into a pointer format, a pointer would be a double word and includes the byte address and the bit address 0-7, the bit address takes the lowest 3 bits, therefore the programmer is shifting the bits, so in this case the value 226 is in pointer format 226.0. OPN DB[#DB_Source] is opening the DB identified by #DB_Source, which in this case is 50, therefore its opening DB50. L DBW[#Source_Word] is load the dataword identified by #Source_Word, in this case 226.0, therefore L DBW226. (If he had not shifted by 3 this would not have worked) OPN DB[#DB_Dest] T DBW[#Dest_Word] is the same thing, he's opening the destination datablock and tranferring the value he's taken from DB50.DBW226 into this DW. L #Source_Word L P#2.0 +D T #Source_Word He's transferring more words, so he's incrementing to the next word, as its in pointer format he's adding pointer P#2.0, which means 226.0 + 2.0 = 228.0, therefore DBW228 will be the next one. He's added 2, as he is transferring Data Words, which is two bytes long, the next data word is two bytes away. He does the same with the destination then does L #Loop_Counter1 LOOP next This automatically decrements the value held in Loop_Counter1 which he initiated to a value of 2 (he's doing 2 loops) and jumps back to the label next Once Loop_Counter1 reaches zero it continues down where he increments the source DB to DB51 and offsets the destination word, so iot will be the same DB he writing to but further down. L #Word_Dest //Increment Active Word number by Length L 2 //(2 x Length because off Byte number) +I L 2 +I T #Word_Dest for some reason he adds 2 twice rather than 4 :) Then loops back and moves another two words, same data words in the next DB {51) to the next two words in the destination DB Share this post Link to post Share on other sites