8/20/2011 2:35 PM | |
Joined: 10/7/2005 Last visit: 7/30/2024 Posts: 3013 Rating: (1054)
|
Hello kavelj22 I presume the Parameter "IN_PIW_Address" is of type INT or WORD and that for example "IW 4" or "PIW 4" is used as the actual value for this Parameter of the FC call, correct? If so, here's the explanation: The command "L P##IN_PIW_Address" loads accu1 with a Pointer value of the assigned address. If the actual value for Parameter "IN_PIW_Address" is for example "IW 4" for that FCcall, you'll end up with 81000020hex in accu 1 (Note that you would get exactly the same value in accu1 if you do a "L P#I 4.0"). 81hex nominates "input address" as the memory area (which is of no interest for your code) and 20hex is the BYTE.BIT address (20hex = 32dec = 00100000 binary). If you remove the Pointers BIT part from the 20hex (e.g. via SRD 3 as done in your program), you'll end up with a value of 4. Since avalue of 4 asa Pointer value "points" to bit 4 (and you want to point to bit 2 which corresponds tothe IW 4 related bit in the DB), the additional division by 2 isdone. Doing SRD 4 instead of the L 2, /I and SRD 3 will not work in this case by the way. The reason that"/I"by 2 is done first on the 81000020hex value is that it elegantly removes the 81hex memory area ("/I" only takes accu1 low into account and as such discards the 81hex memory area from the result as also already mentioned by hdhosseini). I hope this helps |
Cheers |
|
This contribution was helpful to1 thankful Users |
8/23/2011 3:08 PM | |
Posts: 30 Rating: (2) |
OK! Let's forget about previous post :)! The value that is written in pointer in the program has #80 and not #81 at least what i get when i do it with PLC SIM! So could be used also with SRD 4 and i dont know why they use the other way. Maybe this part of the program is used in many different programs and is made like this so is always working doesnt matter the memory area i dont know! I also found this PDF where is a very good explanation of indirect addresing and most important explanation of address register and all the bits including memory area! Thanx!
AttachmentVolume 2 describes Register Indirect Addressing.pdf (110 Downloads) |
This contribution was helpful to1 thankful Users |
Follow us on