VnRobo
AboutPricingBlogContact
🇻🇳VISign InStart Free Trial
🇻🇳VI
VnRobo logo

AI infrastructure for next-generation industrial robots.

Product

  • Features
  • Pricing
  • Knowledge Base
  • Services

Company

  • About Us
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 VnRobo. All rights reserved.

Made with♥in Vietnam
VnRobo
AboutPricingBlogContact
🇻🇳VISign InStart Free Trial
🇻🇳VI
  1. Home
  2. Blog
  3. Siemens S7-1200 PLC Programming: From Basics to Application
otherplcautomation

Siemens S7-1200 PLC Programming: From Basics to Application

Overview of PLC programming with TIA Portal — from hardware configuration, ladder diagram writing to SCADA integration in automation systems.

Nguyen Anh TuanApril 10, 20256 min readUpdated: Jun 16, 2026

PLC in Industrial Automation Systems

PLC (Programmable Logic Controller) is the brain controlling every industrial automation system. From food packaging lines, conveyor systems in warehouses, to HVAC control for buildings — PLCs are everywhere.

Siemens S7-1200 is the most popular PLC series in Vietnam due to reasonable pricing, sufficient performance, and broad ecosystem support. This article will take you from zero to writing your first PLC program.

Siemens PLC in industrial control cabinet
Siemens PLC in industrial control cabinet

S7-1200 Hardware Configuration

Popular CPUs

CPU DI/DO/AI Memory Use Case Reference Price
1211C 6/4/2 50KB Small machines, simple control ~3.5M VND
1212C 8/6/2 75KB Packaging machines, small conveyors ~4.5M VND
1214C 14/10/2 100KB Most popular, versatile ~5.5M VND
1215C 14/10/2+2AO 125KB Complex systems, 2 Ethernet ports ~7M VND

Expansion Modules

Each CPU supports expansion:

  • Signal Board (SB): Attach directly to CPU, add compact I/O
  • Signal Module (SM): Separate expansion module, add DI/DO/AI/AO
  • Communication Module (CM): RS232/RS485, PROFIBUS, AS-i

Example configuration for product sorting conveyor system:

  • CPU 1214C DC/DC/DC (14 DI, 10 DO)
  • SM 1231 AI (8 analog inputs for weight sensors)
  • CM 1241 RS485 (Mitsubishi frequency drive connection)
  • SB 1232 AQ (1 analog output for speed control)

Programming with TIA Portal

TIA Portal (Totally Integrated Automation) is Siemens' integrated development environment. Version V17 and above are recommended for full OPC UA support and improvements.

Program Structure

A TIA Portal project is organized as:

Project
├── PLC_1 [CPU 1214C]
│   ├── Program blocks
│   │   ├── OB1 (Main) — Main program, runs each cycle
│   │   ├── FB1 (Motor_Control) — Function Block for motor control
│   │   ├── FC1 (Calculate_Speed) — Function for calculation
│   │   └── DB1 (Motor_Data) — Data Block storing parameters
│   ├── Technology objects
│   │   └── PID_Compact — PID controller
│   └── PLC tags
│       └── Tag table — Physical I/O mapping

Ladder Diagram (LAD)

Most intuitive language, suitable for on/off logic control. Easy for electricians to read and maintain:

// Motor self-holding circuit
|---[ I0.0 ]---[/I0.1 ]---( Q0.0 )---|   I0.0: START button
|                                       |   I0.1: STOP button (NC)
|---[ Q0.0 ]--------------------------|   Q0.0: Motor contactor
// Sequential control of 3 conveyor belts
|---[ I0.0 ]---[TON T1, 2s]---( Q0.0 )---|   Belt 1: start immediately
|---[ Q0.0 ]---[TON T2, 3s]---( Q0.1 )---|   Belt 2: delay 2s
|---[ Q0.1 ]---[TON T3, 3s]---( Q0.2 )---|   Belt 3: delay additional 3s

