Byte To Integer problem (written an error in S7)

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
This morning I had a problem with a machine where I use BTI functions...

This was what the diagnostics of the CPU gave me:

fstfau1.jpg



fstfau2.jpg



This i my code of thi block:

Code:
FUNCTION "Alarmlocatie1" : VOID
TITLE =
VERSION : 0.1

VAR_OUTPUT
  AL_Lader1 : BOOL ; 
  AL_Aanvoer1 : BOOL ; 
  AL_Ponsbank1 : BOOL ; 
  AL_Uitvoer1 : BOOL ; 
  AL_Uitwerp1 : BOOL ; 
END_VAR
VAR_TEMP
  Lader_tmp_1 : INT ; 
  Lader_tmp_2 : INT ; 
  LADERVALUE : INT ; 
  AANVOERVALUE : INT ; 
  Ponsbank_tmp_1 : INT ; 
  Ponsbank_tmp_2 : INT ; 
  Ponsbank_tmp_3 : INT ; 
  Ponsbank_tmp_4 : INT ; 
  PONSBANKVALUE : INT ; 
  UITVOERVALUE : INT ; 
  UITWERPVALUE : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =Lader Alarm ?
	  L	 DB20.DBB	0; // Lader Alarmen
	  BTI   ; 
	  T	 #Lader_tmp_1; 
	  L	 DB20.DBB	3; // Lader Alarmen
	  BTI   ; 
	  T	 #Lader_tmp_2; 
	  L	 #Lader_tmp_1; 
	  L	 #Lader_tmp_2; 
	  +I	; 
	  T	 #LADERVALUE; 
	  L	 0; 
	  <>I   ; 
	  =	 #AL_Lader1; 
NETWORK
TITLE =Aanvoer Alarm ?
	  L	 DB20.DBB	2; // Aanvoer Alarmen
	  BTI   ; 
	  T	 #AANVOERVALUE; 
	  L	 0; 
	  <>I   ; 
	  =	 #AL_Aanvoer1; 
NETWORK
TITLE =Ponsbank Alarm ?
	  L	 DB20.DBB	4; // Ponsbank Alarmen
	  BTI   ; 
	  T	 #Ponsbank_tmp_1; 
	  L	 DB20.DBB	5; // Ponsbank Alarmen
	  BTI   ; 
	  T	 #Ponsbank_tmp_2; 
	  L	 DB20.DBB	6; // Ponsbank Alarmen
	  BTI   ; 
	  T	 #Ponsbank_tmp_3; 
	  L	 DB20.DBB	7; // Ponsbank Alarmen
	  BTI   ; 
	  T	 #Ponsbank_tmp_4; 
	  L	 #Ponsbank_tmp_1; 
	  L	 #Ponsbank_tmp_2; 
	  +I	; 
	  L	 #Ponsbank_tmp_3; 
	  +I	; 
	  L	 #Ponsbank_tmp_4; 
	  +I	; 
	  T	 #PONSBANKVALUE; 
	  L	 0; 
	  <>I   ; 
	  O	 "DB allarmen1".Allarm[72]; // Ponsbank Alarm
	  O	 "DB allarmen1".Allarm[73]; // Ponsbank Alarm
	  O	 DB21.DBX	0.5; // Ponsbank Alarm
	  =	 #AL_Ponsbank1; 
NETWORK
TITLE =Uitvoer Alarm ?
	  L	 DB20.DBB	8; // Uitvoer Alarmen
	  BTI   ; 
	  T	 #UITVOERVALUE; 
	  L	 0; 
	  <>I   ; 
	  O	 "DB allarmen1".Allarm[74]; // Uitvoer Alarm
	  O	 "DB allarmen1".Allarm[75]; // Uitvoer Alarm
	  O	 "DB allarmen1".Allarm[76]; // Uitvoer Alarm
	  O	 "DB allarmen1".Allarm[77]; // Uitvoer Alarm
	  O	 "DB allarmen1".Allarm[78]; // Uitvoer Alarm
	  O	 DB21.DBX	0.7; // Zaag Alarm
	  =	 #AL_Uitvoer1; 
	  L	 DB20.DBB   10; // Uitwerpen Alarmen
	  BTI   ; 
	  T	 #UITWERPVALUE; 
	  L	 0; 
	  <>I   ; 
	  =	 #AL_Uitwerp1; 
END_FUNCTION
 
ahem..

BTI is BCD to Integer not Byte to Integer, if bits 0 to 11 of the accumulator are not a valid 3 digit BCD number then you get this fault.
 
Ahum

OH MY GOD :)

I just need to load the byte value and transfer it to an integer to make comparisions.

Big mistake

Thanks

krk said:
ahem..

BTI is BCD to Integer not Byte to Integer, if bits 0 to 11 of the accumulator are not a valid 3 digit BCD number then you get this fault.
 

Similar Topics

After twisting this way and that, I finally have the PLCs clock information in seperate bytes. Now to display this on an HMI, it should be an...
Replies
17
Views
6,040
Our system utilises INPUT_BYTE to capture NMEA0183 ASCII stream which sends data to the NOM multiple times a second. The NOM module can either be...
Replies
0
Views
403
Hello everyone, friends. I need help with something. I want to read and change Bit and Byte numbers via HMI. I found a code snippet for this as...
Replies
18
Views
3,065
Hello everyone :) I just want to start with learning PLC programming, so I need advice. I have SIMATIC S7-1200, CPU with integrated memory...
Replies
5
Views
947
I have a C-More HMI that changes my PLC String from "Machine Status" to "aMhcni etStasu" . There is an option with other objects that have string...
Replies
15
Views
3,504
Back
Top Bottom