Step 5 Communication of CP341 and COM525

masoudium

Level-1
Beiträge
5
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hi,
In a project, we need to transfer some DBs from an S5 (135U) to an S7(315-2DP) and vice versa.
This is our Hardware config:
-On S5 we have a CP525 with to interface
-On S7 we have a CP341-RS422
-We have a protocol converter to convert RS232 signals from CP525 to RS422 Signals on CP341

And this is what we have done for the software:
-On S5 We programmed FB125(SYNCH) in OB20, OB21, OB22
* FB126(SEND_ALL) and FB127(RECEIVE_ALL) are called in OB1
* In CP525 we’ve adjusted the address jumpers IF0 and IF1 and on its RAM we’ve configured the R3964 Protocol.

-On S7 We’ve configured the CP341 using its parameter setting in hwconfig.
*We’ve used the example project for CP341. It uses FB8 to SEND and FETCH data. We’ve configured it in SEND mode to grab DBs from S5. The below is our code in S7. It is located in FC22 and it is called in OB1:

Code:
[COLOR=#000000][FONT=Arial] [INDENT]L 256 //LADDR
T "SEND WORK DB".P_SND_RK_WORK_LADDR


L 42 //DB_NO
T "SEND WORK DB".P_SND_RK_WORK_DB_NO
T "SEND SRC DB".P_SND_RK_DB_NO


L 0 //DBB_NO
T "SEND WORK DB".P_SND_RK_WORK_DBB_NO
T "SEND SRC DB".P_SND_RK_DBB_NO


L 114
T "SEND WORK DB".P_SND_RK_WORK_LEN //LEN
T "SEND SRC DB".P_SND_RK_LEN //LEN


// ------------------------
// SEND with Instance-DB
// ------------------------
CALL "P_SND_RK" , "SEND IDB"
SF :='S'
REQ :="SEND WORK DB".P_SND_RK_REQ
R :="SEND WORK DB".P_SND_RK_R
LADDR :="SEND WORK DB".P_SND_RK_WORK_LADDR
DB_NO :="SEND WORK DB".P_SND_RK_WORK_DB_NO
DBB_NO :="SEND WORK DB".P_SND_RK_WORK_DBB_NO
LEN :="SEND WORK DB".P_SND_RK_WORK_LEN
R_CPU_NO:=1
R_TYP :='D'
R_NO :=10
R_OFFSET:=0
R_CF_BYT:=255
R_CF_BIT:=
DONE :="SEND WORK DB".P_SND_RK_DONE
ERROR :="SEND WORK DB".P_SND_RK_ERROR
STATUS :="SEND WORK DB".P_SND_RK_WORK_STATUS


// ------------------------
// Generate edge P_SND_RK_REQ
// ------------------------
AN "SEND WORK DB".P_SND_RK_REQ //P_SND_RK_REQ
S "SEND WORK DB".P_SND_RK_REQ //set P_SND_RK_REQ


O "SEND WORK DB".P_SND_RK_DONE //P_SND_RK_DONE
O "SEND WORK DB".P_SND_RK_ERROR //P_SND_RK_ERROR
R "SEND WORK DB".P_SND_RK_REQ //P_SND_RK_REQ


// -------------------------------
// Check "Complete without error"
// -------------------------------
AN "SEND WORK DB".P_SND_RK_DONE //check P_SND_RK_DONE
JC CHER //if P_SND_RK_DONE equals 0, jump to CHER
//and check P_SND_RK_ERROR


// -------------------------------
// "Complete without error"
// P_SND_RK_DONE = 1
// -------------------------------
L "SEND SRC DB".P_SND_RK_COUNTER_OK //"Complete without Error"
+ 1 //increment counter
T "SEND SRC DB".P_SND_RK_COUNTER_OK


NOP 0
NOP 0 //further user functions
NOP 0


BE


// -------------------------------
// Check "Complete with error"
// P_SND_RK_ERROR = 1
// -------------------------------
CHER: AN "SEND WORK DB".P_SND_RK_ERROR //check P_SND_RK_ERROR
BEC //if no error occured, jump to end


// -------------------------------
// "Complete with error"
// -------------------------------
L "SEND SRC DB".P_SND_RK_COUNTER_ERR //"Complete with error"
+ 1 //increment counter
T "SEND SRC DB".P_SND_RK_COUNTER_ERR


L "SEND WORK DB".P_SND_RK_WORK_STATUS
T "SEND WORK DB".P_SND_RK_WORK_STATUS_SAV //save STATUS


NOP 0
NOP 0 //Error-Handling
NOP 0


BE



[/INDENT]
[/FONT][/COLOR]
TXD and RXD LEDs on CP341 are flashing and we also used a digital logic analyzer to inspect what is transferring on the line. and I could see the content of DB42 transferring.
But now I can’t see any change in S5 part. I thought the Data will be transferred to DB10 of the S5 As I have set the DB_no to 10 in my code. What am I doing wrong? It’s been a week I’ve been working on this with no success!L
 
I've never done Communication with CP341 but in S5 one RECEIVE_ALL is not enough, you need to have a dedicated RECIEVE for that specific data as well. Imagine you would like to have a 2nd communication part over the CP and a different PLC, how would the S5 know which is which without dedicated RECIEVES.
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Dear Clyde82,
I just have put RECIEVE_ALL and SEND_ALL in S5 as I want S5 to be in passive mode. Based on this post I thought I should do it this way. Maybe I've got it wrong.
Do you have any suggestion?
 
Hi masoudium,

first of all RECIEVE_ALL or SEND_ALL don't have anything to do with the S5 being passive or not. Those calls are needed if the S5 is active as well. On top of that S5 should never be the passive partner but always the active one (says so in SIEMENS documents somewhere). Second did you create and burn a job on the memory card / eprom ? Third if you have a job then you should have a A-NR for that job other than 0,0. That you need to create specific send / recives with FB126 / FB127 and then point to the correct DBs. It should look something along those lines:

Code:
Netzwerk 5
    // Aufruf FB245 als RECEIVE-ALL
    O   M 0.0
    ON M 0.0     <-------- VKE auf log "1" setzen, sonst wird der FB nur zufällig bearbeitet !!!
    :SPA FB 245
NAME: RECEIVE
SSNR:  KY 0,16   <--------- Deine Schnittstellennummer, hier 0
A-NR:  KY 0,2   <--------- Auftragsnummer auf 0 setzen
ANZW:  MW102
QTYP:  KC NN
DBNR:  KY 0,10
QANF:  KF +0
QLAE:  KF +200
PAFE:  MB  99
 
Hi Clyde82,
I've asked the same question in Siemens forum but receiving different answers. I'm completely confused right now. Please check this link.
 
Zuviel Werbung?
-> Hier kostenlos registrieren
hmm, looks like that user has more experience with that particular CP better listen to him. According to him what I wrote in my second post would not apply for this kind of communication.
 
Dear Clyde82,
Today I have no access to the system. Tomorrow I will check and report the result here.

Regards
 
Zurück
Oben