AG-SEND & AG-RECEIVE in an FB

orense

Member
Join Date
Apr 2006
Location
Norway
Posts
196
Hello!

I have a problem using FC 5 and FC 6 inside an FB.
I try to use a local IN variable for the send input to FC5, but SIMATIC does not allow me. I try to use datatype ANY, which is the same as used inside FC5 for this variable.

I will write the input to this FB input in this format : P#DB102.DBX0.0 BYTE 20,
this is the same as if you write it directly to FC5.

What kind of variable type can I use to make it work?
When I use ANY, I does not allow it on FC 5, the letters are red, and I can,t save it.

Thanks alot for answers :)


Andreas
 
It will allow a TEMP variable that has been set up as an ANY, so your bast bet would be to have parameters that you can build up in the FB.

i.e. IN DB_Address INT
IN DW_Address INT
IN Length INT


have temp TEMP FC_SEND ANY

Look at the address in the temp range for FC_SEND, lets say its the first for example, so starts at L 0.0.

L W#16#1002 //Set for Byte
T LW 0
L #Length
T LW 2
L #DB_Address
T LW 4
L #DW_Address
SLD 3
T LD 6
L W#16#8400 //Memory Area DB
L LW 6
AW
T LW 6

Then you can use the FC_SEND temp parameter in your call. Remember though by directly addressing the local temp flags, if you insert a new temp before FC_SEND then all the local flags will move down.

There is a way around this by using pointers like LAR1 ##FC_SEND, can't remember the whole thing though, perhaps omeone else can expand on that, I've used it before to block move a range of datawords into local flags.
 
AG-SEND & AG-RECIVE in an FB

Hello...

Thank you very much for help PeterW...
I tried what you suggested, but it didn,t work properly. I got some error messages on the AG-SEND block.

8F24H Area error reading a parameter.

I didn,t really understand this code either:

L W#16#1002 //Set for Byte
T LW 0
L #LEN
T LW 2
L #DB_Address
T LW 4
L #DW_Address
SLD 3
T LD 6
L W#16#8400 //Memory Area DB
L LW 6
AW
T LW 6


Can you explain a little bit??

I made the three variables( DB_Address, DW_Address and Length) as inputs, then I used the code and sat FC_SEND as temp.

About the code I imagine that if for instance the DB_Address is sat to 70, the DW_address to 0 and the Length sat to 4, then the code will put this into FC_SEND :

P#DB100.DBX0.0BYTE4


is this correct??

Thank you and regards Andreas
 
No that would be p#DB70.DBX0.0.BYTE4 (Which is two words).

The integer value should be the number of the block as its in decimal format.

The code is manually populating the ANY parameters.

For a good description, in the editing screen, select help on the pull down menu, then first option contents. The manual apppears, so search down the contents window, close to the bottom will be appendix, in there is a section data types and parameters, inside there is three more selections, pick parameter types and it describes (much better than I can) the make up of both the pointer and ANY parameters. You should understand what the logic is doing then.
 
Error message on FC5

I am trying to write to FC 5 using an Any temp pointer inside an FB.


I call the FB like this:


CALL "RR_SEND" , DB50
INIT_COM :=M2.0
ID :=2
LADDR :=W#16#100
DB_Address:=70
DW_Address:=0.000000e+000
Length :=4




Inside this FB RR_SEND i use the temp any pointer

This is the code for the pointer in STL:

