FIFO without FIFO BLOCK

mrsoliveira

Member
Join Date
Mar 2007
Location
RS
Posts
12
Does anyone have a sample of logic using one FIFO without correspondent block?

I nedd implement this for 4 positions bufer, but my plc dont have this function.

Thanks for help.
 
I will try and explain on how I make them...now I don't have enough details on your application but I will try anyway

load your first buffer/register this will be 1, now move your data from your last buffer to your second to last (you said you needed 4) so move your data from 3to4 then 2to3 then 1to2 then reload 1 with your new data

It helps when you are doing large ones if you draw them out to keep track, but you should be able to get 4 easy :)

Hope this helps...
 
mrsoliveira said:
Does anyone have a sample of logic using one FIFO without correspondent block?

I nedd implement this for 4 positions bufer, but my plc dont have this function.

Thanks for help.

In Plc2, Plc5, Slc500, I have used File to File Move, File Arithmetic Logic, and FIFO to do very much the same thing.

Find an instruction that allows you to deal with files, that has a control word.
Then move your input word into word 5 and extract it from word 1 to give you 4 steps , it is necessary to count 5 to 4 to 3 to 2 etc. counting the other direction over writes the value you want moved in the next step and takes the input word straight thru to the extract word in 1 step, and it appears to have been 4 steps
 
Last edited:
See exerpt attached PLCopen document with a FIFO example in ST. Page 46. (You will have to add the tabs back in).
or Follow the following link:
click me

Variable Declaration:
FUNCTION_BLOCK MC_LREAL_FIFO32
(* Function: The FB is a first in first out (FIFO) type Buffer for DINT Values with the size
of 32 Elements. *)
VAR_INPUT
Enable: BOOL; (* Inits the FIFO buffer on pos. edge *)
Put: BOOL; (* Writes value into FIFO on positive edge *)
Get: BOOL; (* Reads value into FIFO on positive edge *)
PutValue: LREAL; (* Value for Put *)
END_VAR
VAR_OUTPUT
Active: BOOL; (* Goes high with Enable *)
NoOfElementsInFIFO: DINT; (* Shows the number of elements in Buffer *)
GetValue: LREAL; (* Value for Get *)
Error: BOOL; (* is set at Error in FB *)
ErrorId: DINT; (* -1 = FIFO empty, -2 = FIFO full *)
END_VAR
VAR CONSTANT
MaxElements: DINT:= 32;
FIFO_Empty: DINT:= -1;
FIFO_Full: DINT:= -2;
END_VAR
VAR (* local variables *)
FIFOARRAY: ARRAY[1..MaxElements] OF LREAL;
EnableFlag: BOOL;
GetFlag: BOOL;
PutFlag: BOOL;
GetIndex: DINT;
PutIndex: DINT;
END_VAR
Code sequence:
IF Enable AND NOT EnableFlag THEN (* Initialisation at pos.edge of Enable *)
EnableFlag:= TRUE;
Active:= TRUE;
ErrorId:= 0;
Error:= FALSE;
GetIndex:= 1;
PutIndex:= 1;
NoOfElementsInFIFO:= 0;
PutFlag:= FALSE;
GetFlag:= FALSE;
ELSIF NOT Enable AND EnableFlag THEN (* Disable FB at neg.edge of Enable *)
EnableFlag:= FALSE;
Active:= FALSE;
END_IF
IF Enable AND NOT Error THEN
IF Put AND NOT PutFlag THEN (* pos.edge at Put *)
PutFlag:= TRUE;
IF NoOfElementsInFIFO >= MaxElements THEN
ErrorId:= FIFO_Full;
Error:= TRUE;
ELSE
NoOfElementsInFIFO:= NoOfElementsInFIFO + 1;
FIFOARRAY[PutIndex]:= PutValue;
PutIndex:= PutIndex + 1;
IF PutIndex > MaxElements THEN
PutIndex:= 1;
END_IF
END_IF
ELSIF NOT Put AND PutFlag THEN (* neg.edge at Put *)
PutFlag:= FALSE;
END_IF
IF Get AND NOT GetFlag THEN (* pos.Edge of Get *)
GetFlag:= TRUE;
IF NoOfElementsInFIFO < 1 THEN
ErrorId:= FIFO_Empty;
Error:= TRUE;
ELSE
NoOfElementsInFIFO:= NoOfElementsInFIFO - 1;
GetValue:= FIFOARRAY[GetIndex];
GetIndex:= GetIndex + 1;
IF GetIndex > MaxElements THEN
GetIndex:= 1;
END_IF
END_IF
ELSIF NOT Get AND GetFlag THEN (* neg.edge at Get *)
GetFlag:= FALSE;
END_IF
END_IF
 
Last edited:
Here is my attempt at a FIFO for byte's (4 locations):
(I haven't tried this so somebody may tell me it won't work)
fifobyte2.jpg


If data in the first location (VB1) changes then it copies
VB3 to VB4, (This overwrites VB4 so VB4 is "gone")
VB2 to VB3,
VB0 (which is a copy of the data originally contained in VB1) to VB2. And last step is to copy the new VB1 data to VB0 so the instruction is finished, untill somebody again modifies VB1.
Be warned, I am a learner myself, but it looks pretty straight forward. Same logic could be used for words, double words - just addressing would change.
Regards.
 
Last edited:

Similar Topics

I am not sure if this is possible but if there is a way, you guys would be the ones to know. I am currently working on a project where we are...
Replies
7
Views
216
Hello all, I'm using a 5069-L330ER in a project and I need to essentially capture some data that will be shown as a trend on a screen. The data...
Replies
9
Views
961
Hello! I have a network of conveyors bringing raw product to 4 machines. A sensor in the hopper of each machine calls for more product. I'm...
Replies
15
Views
5,866
Hello everyone, has anyone out there ever made a FIFO using an FFL and FFU instructions on a Micro800? I have tried setting it up just as I would...
Replies
9
Views
3,114
I have a bottle capper that is using an encoder and FIFO logic to track the free standing bottles passing through a bottle capper. I have checked...
Replies
31
Views
11,671
Back
Top Bottom