-> Hier kostenlos registrieren
Moin,
ich bin gerade dabei ein IO-Link System von Siemens mit dem RF210R zu programmieren.
Ich habe aus dem Internet vorgefertigte FBs genommen aber wenn ich den FB in die S7-1511-1 PN lade zeigt er Bereichslängenfehler an. den Fehlercode und den FB (in Text) Lade ich euch mal dazu. Ich danke im voraus schon mal allen Helfern.
Der Fehlercode:
Hier ist der Teil des DB den ich relevant finde
Der FB ist von Siemens. Dazu die PDF:https://cache.industry.siemens.com/...2/73565887_IOL_READ_WRITE_DATA_DOC_V31_de.pdf
ich bin gerade dabei ein IO-Link System von Siemens mit dem RF210R zu programmieren.
Ich habe aus dem Internet vorgefertigte FBs genommen aber wenn ich den FB in die S7-1511-1 PN lade zeigt er Bereichslängenfehler an. den Fehlercode und den FB (in Text) Lade ich euch mal dazu. Ich danke im voraus schon mal allen Helfern.
Der Fehlercode:
Code:
Temporärer CPU-Fehler: Bereichslängenfehler in FB 4
betrifft OB 1 Ausführung
Lesezugriff DB-Bereich
fehlerhafte Adresse, Operand ersetzt
PLC_1
interne Adressierungsdetails: Caddr=16#00000055, Bereich: DB-Bereich, Adr: 136
Hier ist der Teil des DB den ich relevant finde
Der FB ist von Siemens. Dazu die PDF:https://cache.industry.siemens.com/...2/73565887_IOL_READ_WRITE_DATA_DOC_V31_de.pdf
Code:
#adr_offset := #PORT_ADR; //start adress of port
#BLK := DPRD_DAT(LADDR := #HW_ID, RECORD => #REC_DAT);
#Status_Byte := #REC_DAT[#adr_offset]; //Status Byte
#Pres_bit := #Status_bit[5]; //Presence bit. Transponder on field
#PRESENCE := #Pres_bit;
IF NOT #EXECUTE THEN
#DONE := false;
#ERROR := false;
#STATUS := 0;
END_IF;
#diffToFour := WORD_TO_INT(#LEN_DATA) MOD 4;
IF #EXECUTE AND #EXECUTE <> #execute_req THEN //Positive edge for d#reading of data
IF NOT #BUSY THEN
#ADR := #ADR_TAG; //Transpoder Adress
#adrtag := WORD_TO_INT(#ADR);
#length := #LEN_DATA; //Length of read Data
#n_state := #Write_state;
#BUSY := TRUE;
#DONE := FALSE; //reset all the output parameters
#ERROR := FALSE;
#STATUS := 0;
#i := 0;
#bytemove := 0;
//next step >> send write command
ELSE
#temp_Status_W[1] := 16#8102; //block is still active
#temp_Status_W[0] := 16#0001; //Error identifier for block errors
#STATUS := #temp_Status;
#n_state := #Error_state;
END_IF;
IF #LEN_DATA < 4 THEN
#temp_Status_W[1] := 16#8104; //length too short
#temp_Status_W[0] := 16#0001; //identifier rfid errors
#STATUS := #temp_Status;
#n_state := #Error_state;
END_IF;
END_IF;
#execute_req := #EXECUTE;
IF NOT #PRESENCE AND #PRESENCE <> #presence_fl THEN //the tag has left the antenna field
IF NOT #DONE THEN
#Timer_in_1 := true; //wait 5 sec
#Timer_R_1 := false;
END_IF;
END_IF;
#presence_fl := #PRESENCE;
IF #PRESENCE THEN
#Timer_R_1 := true;
#Timer_in_1 := false;
END_IF;
//-----------------------------------------------------------------------------------------------------//
//------------------------------------------start of state machine------------------------------------//
//-----------------------------------------------------------------------------------------------------//
CASE #n_state OF
0://IDLE
#i := 0; //offset of puffer must be reseted
#BUSY := false;
#Timer_in_1 := false;
//-------------------------------------------------Write state-----------------------------------------//
//---------------------------------------------send write command--------------------------------------//
//-----------------------------------------------------------------------------------------------------//
2://Write_state
IF #length > 0 THEN
#DAT[#adr_offset] := 16#1; //Set write command
#DAT[#adr_offset + 2] := #ADR_WRITE[0]; //Adr-H
#DAT[#adr_offset + 3] := #ADR_WRITE[1]; //Adr-L
VariantGet(SRC := #IDENT_DATA,
DST => #Write_Data);
// IF #LEN_DATA > 4 THEN
#DAT[#adr_offset + 4] := #Write_Data[#i - #bytemove];
#DAT[#adr_offset + 5] := #Write_Data[1 + #i - #bytemove];
#DAT[#adr_offset + 6] := #Write_Data[2 + #i - #bytemove];
#DAT[#adr_offset + 7] := #Write_Data[3 + #i - #bytemove];
//Just 4 Bytes are reserved for every transfer
END_IF;
IF #BLK = 0 THEN
#n_state := #Telegram; //Telegram: Edit the read data
END_IF;
//-----------------------------------------------Telegram state----------------------------------------//
//-----------------------------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------------------------//
1://Telegram_state
IF #length > 0 THEN //Only when length of data>0 can continue
IF #Status_bit[6] THEN //IF RFID error has occured
#temp_Status_W[1] := #REC_DAT[#adr_offset + 1];
#temp_Status_W[0] := 16#0011; //Error identifier for RFID errors
#STATUS := #temp_Status;
#n_state := #Error_state;
END_IF;
#adr_offset := #PORT_ADR;
//-------------------------- write command is ready------------------------------------------------//
IF #Status_bit[7] AND #Status_bit[0] THEN
IF #REC_DAT[#adr_offset + 2] = #ADR_WRITE[0] AND #REC_DAT[#adr_offset + 3] = #ADR_WRITE[1] THEN //received ADR must be ==sent ADR
IF #BLK = 0 THEN
IF #Status_bit[7] AND NOT #Status_bit[6] THEN
#length := #length - 4;
IF #diffToFour <> 0 AND #length < 4 THEN
#bytemove := 4 - #diffToFour;
END_IF;
//if len is not dividable with 4 the adr offset has to be changed that the last (length < 4) command is done right
#i := #i + 4; //offset must be changed
#ADR := INT_TO_WORD(WORD_TO_INT(#ADR) + 4)-INT_TO_WORD(#bytemove); //Change the ADR on Transponder(4 Bytes)
#n_state := #Write_state; //Start a new write command
ELSE
#n_state := #IDLE;
END_IF;
ELSE
#temp_Status_W[1] := INT_TO_WORD(#BLK); //Error has to BLKMOV occured
#temp_Status_W[0] := 16#0001; //functions-Error identifier
#STATUS := #temp_Status;
#n_state := #Error_state;
END_IF;
END_IF;
END_IF;
#BLK := DPWR_DAT(LADDR := #HW_ID, RECORD := #DAT);
ELSE
#n_state := #IDLE;
#BUSY := false;
#temp_Done := TRUE;
#DONE := #temp_Done;
END_IF;
//------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------Error state------------------------------------------------//
//---------------------------------------------error has occured----------------------------------------------//
3://Error_State
#temp_Error := TRUE;
#BUSY := false;
#ERROR := #temp_Error;
#DONE := false;
#Timer_in_1 := false;
#Timer_R_1 := true;
#n_state := #IDLE;
END_CASE;
//------------------------------------------------------------------------------------------------------------//
//-------------------------------------------------Timer------------------------------------------------------//
//------------------------------------------------------------------------------------------------------------//
#IEC_Timer_0_Instance_1(IN := #Timer_in_1, //this timer will start, if the tag has left the antenna field
R := #Timer_R_1,
PT := #Timer_PT_1);
IF #IEC_Timer_0_Instance_1.Q THEN //error has occured. No tag on field during the 5 sec.
#temp_Status_W[1] := 16#8101; //tag has left the field
#temp_Status_W[0] := 16#0001; //identifier rfid errors
#STATUS := #temp_Status;
#n_state := #Error_state;
END_IF;