Reverse Fifo Table_s7-300

HansAndersen

Member
Join Date
Sep 2006
Location
Hamburg
Posts
132
Code:
1234 --> Db1.dbd0=1234
5678 --> Db1.dbd0=5678
	Db1.dbd4=1234
9abc --> Db1.dbd0=9abc
	Db1.dbd4=5678
	Db1.dbd8=1234


How To SOLVE This Proplem In S7-300 With Stl.

Thanks
 
Last edited:
For three variable

L #number
L DB1.DBD 0
==R
JC qqqq
L DB1.DBD 4
T DB1.DBD 8
L DB1.DBD 0
T DB1.DBD 4
L ID 0
T DB1.DBD 0
qqqq: NOP 0
 
Madman said:
For three variable

L #number
L DB1.DBD 0
==R
JC qqqq
L DB1.DBD 4
T DB1.DBD 8
L DB1.DBD 0
T DB1.DBD 4
L ID 0
T DB1.DBD 0
qqqq: NOP 0

tHANK YOU SO MUSH.BUT I DIDNT MENTION IT WILL CONTINIUE TO DBD160
 
Here's an FC that will do the job. I have tested this in the simulator using a FIFO containing 10 double words.

Code:
FUNCTION FC 5 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  dwDataToAdd : DWORD ; 
  iFifoSize : INT ; 
  dbToUse : BLOCK_DB ; 
END_VAR
VAR_TEMP
  iLoopCount : INT ; 
  dwPointerDec : DWORD ; 
END_VAR
BEGIN
NETWORK
TITLE =
	  L	 P#4.0; 
	  NEGD  ; 
	  T	 #dwPointerDec; 
	  L	 #iFifoSize; 
	  +	 -2; 
	  L	 P#4.0; 
	  *D	; 
	  LAR1  ; 
	  OPN   #dbToUse; 
	  L	 #iFifoSize; 
	  +	 -2; 
SHUF: T	 #iLoopCount; 
	  L	 DBD [AR1,P#0.0]; 
	  T	 DBD [AR1,P#4.0]; 
	  L	 #dwPointerDec; 
	  +AR1  ; 
	  L	 #iLoopCount; 
	  LOOP  SHUF; 
	  L	 DBD [AR1,P#0.0]; 
	  T	 DBD [AR1,P#4.0]; 
	  L	 #dwDataToAdd; 
	  T	 DBD [AR1,P#0.0]; 
	  SET   ; 
	  SAVE  ; 
END_FUNCTION
 
alternative:

L #number
L DB1.DBD 0
==R
JC qqqq
CALL "BLKMOV"
SRCBLK :=P#DB1.DBX0.0 BYTE 164
RET_VAL:=MW100
DSTBLK :=P#DB1.DBX170.0 BYTE 164
L #number
T DB1.DBD 0
CALL "BLKMOV"
SRCBLK :=P#DB1.DBX170.0 BYTE 160
RET_VAL:=MW100
DSTBLK :=P#DB1.DBX4.0 BYTE 160
qqqq: NOP 0


you db1
2jklgfdljgsdf1.jpg
 
or


L ID 0
L DB1.DBD 0
==R
JC qqqq
CALL "BLKMOV"
SRCBLK :=P#DB1.DBX0.0 BYTE 164
RET_VAL:=MW100
DSTBLK :=P#DB1.DBX4.0 BYTE 164
L ID 0
T DB1.DBD 0

qqqq: NOP 0


BLKMOV - SFC20 From Standart library
 
Last edited:
Madman said:
L ID 0
L DB1.DBD 0
==R
JC qqqq
CALL "BLKMOV"
SRCBLK :=P#DB1.DBX0.0 BYTE 164
RET_VAL:=MW100
DSTBLK :=P#DB1.DBX4.0 BYTE 164
L ID 0
T DB1.DBD 0

qqqq: NOP 0

I was under the impression that this won't work. The first 4 bytes would be copied over and over and over.

From the help file:
-Data is copied in the direciton of ascending adresses (dbb0 to dbb4, then dbb1 to dbb5, and when it gets to dbb4 it copies the data to dbb8, however dbb4 contains the data from dbb0......)
-The source and destination area must not overlap. See previous point

So best to use a DB just for the temporary holding of the data or use a DB twice the size as in Madman's first suggestion.

We use a second DB for the temporary holding of the data.
 
Jeebs said:
From the help file:
-Data is copied in the direciton of ascending adresses (dbb0 to dbb4, then dbb1 to dbb5, and when it gets to dbb4 it copies the data to dbb8, however dbb4 contains the data from dbb0......)
-The source and destination area must not overlap. See previous point

I don’t find this text in help file to sfc20. 📚

In plcsim this program is work. You make sure in this, then you download it’s in simulator.

gsdfgdgdfg.jpg
 
SFC20.JPG


Thats what it says in my Help-file

I was taught to never use overlapping area's when I first learned S7. Tested and tried it. It didn't work 'back then'.

But hey, if they 'fixed' it, all the better. Will test and try it again when time permits.....
 
Areas for SFC20 can overlap, but only when copy data in descending direction (source address is higher than destination address).
In PLCSim it works in both directions but it's an error of PLCSim.
 
I had used SFC20 before asking question.It had worked properly.I didnt see any overlaping.The mean of overlap may be different thing here.So I wanted to try it in STL.I had used loop and also indirect adressing.It had become with a little different.Thanks to L D[AR2,P#0.0], I found correct way. STL code worked wery well.But I had to add (fp)not to write the values to all fifo immediately.
 
Keep in mind that there is a point when SFC20 will be more efficient. For smaller blobs of data, a loop is faster, but for very large bobs, SFC20 will be faster (it uses a fixed overhead plus a per-byte multiplier). You can look at the execution times of the various instructions and SFCs (or test it) to see what is the best for you.

Also, as others mentioned, you can't overlap the data with SFC20.
 

Similar Topics

Hi all, I'm having trouble solving a problem I've been working on for several months, and thought you might like a stab at it. The machine runs...
Replies
22
Views
953
I have a SX2 plc and i'm getting 0-10v analog signal,but i need 10bar analog output in 0v can someone explain how its done
Replies
2
Views
546
I'm trying to add on to a safety circuit and trying to make sure this is fail-safe. My safety scanner needs some muting when things aren't running...
Replies
8
Views
824
Hi, I have issue with acs800 starting the motor in reverse for like 5-6 seconds with a max speed of around -220 rpm before it goes to the...
Replies
10
Views
2,005
I am looking at a 1305 drive connected to a PLC5 via RIO. The drive is working and I was able to get a functional HIM working on the drive as...
Replies
3
Views
1,850
Back
Top Bottom