January 9, 2025

PLC Programming Blocks: OB, FC, FB, and DB

Introduction

Programmable Logic Controllers (PLCs) are essential in industrial automation, and their efficient programming relies on different types of program blocks. In Siemens TIA Portal (Step 7) or similar PLC software, program organization is crucial for creating structured, reusable, and efficient control logic.

In this article, we will explore the four main types of PLC program blocks used in Siemens PLC programming:

  1. OB (Organization Block) – Main program execution blocks
  2. FC (Function) – Reusable logic without memory retention
  3. FB (Function Block) – Reusable logic with memory retention
  4. DB (Data Block) – Data storage for variables

Understanding these blocks will help you write better PLC programs that are scalable, modular, and easy to maintain.

1. Organization Block (OB)

What is an OB?

  • Organization Blocks (OBs) control the execution of a PLC program.
  • They define the priority, scan cycle, and error handling of a PLC.
  • The main cycle OB (OB1) is executed cyclically, while other OBs handle specific events.

Types of OBs

  1. OB1 – Main Program Cycle

    • This is the main cyclic program execution block.
    • The PLC continuously scans OB1 as long as it is in RUN mode.
    • All logic is usually called within OB1 using FCs and FBs for modular programming.
  2. OB10-OB17 – Time-Triggered OBs

    • These execute at specific time intervals.
    • Useful for timed operations, such as data logging or periodic checks.
  3. OB20-OB23 – Hardware Interrupt OBs

    • Triggered by hardware interrupts like sensor inputs.
    • Used for real-time critical operations.
  4. OB30-OB38 – Cyclic Interrupt OBs

    • Execute at fixed time intervals.
    • Ensure consistent execution of specific tasks.
  5. OB40-OB47 – Process Alarm OBs

    • Triggered by process alarms.
    • Used for fault handling.
  6. OB80-OB87 – Fault Handling OBs

    • Handle errors such as division by zero, power failure, or module faults.
    • Ensures the PLC can recover from errors gracefully.

2. Function (FC)

What is an FC?

  • Functions (FCs) are reusable blocks of logic that do not retain memory after execution.
  • They can take input parameters and return output values, but they do not have an internal memory.
  • Best suited for calculations, math operations, and temporary logic.

Key Features of FCs

No internal memory (stateless)
Accepts input parameters and returns output parameters
Used for simple, reusable logic

Use Case for FCs

  • Mathematical calculations
  • Signal processing
  • Data conversions


3. Function Block (FB)

What is an FB?

  • Function Blocks (FBs) are similar to FCs but retain memory (stateful execution).
  • Used when logic needs to store data across multiple cycles.
  • They require a Data Block (DB) for memory storage.

Key Features of FBs

Have internal memory (can store values between scans)
Require an Instance Data Block (DB)

Used for complex logic, motor control, and PID control

Example: FB for Motor Control

Use Case for FBs

  • Motor start/stop circuits
  • PID controllers
  • Alarm handling

4. Data Block (DB)

What is a DB?

  • Data Blocks (DBs) store global or instance-specific data.
  • Can be used to store sensor values, setpoints, or configuration parameters.
  • There are two types of DBs:
    • Global DB – Shared across multiple functions.
    • Instance DB – Used with FBs to store internal memory.

Best Practices for Using OBs, FCs, FBs, and DBs

Use OB1 only for function calls – Keep OB1 clean by calling FCs and FBs instead of writing logic directly inside it.
Use FCs for stateless logic – If the function does not need memory, use an FC to keep programs modular.
Use FBs for stateful operations – If the function needs to store past values, use an FB with an instance DB.
Organize data using DBs – Store configuration parameters in DBs to make programs easier to modify.

Conclusion

Understanding OBs, FCs, FBs, and DBs is essential for writing structured, efficient, and scalable PLC programs.

  • OBs define the execution cycle and event handling.
  • FCs provide reusable, stateless logic.
  • FBs allow memory retention for stateful processes.
  • DBs store important process data.

By using these blocks strategically, you can build flexible automation solutions that are easy to maintain and expand. 


Click here to watch video 

https://youtu.be/BmCGuHfOjp0

January 8, 2025

PRA remote IO SCANNING using Schneider eco structure control expert platform

PRA Remote IO Scanning Using Schneider EcoStruxure Control Expert

Introduction

In modern industrial automation, Remote I/O (RIO) Scanning plays a crucial role in optimizing system performance by enabling communication between a Programmable Logic Controller (PLC) and remote I/O modules. Schneider Electric's EcoStruxure Control Expert (formerly Unity Pro) provides powerful tools to configure and manage PRA (Process Remote Automation) Remote I/O Scanning for efficient and seamless data exchange.

This article explores the step-by-step process of setting up PRA Remote I/O Scanning using Schneider’s EcoStruxure Control Expert and highlights key configurations for ensuring smooth communication.


