Using Clock Memory Bits in TIA Portal – Siemens PLC

In this article, we will take about clock memory bits in TIA Portal and Siemens PLC. And we will show how to enable the use of the memory bits and how it can help you avoid coding a lot of logic lines to obtain a simple function that your PLC already do it internally.

Contents:

  • What are clock memory bits?
  • The need for clock memory bits.
  • Enable clock memory in my project.
  • Simple program example.
  • Program simulation.
  • Conclusion.

What are Clock Memory Bits?

A clock memory is a bit memory that changes its binary status periodically in the ratio of 1:1. That simply means it changes its status periodically between true and false with a pre-defined frequency.

There are 8 clock memory bits pre-defined in the CPU which is why they are also called clock memory byte.

You decide which memory byte of the CPU will become the clock memory byte when you enable the use of the memory byte and assign the clock memory parameters.

The Need for Clock Memory Bits

You don’t necessarily need the clock memory as you can create your own logic and achieve the same functionality. However, it is a good thing to have in your pocket when you need such functionality. As creating 8 separate logic for 8 clock memory bits will take some of your time and effort and might make your program unnecessarily large.

You can use clock memory, for example, to activate flashing indicator lamps or to initiate periodically recurring operations such as recording actual values.

Each bit of the clock bit memory byte is assigned a frequency. See the following table.

Bit of the clock memory byte76543210
Period (s)2.01.61.00.80.50.40.20.1
Frequency (Hz)0.50.62511.2522.5510

Table 1. Clock memory bits frequencies according to the TIA Portal help manual.

Enable Clock Memory in Siemens PLC

To use the clock memory bits in your logic, you need to enable the use of the clock memory byte from the properties of the CPU. See picture 1.

Enable the use of clock memory byte in Tia Portal
Picture 1 – Enable the use of clock memory byte

You can choose the address of the byte you want to assign for the clock memory, just make sure it doesn’t conflict with any other memory bytes in your PLC logic.

As you see from the picture, we chose the address 0, so if you need to use the 2Hz clock bit you will use the bit %M0.3

Tia Portal Conveyor Belt Example Program

In a previous article, we used a simple example of a conveyor belt moving a product between the start and end of the belt. There was an indication LED that turns ON when the Belt is running. See picture 2.

conveyor belt system
Picture 2 – Simple conveyor belt system

We will use the same example, but this time we will make the LED more intuitive using the clock memory bits. This time we will use the clock memory bits with the LED to give an indication of different cases of the process.

Process Description

In a conveyor belt system controlled by a PLC, there are two presence sensors at the two ends of the belt to detect the presence of a product, when the product is detected at the start of the belt, the conveyor can be started through a start Pushbutton and when the product reaches the end the belt will stop automatically and it will not run again until a new product is detected once again at the start and the START push button is pressed.

The indication LED should have more than one behavior depending on the current case of the system.

These cases are as follows:

  1. If there is a product at the start of the belt but START is not pressed yet, the LED should be flashing by a frequency of 0.5Hz.
  2. If the conveyor is moving the product the LED should be flashing by a 2Hz frequency.
  3. When the product reaches the end of the belt the LED should be ON
  4. When the product is removed from the end the LED will go OFF.

 Project IOs

We have 4 digital inputs as follows:

  • START: start push button to run the Conveyor.
  • STOP: stop push button to stop the conveyor at any moment.
  • P1: Presence sensor at the start of the belt.
  • P2: Presence sensor at the end of the belt.

We also have 2 digital outputs as follows:

  • MOTOR: when activated the Conveyor belt will start running.
  • LED: will be activated according to the sequence mentioned before.

Program Code

First, we select our PLC and assign the IO tags. See picture 3

Tia Portal Conveyor Belt Example Program
Picture 3 – Assign inputs and outputs tags

Don’t forget to enable the use of the clock memory byte as shown in picture 1.

We will have two networks of code, one for the control of the conveyor belt and another for the LED logic. See pictures 4 and 5 for the logic.

PLC control logic of the conveyor belt
Picture 4 – The control logic of the conveyor belt
Using Clock Memory Bits in TIA Portal - Siemens PLC
Picture 5 – The control logic of the LED

As you can see, using the clock memory bits made the logic simple and easy to read. Imagine if you would create the same logic without the use of these bits, you would have used a lot of timers and your logic would have been fairly complicated.

Program Simulation

We explained before how to use the PLCSim to simulate our code. In this example, we will use the simulation sequence to create the same sequence of the actual process and we will see if the LED behavior will match the intended functionality or not.

Start by compiling our code and start a new simulation. See picture 6.

Tia Program simulation
Picture 6 – Program simulation

As you can see, the LED is now OFF; there are no products presences at the start or the end of the conveyor.

We created a simulation sequence and see how the LED will react to different process conditions. See the following animation.

Clock Memory Bits in PLC

See if you can notice how the LED behavior changes with different process conditions.

Conclusion

  • Clock memory bits turn on and off with a pre-defined frequency.
  •  They are very useful when you need to activate flashing indicator lamps or to initiate periodically recurring operations.
  • Using clock memory bits will save you the time and effort consumed to obtain the same functionality through your own logic.

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

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

Read Next:

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

Leave a Comment