0
0
FreertosHow-ToBeginner · 4 min read

How to Program Siemens S7 1200 PLC Step-by-Step

To program a Siemens S7 1200 PLC, use the TIA Portal software to create a project, configure hardware, write logic in ladder or structured text, and download it to the PLC. The process involves defining inputs/outputs, programming control logic, and testing via simulation or real hardware.
📐

Syntax

Programming Siemens S7 1200 PLCs is done in TIA Portal using languages like Ladder Logic (LAD) or Structured Text (ST). The basic syntax for a simple output control in Structured Text is:

  • IF condition THEN action END_IF
  • Variables represent inputs/outputs or internal memory
  • Comments start with //
structured-text
IF I0.0 THEN
    Q0.0 := TRUE; // Turn on output
ELSE
    Q0.0 := FALSE; // Turn off output
END_IF
💻

Example

This example shows a simple program that turns on an output when a button is pressed. It uses Structured Text in TIA Portal.

structured-text
PROGRAM Main
VAR
    Button : BOOL; // Input I0.0
    Light : BOOL;  // Output Q0.0
END_VAR

// Logic: If button pressed, turn on light
IF Button THEN
    Light := TRUE;
ELSE
    Light := FALSE;
END_IF
Output
When input Button (I0.0) is TRUE, output Light (Q0.0) becomes TRUE; otherwise FALSE.
⚠️

Common Pitfalls

Common mistakes when programming Siemens S7 1200 include:

  • Not configuring hardware correctly in TIA Portal before programming
  • Using wrong addresses for inputs/outputs
  • Forgetting to download the program to the PLC after changes
  • Not testing the program in simulation or on hardware

Always verify addresses and hardware setup first.

structured-text
(* Wrong: Using input address without hardware config *)
IF I1.0 THEN
    Q0.1 := TRUE;
END_IF

(* Right: Confirm I1.0 exists in hardware config and is assigned correctly *)
📊

Quick Reference

Key steps to program Siemens S7 1200:

  • Install and open TIA Portal
  • Create a new project and add S7 1200 CPU
  • Configure inputs/outputs in hardware configuration
  • Write logic in Ladder or Structured Text
  • Compile and download to PLC
  • Test using simulation or real device

Key Takeaways

Use TIA Portal software to program Siemens S7 1200 PLCs with Ladder or Structured Text.
Always configure hardware and assign correct input/output addresses before programming.
Write clear logic and test your program in simulation or on the actual PLC.
Download your program to the PLC after compiling to apply changes.
Avoid common mistakes by verifying hardware setup and addresses first.