Hi - Merry Christmas Plcs.net members!
I would like my function block to use a Memory byte address which i pass in as a start address to which all offsets inside the FB are based.
Basically if i want to call this block more than once - i can enter different start addresses and the block does the rest for me.
i first experimented with passing in a value as follows;
This works well but i want people to be able to cross reference the start address to guide them to the FB.
so i tried this - it works but i was wondering if i'm over complicating matters.
Is this ok inside a FB? are there any pitfalls with this approach? can it be done simpler?
Thanks in advance for any help on this matter.
I would like my function block to use a Memory byte address which i pass in as a start address to which all offsets inside the FB are based.
Basically if i want to call this block more than once - i can enter different start addresses and the block does the rest for me.
i first experimented with passing in a value as follows;
Code:
L #iStartAddress // FB IN - type INT
SLW 3
LAR1
L 100
T MB [AR1,P#0.0]
L 101
T MB [AR1,P#1.0]
etc...........
so i tried this - it works but i was wondering if i'm over complicating matters.
Code:
L P##StartAddress // Load Pointer into Accu (Ar1 has L14.0)
LAR1 // Load into Ar1
// Ar1 contents DI0.0
// Retrieve - Byte 6 Memory Area | Byte 7,8,9 Byte/Bit Address
L D [AR1,P#6.0]
// Ar1 contents DI0.0
LAR1 // Update Ar1
// Ar1 contents M100.0
L 50
T MB [AR1,P#0.0]
L 51
T MB [AR1,P#1.0]
Thanks in advance for any help on this matter.