Function Block Diagram (FBD)

Suitable for analog processing and PID algorithms. Example: oven temperature control:

┌─────────────┐
│ PID_Compact │
│             │
│  Setpoint ──┤── 180.0 (°C)
│  Input ─────┤── IW64 (Thermocouple)
│  Output ────┤── QW80 (Heater SSR)
│  Kp ────────┤── 2.5
│  Ti ────────┤── 10.0s
│  Td ────────┤── 1.0s
└─────────────┘

Structured Text (SCL)

High-level language similar to Pascal, for complex algorithms. Recommended for complex logic:

// Temperature control with hysteresis and alarm
FUNCTION_BLOCK "FB_TempControl"
VAR_INPUT
    Temperature : REAL;    // Measured temperature
    SetPoint    : REAL;    // Target temperature
    Hysteresis  : REAL;    // Deadband (typically 2-5°C)
    AlarmHigh   : REAL;    // High alarm threshold
    AlarmLow    : REAL;    // Low alarm threshold
END_VAR
VAR_OUTPUT
    HeaterOutput : BOOL;
    CoolerOutput : BOOL;
    AlarmActive  : BOOL;
END_VAR

// Control logic
IF Temperature > SetPoint + Hysteresis THEN
    HeaterOutput := FALSE;
    CoolerOutput := TRUE;
ELSIF Temperature < SetPoint - Hysteresis THEN
    HeaterOutput := TRUE;
    CoolerOutput := FALSE;
END_IF;

// Check alarm
AlarmActive := (Temperature > AlarmHigh) OR (Temperature < AlarmLow);

SCADA Connection and Monitoring

SCADA system monitoring factory
SCADA system monitoring factory

S7-1200 supports multiple connection protocols from firmware V4.4:

OPC UA (Recommended)

OPC UA is the industrial standard for M2M communication. S7-1200 V4.4+ has integrated OPC UA Server:

# Python client reading data from PLC via OPC UA
from opcua import Client

client = Client("opc.tcp://192.168.0.1:4840")
client.connect()

# Read temperature from PLC
temp_node = client.get_node("ns=3;s=\"DB_Process\".\"Temperature\"")
temperature = temp_node.get_value()
print(f"Current temperature: {temperature}°C")

# Write setpoint
sp_node = client.get_node("ns=3;s=\"DB_Process\".\"SetPoint\"")
sp_node.set_value(180.0)

client.disconnect()

S7 Protocol + Node-RED

For quick and flexible solutions:

{
    "nodes": [
        {
            "type": "s7 in",
            "address": "DB1,REAL0",
            "name": "Read Temperature",
            "interval": 1000
        }
    ]
}

Integrated Web Server

S7-1200 has an integrated web server allowing simple HTML dashboards. Suitable for basic monitoring without separate SCADA.

Integrating PLC with Robot (ROS 2)

The most interesting part — connecting PLC with modern robot systems. Hybrid PLC + ROS 2 architecture leverages:

  • PLC: Stable, deterministic, handles safety I/O per robot safety standards
  • ROS 2: Flexible, AI/ML, path planning, computer vision
┌─────────────────────────────────────────┐
│              ROS 2 System               │
│  ┌──────────┐  ┌──────────┐  ┌───────┐ │
│  │ Nav2     │  │ MoveIt2  │  │ Vision│ │
│  │ (AMR)    │  │ (Arm)    │  │ (CV)  │ │
│  └────┬─────┘  └────┬─────┘  └───┬───┘ │
│       └──────────────┼────────────┘     │
│              ┌───────┴───────┐          │
│              │ OPC UA Bridge │          │
│              └───────┬───────┘          │
└──────────────────────┼──────────────────┘
                       │ OPC UA
