Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: How to Code a FIFO Queue in STL Language in Siemens PLC?
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > How to Code a FIFO Queue in STL Language in Siemens PLC?

How to Code a FIFO Queue in STL Language in Siemens PLC?

In this article, you will learn how to write a code to create a custom first in first out (FIFO) queue in STL language in Siemens PLC.

Last updated: September 28, 2022 2:22 pm
Hussien Ghareb
PLC Tutorials
No Comments
Share
5 Min Read
SHARE

Welcome back Automation seekers in the last post we have learned how to create a FIFO register using Siemens ready-made functions in TIA Portal.

Contents
FIFO in STL LanguageExample Code in STLStep (1): Creating the function blockStep (2): Defining Inputs & Outputs of functionStep (3): Coding of the FIFO QueueStep (4): Calling the Function Block into the Main OBVideo

FIFO in STL Language

Today we are going to make the same task (FIFO Register), but in a different way, as we will code the function itself so if you are interested in programming here is another technical method to build FIFO (First in First Out) register.

Coding for FIFO Queue Register

Example Code in STL

Here we have a situation that requires storing some transmitter readings (20, 26, 19, 22, ….) every reading should be handled in its turn as whenever it is needed it will also be presented in its turn.

So, in order to avoid repeated coding and routine programming we are going to make a Hand-Made function block that would allow us to create the FIFO queue.

Step (1): Creating the function block

First of all, we will create an ordinary Function Block (automatically it will create an instance data block for itself). As shown in Fig. (1)

Creating the function block
Figure 1

Step (2): Defining Inputs & Outputs of function

As we can see in the next figure Fig. (2), we defined our inputs, output, and the variables that will be stored in the instance database memory.

FIFO in STL Language in Siemens PLC
Figure 2

Step (3): Coding of the FIFO Queue

And now let us put some coding into the function block that we have created.

Here for the first network as we can see in Fig. (3) IF the bit “Enter_Input” is activated the program will detect the input data and it will copy it to the word “RAM” to be stored in its turn.

After that we increased the “Address_Pointer” by one, this address pointer will help us to put the data in its turn in the queue as we will see.

And IF the bit “Enter_Input” is not activated the program will escape this instruction.

Coding of the FIFO Queue
Figure 3

As we said before the Address pointer helps us to organize the incoming readings so in Fig. (4) we can see that if the Address pointer = 1 (the incoming reading will be saved into the first address).

And if the Address pointer = (the incoming reading will be saved into the second address) … etc.

So, as we noticed the incoming readings would never be stored with the same address because of the Address Pointer.

Addressing of FIFO in PLC
Figure 4

Here for this network that is shown in Fig. (5) IF the bit “Get_Output” is activated the program will select the reading that it is in turn (First Address) and the program will copy it to the function output word (Outcome).

After that, the program will make a shifting operation for the addresses as the content of Address (2) will be stored into Address (1) and the same for Addresses (3,2) and the same for all other addresses.

We can describe this instruction exactly as the Queue moving.

Finally, we will decrease the Address Pointer by one to let the program knows that the queue gets rid of the first reading.

Create logic programming - FIFO
Figure 5

Download the code: FIFO Block in STL

Step (4): Calling the Function Block into the Main OB

As all of us know the program will not execute this function until you call it in the Main OB because the scan cycle of Siemens PLCs starts with the Main OB.

So here in Fig. (6), all we need to do is to drag and drop the Function Block at the first network.

Then put the desired address for your block.

Calling the Function Block into the Main OB
Figure 6

Video

FIFO Coding in STL - first in first out PLC Logic - Siemens Tia Portal

If you liked this article, then please subscribe to our YouTube Channel for Electrical, Electronics, Instrumentation, PLC, and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

  • What is a Wet Contact?
  • Preventive Maintenance of VFD
  • Why 24 Volts DC Power Supply?
  • Commissioning and Testing of PLC
  • Automation Engineer Troubleshooting
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

What is Interposing Relay in a PLC System ?
Run 4 Motors Sequentially from Same Push button PLC Program
What is Complementary Split Range Control (CSRC)?
Difference between Power Cables and Signal Cables
Types of Failures in Industrial Automation Systems
Laws of Boolean Algebra using Ladder Logic
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
208kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

Siemens PLC Interview Questions and Answers
OMRON PLC Tutorial: Car Parking System Application
Tank Level Control in PLC
Making Multi Way Switches using PLC
Auto and Manual Liquid Tank System: PLC Program Example
Single-Acting Cylinder Control using Proximity Sensor
Create PLC Program based on Logic Circuit
How Weigh Feeder Works ?

Keep Learning

What is Multi-touch Technology

What is Multi-touch Technology? – Industrial Automation

PLC Program using Bitwise Instructions

Allen Bradley Bitwise Logical Operations

Contextual HMI

What is Contextual HMI? – HMI Screens on a Mobile or Tablet

Open PLC Software

Open Source PLC and SCADA Software

Best Practices of PLC Wiring

Best Practices of PLC Wiring – Programmable Logic Controller

PLC Ladder Logic Example based on Set Coil and Reset Coil

PLC Ladder Logic Example based on Set Coil and Reset Coil

Draw a ladder logic to switch ON-OFF a bulb using a toggle switch

Draw a Ladder Logic to switch ON-OFF a Bulb using a Toggle Switch ?

Concept of DCS in Industrial Automation

Concept of DCS in Industrial Automation

Learn More

PlantPAx DCS

Introduction to PlantPAx Distributed Control System

Squirrel Cage Induction Motor vs Slip Ring Induction Motor

Digital Electronics Multiple Choice Questions

Fast Adder & Serial Adder Multiple Choice Questions

level control system

Practical Process Control System Questions & Answers – 11

Accelerometer Arduino Sensor

What are Micro Electro-Mechanical Systems (MEMS)?

Types of Script in Intouch Scada

Types of Script in Intouch Scada

Measuring Instruments Questions and Answers

150+ Measuring Instruments Questions and Answers

Rectifiers & Filters Interview Questions

Rectifiers & Filters Interview Questions

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?