LAR1 P##FC_SEND
L B#16#10
T LB [AR1,P#0.0]
L B#16#2
T LB [AR1,P#1.0]
L #Length
T LB [AR1,P#2.0]
L #DB_Address
T LW [AR1,P#4.0]
L #DW_Address
T LD [AR1,P#6.0]

FC_SEND is the temp parameter which I will use on FC5.

#Length , #DB_Address, #DW_Address are the IN parameters to the FB, they will represent :

P#DB70.DBX 0.0 BYTE 4

Then I call fc5:


A #INIT_COM
= L 10.0
BLD 103
CALL "AG_SEND"
ACT :=L10.0
ID :=#ID
LADDR :=#LADDR
SEND :=#FC_SEND <------ The Temp
LEN :=#Length
DONE :=#SND_DONE
ERROR :=#SND_ERR
STATUS:=#SND_STAT
NOP 0


However, on the ERROR parameter I get a "1", and the STATUS says
8F24, which means "Area error reading a parameter"

Any ideas why? Seems like something is wrong with my code, but I can,t find out why :(

Thanks a million for answers


Andreas :)
 
Its your DW_Address.

Its best if you enter this as an INT.

Then

L DW_Address
SLD 3 // This last 3 bits are for bit address (0-7).
// make it a double word shift, as the address is a double word and if big enough will transfer some bits from the lower to higher word.

T LD [AR1,P#6.0]

// Then you need to tell it its a dataword address in byte 6

l 16#B#84 // Check this I believe off hand that 84Hex = DB
T LB [AR1, p#6.0]
 
Maybe this example is more clear to understand? It's works.
LAR1 P##pSource
L B#16#10 // Syntax ID
T LB [AR1,P#0.0]

L B#16#2 // Data type: byte
T LB [AR1,P#1.0]


L 26 // Repetition factor
T LW [AR1,P#2.0]


L 6 // DB6 as source
T LW [AR1,P#4.0]


L P#0.0 // From start of DB6
T LD [AR1,P#6.0]


L B#16#84 // Memory area: DB
T LB [AR1,P#6.0]


Of course, you must to shift your DW_address left 3, as PeterW said, instead of p#0.0.
 
Gambrinus said:
L P#0.0 // From start of DB6
T LD [AR1,P#6.0]


L B#16#84 // Memory area: DB
T LB [AR1,P#6.0]


Of course, you must to shift your DW_address left 3, as PeterW said, instead of p#0.0.

The problem with that is I believe he wants to vary it, so next call could be starting from DBB20 or something (I could be wrong).

This could be done without indirect addressing of course, by loading straight into the local addresses indicated by the first byte of the #FC_SEND ANY address. I wouldn't really recommend though in case someone adds a new TEMP later before the #FC_SEND parameter.
 
I got it working now...

coded like this :

LAR1 P##FC_SEND
L B#16#10
T LB [AR1,P#0.0]
L B#16#2
T LB [AR1,P#1.0]
L #Length
T LB [AR1,P#2.0]
L #DB_Address
T LW [AR1,P#4.0]
L #DW_Address
SLD 3
T LD [AR1,P#6.0]
L B#16#84 // Memory area: DB
T LB [AR1,P#6.0]


And then I call fc5 in next network:


A #INIT_COM
= L 10.0
BLD 103
CALL "AG_SEND"
ACT :=L10.0
ID :=#ID
LADDR :=#LADDR
SEND :=#FC_SEND
LEN :=#Length
DONE :=#SND_DONE
ERROR :=#SND_ERR
STATUS:=#SND_STAT
NOP 0



And it is sending....

The purpose is that since this is inside an FB, then I can just add an extra call if I want to send more DB,s between the two PLC,s....I only have to change the ID for the connection, the length, DB_address and DW address...

Thank you very much for your help guys.... I really appreciate it :)



Andreas :)
 

Similar Topics

Hello All, Currently I am migrating S7 300 to S7 1500 & I am unable to use DP send & receive data from Master PLC. Which instruction is...
Replies
4
Views
1,662
All, I am up a creek and not only did I lost my paddle, but the creek is on fire. What I am attempting to do is to connect Wonderware System...
Replies
2
Views
2,346
Hello every one ... i want to know if the communication functions " AG SEND " and "AG RECEIVE" works with TCP only ? or with other communication...
Replies
5
Views
2,635
Hey guys, I hae an RSLinx that will not connect. So what I have is 5 machines, communicating in series from a DH485 to a coupler to ethernet to a...
Replies
2
Views
1,392
Send/Receive Data(ethernet comm..) between CPU 315-2 DP & S7-1200 OVER CP 343-1 Lean I have 2 programs. In 1.(first program ) my hardware...
Replies
0
Views
2,697
Back
Top Bottom