S7- Add 2 DB's ?

steen.bill

Member
Join Date
Sep 2002
Location
Denmark
Posts
21
Hello.
Are there a easy way to make "ADD" function of 2 DB's in S7?

I have one datablock and want to add another datablock with some variables, result in a third datablock.
DB's going up to DBD1200, all are "REAL"
 
Hi again..

FC104 are working, but not the way i want #¤%#¤&##
First value (in DB) have to be a INT..(showing the lengt of DB) i have only REAL.. Then i tried to change first value to a INT but now FC104 are adding wrong because INT are only 2 words... REAL are 4. All REAL value are therefor now in a wrong position, and adding to REAL's that are shift left are giving me a headegg...


I have 300 REAL's value, if my I0.0 goes high, i want to add some new value's and save all 300 REAL's in a new DB. If I0.0 goes low, remove addition again. IT should be simpel but it's S7....

If I0.0
DB401 = DB201 + DB301
Else
DB401 = DB201
 
steen.bill said:
Then i tried to change first value to a INT but now FC104 are adding wrong because INT are only 2 words... REAL are 4. All REAL value are therefor now in a wrong position,
I dont understand. Can you elaborate a bit more ?

steen.bill said:
[...]giving me a headegg...
Like this ?:
http://www.worth1000.com/emailthis.asp?entry=377548

If nothing else works, then maybe I could whip something up for you. But lets try to see if we can get FC104 to work first.
 
Here's an implementation you could use. It assumes the data starts at the beginning of the data blocks.
Detect a rising/falling edge of I0.0 and then call the block conditionally:

Code:
FUNCTION FC 11 : BOOL
TITLE =
VERSION : 0.1

VAR_INPUT
  iDBA : INT ; 
  iDBB : INT ; 
  iDBC : INT ; //if bAdd=1 then DBC=DBA + DBB  else DBC=DBA
  iNoOfReals : INT ; 
  bAdd : BOOL ; 
END_VAR
VAR_TEMP
  iLoopCount : INT ; 
  iDB_A : INT ; 
  iDB_B : INT ; 
  iDB_C : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
	  L	 #iDBA; 
	  T	 #iDB_A; 
	  L	 #iDBB; 
	  T	 #iDB_B; 
	  L	 #iDBC; 
	  T	 #iDB_C; 
	  LAR1  P#DBX 0.0; //point to start of DB
	  L	 #iNoOfReals; //set loop count
LA:   T	 #iLoopCount; 
	  OPN   DB [#iDB_A]; 
	  L	 D [AR1,P#0.0]; 
	  A	 #bAdd; 
	  JCN   noad; 
	  OPN   DB [#iDB_B]; 
	  L	 D [AR1,P#0.0]; 
	  +R	; 
noad: OPN   DB [#iDB_C]; 
	  T	 D [AR1,P#0.0]; 
	  +AR1  P#4.0; //point to next real
	  L	 #iLoopCount; // for all reals
	  LOOP  LA; 
	  SET   ; 
	  SAVE  ; 
END_FUNCTION
 
L D[ar2,p#0.0]

Fc104 🍑

L D[AR2,P#0.0](y) this are just want i was looking for.
As i always say, keep it simple, and this are indeed simple.
It's gonna be a nice day :)
 

Similar Topics

Hi, I have questions. I have Analog Input that need to put into Ignition Designer. But I don't know how to put?
Replies
1
Views
119
I have just installed Studio 5000 V30.11 on my Windows 11 Pro machine. First I had an "Invalid Pointer" error that required me to update Factory...
Replies
2
Views
118
Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
33
Views
1,023
We are trying to poll data coming from a PLC for remote monitoring we have the IP address of the PLC and the default port number and the path is...
Replies
25
Views
579
Back
Top Bottom