STL shorter

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Anyone knows how I can get rid of the temps:
I don't know the DB in advance, so DB_DATA is needed:

code.JPG
 
Add the DB number as a parameter (integer) to FB130 and then use DBB35 etc. as the parameters. Open the correct DB in FB130 using the passed parameter.
 
hey

I tried this:

ddvfssqa.JPG



L D[AR2 said:
Add the DB number as a parameter (integer) to FB130 and then use DBB35 etc. as the parameters. Open the correct DB in FB130 using the passed parameter.
 
My suggestion was to pass on the db number as an integer, you have chosen to pass on the block parameter so my comments do not apply. What is the data type of the parameter Sign_1 ?
 
L D[AR2 said:
Add the DB number as a parameter (integer) to FB130 and then use DBB35 etc. as the parameters. Open the correct DB in FB130 using the passed parameter.

Sorry, my mistake here. You have to use fully qualified addresses when calling an FB (you can use DBB35 when using an FC). So, with the code you have you cannot eliminate the locals. Of course there are other possibilites....

1. Recode FB130 as an FC (you are only using the static data as temp anyway)

2. Use a pointer to pass in the base address of the chars

Here's the source code for FC130 which is FB130 recoded as an FC.

Code:
FUNCTION FC 130 : VOID
TITLE =Conversie String naar Real
VERSION : 0.1

VAR_INPUT
  DATA_DB : INT ; 
  Sign_1 : BYTE ; 
  DEC_1 : BYTE ; 
  POINT : BYTE ; 
  DEC_2 : BYTE ; 
  DEC_3 : BYTE ; 
  DEC_4 : BYTE ; 
  DEC_5 : BYTE ; 
  E : BYTE ; 
  Sign_2 : BYTE ; 
  DEC_6 : BYTE ; 
  DEC_7 : BYTE ; 
END_VAR
VAR_OUTPUT
  Result_Real : REAL ; 
END_VAR
VAR_TEMP
  iDB : INT ; 
  Data : STRING  [14 ]; 
END_VAR
BEGIN
NETWORK
TITLE =Received Serial Bytes schikken in een String Data Type 
	  L	 #DATA_DB; 
	  T	 #iDB; 
	  OPN   DB [#iDB]; 
	  LAR1  P##Data; 
	  L	 14; 
	  T	 B [AR1,P#0.0]; // Max String Length
	  L	 14; 
	  T	 B [AR1,P#1.0]; // Actual String Length
	  L	 #Sign_1; // 1
	  T	 B [AR1,P#2.0]; 
	  L	 #DEC_1; // 2
	  T	 B [AR1,P#3.0]; 
	  L	 #POINT; // 3
	  T	 B [AR1,P#4.0]; 
	  L	 #DEC_2; // 4
	  T	 B [AR1,P#5.0]; 
	  L	 #DEC_3; // 5
	  T	 B [AR1,P#6.0]; 
	  L	 #DEC_4; // 6
	  T	 B [AR1,P#7.0]; 
	  L	 #DEC_5; // 7
	  T	 B [AR1,P#8.0]; 
	  L	 '0'; // 8
	  T	 B [AR1,P#9.0]; 
	  L	 '0'; // 9
	  T	 B [AR1,P#10.0]; 
	  L	 '0'; // 10
	  T	 B [AR1,P#11.0]; 
	  L	 #E; // 11
	  T	 B [AR1,P#12.0]; 
	  L	 #Sign_2; // 12
	  T	 B [AR1,P#13.0]; 
	  L	 #DEC_6; // 13
	  T	 B [AR1,P#14.0]; 
	  L	 #DEC_7; // 14
	  T	 B [AR1,P#15.0]; 
	  CALL "STRNG_R" (
		   S						:= #Data,
		   RET_VAL				  := #Result_Real);
 
END_FUNCTION
 
Last edited:

Similar Topics

i am new to simatic manager and i am trying to figure what this part do in the code : A I 5.6 = DB50.DBX 4.6...
Replies
3
Views
132
Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
208
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
317
First off thank you in advance. Second I am very new to STL. I am trying to build a counter that has one count up and 23 count down options. Am...
Replies
6
Views
376
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
673
Back
Top Bottom