┌──────────────────────┼──────────────────┐
│              ┌───────┴───────┐          │
│              │  S7-1200 PLC  │          │
│              └───────┬───────┘          │
│       ┌──────────────┼────────────┐     │
│  ┌────┴─────┐  ┌─────┴────┐  ┌───┴───┐ │
│  │ Sensors  │  │ Actuators│  │ Safety│ │
│  │ (I/O)    │  │ (Motor)  │  │ (E-Stop)│ │
│  └──────────┘  └──────────┘  └───────┘ │
│              PLC Layer                  │
└─────────────────────────────────────────┘

Debugging and Best Practices

Diagnostic Buffer

S7-1200 logs the last 50 events. Always check diagnostic buffer when errors occur:

  • TIA Portal → Online & Diagnostics → Diagnostic buffer

Tips from Real Experience

  1. Always use Symbolic names — Set meaningful tag names (Motor_Conveyor_1_Run instead of Q0.0)
  2. Backup project to Git — TIA Portal projects are directories, version-controllable
  3. Comment every network — You'll forget logic after 6 months without comments
  4. Use FB instead of FC when state needed — FB has instance DB, FC doesn't
  5. Test on PLCSIM first — TIA Portal has simulator, test logic before downloading to real PLC
  6. Monitor cycle time — Keep cycle time < 10ms for motion, < 100ms for HVAC

Common Errors

Error Cause Solution
Red SF LED Hardware fault Check diagnostic buffer
Connection failure IP conflict or firewall Ping PLC, check subnet mask
Program download fail CPU in STOP mode Switch to RUN, re-download
Incorrect analog reading Scaling not correct Check input range (0-27648 = 0-10V)

Advice for Beginners

  • Hardware: Start with CPU 1214C DC/DC/DC — reasonable price (~5.5M VND), sufficient features for learning and real projects
  • Software: Use TIA Portal V17+ for full OPC UA and simulator support
  • Learning path: LAD → SCL → FB/DB → OPC UA → Robot integration
  • Community: Join Siemens Vietnam Facebook group, Siemens Support forums
  • Certification: Siemens SITRAIN program — international certification valuable for career

Related Articles

  • Digital Twin in Manufacturing: Smart Factory Simulation
  • MQTT Protocol: Communication Between Robot and Cloud
  • Industrial Robot Safety Standards: ISO 10218 and ISO/TS 15066
NT

Nguyễn Anh Tuấn

Robotics & AI Engineer. Building VnRobo — sharing knowledge about robot learning, VLA models, and automation.

Khám phá VnRobo

Fleet MonitoringROS 2 IntegrationAMR Solutions

Related Posts

Tutorial
Robotics
ros2monitoringrobot-fleet
other

Cách giám sát robot ROS 2 từ xa: Hướng dẫn đầy đủ 2026

Hướng dẫn từng bước giám sát robot ROS 2 từ bất kỳ đâu — pin, CPU, trạng thái, heartbeat, alerts. Code chạy được, setup 10 phút. Miễn phí 3 robots.

4/14/20267 min read
NT
Comparison
Robotics
formantrobot-fleetfleet-management
other

Lựa chọn thay thế Formant: So sánh 5 nền tảng quản lý fleet robot 2026

Tìm alternative cho Formant năm 2026? So sánh thẳng thắn 5 nền tảng quản lý fleet robot — giá, hỗ trợ ROS 2, tính năng, và cái nào hợp với team bạn.

4/13/202611 min read
NT
Comparison
Robotics
aws-robomakerrobot-fleetros2
other

AWS RoboMaker 2026: 5 lựa chọn thay thế cho đội ROS 2

AWS RoboMaker đã đóng cửa tháng 9/2025. Đây là 5 lựa chọn thay thế tốt nhất cho quản lý fleet robot ROS 2 năm 2026 — so sánh thẳng thắn, giá cả và hướng dẫn migration.

4/12/202611 min read
NT
VnRobo logo

AI infrastructure for next-generation industrial robots.

Product

  • Features
  • Pricing
  • Knowledge Base
  • Services

Company

  • About Us
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 VnRobo. All rights reserved.

Made with♥in Vietnam