10/2/2011 8:56 AM | |
Joined: 6/5/2009 Last visit: 9/3/2025 Posts: 156 Rating:
|
Dear Experts, I have a situation that requires me to have an ANY pointer as the input. Using which the byte address is supposed to be retrieved, so then it could be offsetted to retreive the a real number to indicate the process variable of an input. I managed to pull the bit address (0 ... 7) from the ANY pointer by masking tchnique, but I am able to retreive only upto 32 byte addresses correctly. If you need the program sample I can attach it for you. Please suggest anything that could be done to standardise that solution. I can complete the rest of the program with the suggestion given. Thanks in advance, Grim Reaper.
AttachmentLib_any.zip (231 Downloads) |
10/3/2011 11:01 AM | |
Joined: 3/24/2009 Last visit: 7/9/2024 Posts: 535 Rating:
|
Dear Grim Reaper, if you can use SCL, you can use the following code: [code] FUNCTION_BLOCK FB200 VAR_INPUT MyAny: ANY; // Symbolic name of the ANY pointer AtMyAny AT MyAny: STRUCT // define the same area with another type ID : WORD; // ID for ANY NBR :INT; // data-count DBN : INT; // DB-number PTR : DWORD; // Pointer to the adress END_STRUCT; END_VAR VAR ByteAdress: DINT; BitAdress: DWORD; END_VAR ByteAdress := (DWORD_TO_DINT(#AtMyAny.PTR AND DW#16#00FF_FFF8) / DWORD_TO_DINT(DW#16#0000_0008)); BitAdress := (AtMyAny.PTR AND DW#16#0000_0007); END_FUNCTION_BLOCK [/code] In the attachment you can find the format of the ANY-pointer. Hope this helps! Best regards, yy1 AttachmentANY-Format.pdf (337 Downloads) |
10/5/2011 4:20 AM | |
Joined: 6/5/2009 Last visit: 9/3/2025 Posts: 156 Rating:
|
Dearyy1, The SCL code that you've placed is fantastic. I just about need to try that one. But I was actually looking for a solution to the problem that I started. I am unable to gain any leverage over the issue I created. Whereas a collegue of mine, who looked at the same ANY pointer as I looked in to it gave a solution. I wanted the answer old school. ======================================== The code that my collegue developed was something like this L W [AR1,P#6.0] L W#16#7 AW SLW 13 T LW 10 L W [AR1,P#8.0] L W#16#FFF8 AW SRW 3 T LW 12 L LW 10 L LW 12 OW T LW 16 =========================================== Please let me know if there is any other method of manipulating the code that I've written. Regards, Grim Reaper |
10/5/2011 7:26 AM | |
Joined: 3/24/2009 Last visit: 7/9/2024 Posts: 535 Rating:
|
Dear Grim Reaper, there isn't just one way of doing this The code of your collegue seems to be correct, so I think that you can use it. Best regards, yy1 |
10/5/2011 8:24 PM | |
Joined: 6/5/2009 Last visit: 9/3/2025 Posts: 156 Rating:
|
Dear yy1, I finally found the answer to the riddle. I have it posted as an attachment. The previous and the present vary only very little for a vast difference. Please check that. And as I mentioned earlier, the bit patterns also helped me with the little modification. Regards, Grim Reaper
AttachmentAny_test_modified.zip (263 Downloads) |
Follow us on