Understanding PRA Remote IO Scanning

Remote I/O scanning allows a PLC to communicate with distributed I/O modules over a network, reducing wiring complexity and improving flexibility. This is essential for large-scale industrial applications where I/O devices are spread across different locations.

With Schneider Electric’s PRA Remote I/O Scanning, the PLC continuously reads inputs and writes outputs to remote I/O devices over a communication protocol such as Ethernet/IP, Modbus TCP, or CANopen.


Step-by-Step Configuration in EcoStruxure Control Expert

Step 1: Open EcoStruxure Control Expert & Create a New Project

  1. Launch EcoStruxure Control Expert.
  2. Select your Schneider Electric PLC model (e.g., Modicon M580, M340).
  3. Create a new project and configure the hardware settings.

Step 2: Configure the PLC for Remote I/O Communication

  1. Open the Hardware Configuration Tab

    • Navigate to the "Configuration" section.
    • Select the PLC backplane and configure the CPU.
  2. Add an Ethernet Network Module

    • Right-click on the CPU rack and add an Ethernet module (e.g., BMXNOC0401 for M340 or BME NOC 0311 for M580).
    • Configure the IP Address, Subnet Mask, and Gateway for the Ethernet module.

Step 3: Adding and Configuring the Remote I/O Scanner

  1. Open the DTM Browser

    • In EcoStruxure Control Expert, go to "DTM Browser" and add a new Remote I/O scanner under the Ethernet module.
  2. Define Remote I/O Device Settings

    • Assign a device name and set the IP address of the Remote I/O module.
    • Ensure that the network settings match the PLC’s Ethernet configuration.
  3. Scan and Detect Remote I/O Modules

    • Click "Scan Devices" to detect the connected Remote I/O modules.
    • The system will automatically list the available PRA remote I/O devices.

Step 4: Configuring Remote I/O Modules

  1. Assign I/O Modules to the Remote I/O Scanner

    • Select the PRA Remote I/O module (e.g., BMXCRA31210, BMXDDI3202) from the device list.
    • Define input and output mappings.
    • Set up any required diagnostics and alarms for real-time monitoring.
  2. Validate the I/O Mapping

    • Check the status of connected I/O devices.
    • Ensure that all input and output addresses are correctly assigned.

Step 5: Program and Test the I/O Scanning

  1. Write a Simple Ladder Logic Program

    • Create a basic Ladder Logic or Structured Text program to test the remote I/O.
    • Example: A digital input from a remote module turns on a digital output in the PLC.
  2. Build and Transfer the Project to the PLC

    • Compile the project and download it to the PLC.
    • Switch the PLC to RUN Mode.
  3. Monitor I/O Status

    • Open the EcoStruxure Control Expert Online Mode to view real-time I/O updates.
    • Verify that the remote I/O signals are functioning as expected.

Troubleshooting Tips

  • Communication Failure: Check the Ethernet cable, IP configuration, and firewall settings.
  • I/O Not Updating: Ensure that I/O modules are correctly mapped in the Remote I/O Scanner.
  • PLC Not Detecting Remote I/O: Perform a hardware scan and ensure the correct firmware version is installed.

Conclusion

Configuring PRA Remote I/O Scanning in Schneider EcoStruxure Control Expert allows seamless data exchange between a PLC and remote I/O devices, enabling efficient and reliable industrial automation. By following the step-by-step setup, industries can enhance their control systems, reduce wiring costs, and improve real-time monitoring of field devices.


Click here to watch video

https://youtu.be/8jYMe9Y6NTU




January 7, 2025

Scheider ATV 320 drive communication with Schneider PLC M 340 using control expert

 To establish communication between a Schneider ATV320 drive and an M340 PLC using Control Expert (formerly Unity Pro), follow these steps:

Hardware Setup: Connect the ATV320 to the M340 PLC using Modbus RTU (RS485) or Modbus TCP/IP (Ethernet) based on the available communication options. Ensure proper wiring, IP addressing (for Ethernet), or serial communication parameters (for RS485). ATV320 Configuration: Configure communication settings (Modbus address, baud rate, parity, or IP address) via the drive's keypad, SoMove software, or Web Server. Set the control mode to enable network control. M340 PLC Configuration in Control Expert: Create a new project and configure the communication module (e.g., BMXNOC for Ethernet or serial communication modules for RS485). Define the ATV320 as a Modbus device (Slave for RTU or TCP/IP). Control and Monitoring Setup: Map the required Modbus registers for control (start/stop, speed setpoint) and feedback (status, frequency). Use READ_VAR and WRITE_VAR functions or Schneider’s prebuilt DFBs (Derived Function Blocks) for communication logic. Testing and Validation: Verify communication using diagnostic tools in Control Expert. Test the control and feedback by sending commands to the drive and reading its status.

Watch video here
https://youtu.be/NKdheHjv1P8