From Spreadsheet to PLC Code
Manually coding ISA-88 state machines in TIA Portal is tedious and error-prone. The FDS (Functional Design Specification) module lets you describe your equipment (Control Modules) and phase sequences in a simple CSV file, then auto-generates production-ready SCL Function Blocks — complete with HOLD/ABORT handling, state machine logic, and proper I/O declarations.
Prerequisites
- T-IA Connect installed and running
- A TIA Portal project open (V16–V21)
- A CSV file with your design spec (or use the sample below)
Step 1: Prepare the CSV File
The CSV follows the ISA-88 standard with two sections: [CmTypes] for equipment definitions (valves, pumps, sensors) and [Phases] for sequence logic (state machines). Here is a minimal example:
[CmTypes] CmType;Variable;Direction;DataType;Description Valve;Cmd_Open;Out;Bool;Open command Valve;Sts_Opened;In;Bool;Opened feedback Valve;Sts_Closed;In;Bool;Closed feedback Pump;Cmd_Run;Out;Bool;Run command Pump;Sts_Running;In;Bool;Running feedback Pump;Speed_SP;Out;Real;Speed setpoint TempSensor;Value;In;Real;Temperature value TempSensor;Sts_Fault;In;Bool;Sensor fault [Phases] PhaseType;Step;StepName;IsInitial;IsFinal;EntryAction;Condition;NextStep Fill;10;Init;TRUE;;;"Execute=TRUE";20 Fill;20;OpenValve;;;"Valve.Cmd_Open:=TRUE";"Valve.Sts_Opened=TRUE";30 Fill;30;StartPump;;;"Pump.Cmd_Run:=TRUE";"TempSensor.Value>=80.0";40 Fill;40;StopPump;;;"Pump.Cmd_Run:=FALSE";"TRUE";50 Fill;50;CloseValve;;;"Valve.Cmd_Open:=FALSE";"Valve.Sts_Closed=TRUE";60 Fill;60;Done;;TRUE;"Pump.Cmd_Run:=FALSE";"TRUE";
The CSV uses semicolons as separators. Each CmType defines the I/O interface of an equipment module, and each Phase defines a state machine with steps, entry actions, and transition conditions.
Step 2: Load the Design Spec
You can load the CSV in three ways: via the FDS page in the desktop app sidebar, via the REST API, or via the AI copilot's MCP tools. Here is the API method:
curl -X POST http://localhost:9000/api/design-spec/load \ -H "Content-Type: multipart/form-data" \ -F "file=@design-spec.csv"
{
"success": true,
"areas": 1,
"processCells": 1,
"unitTypes": 1,
"cmTypes": 3,
"phases": 1
}Once loaded, the CSV is saved in the .tia-connect/cdc/ folder alongside your TIA project and will be auto-reloaded next time.
Step 3: Explore the Parsed Model
After loading, T-IA Connect parses the CSV into an ISA-88 hierarchy: Area → ProcessCell → UnitType → Control Modules + Phases. You can inspect the result:
# Get the full ISA-88 hierarchy curl http://localhost:9000/api/design-spec/model # List all phases curl http://localhost:9000/api/design-spec/phases
{
"areas": [{
"name": "Area1",
"processCells": [{
"name": "PC1",
"unitTypes": [{
"name": "Unit1",
"cmTypes": [
{ "name": "Valve", "variables": 3 },
{ "name": "Pump", "variables": 3 },
{ "name": "TempSensor", "variables": 2 }
],
"phases": [
{ "name": "Fill", "steps": 6 }
]
}]
}]
}]
}
// GET /api/design-spec/phases
[
{
"name": "Fill",
"steps": ["Init", "OpenValve", "StartPump",
"StopPump", "CloseValve", "Done"]
}
]Step 4: Generate SCL Code
Generate the SCL Function Block for any phase. The generator creates a complete state machine with VAR_INPUT (Execute, Abort, Hold + custom variables), VAR_OUTPUT (Done, Active, Held, Error), and a CASE statement with all steps.
curl -X POST http://localhost:9000/api/design-spec/generate \
-H "Content-Type: application/json" \
-d '{ "phase": "Fill" }'FUNCTION_BLOCK "FB_Fill"
VAR_INPUT
Execute : Bool;
Abort : Bool;
Hold : Bool;
Valve : "UDT_Valve";
Pump : "UDT_Pump";
TempSensor : "UDT_TempSensor";
END_VAR
VAR_OUTPUT
Done : Bool;
Active : Bool;
Held : Bool;
Error : Bool;
END_VAR
VAR
_Step : Int;
_StepEntry : Bool;
END_VAR
BEGIN
CASE #_Step OF
0: // IDLE
IF #Execute THEN
#Active := TRUE;
#_Step := 10;
END_IF;
10: // Init
IF Execute = TRUE THEN
#_Step := 20;
END_IF;
20: // OpenValve
IF #_StepEntry THEN
#Valve.Cmd_Open := TRUE;
END_IF;
IF #Valve.Sts_Opened = TRUE THEN
#_Step := 30;
END_IF;
30: // StartPump
IF #_StepEntry THEN
#Pump.Cmd_Run := TRUE;
END_IF;
IF #TempSensor.Value >= 80.0 THEN
#_Step := 40;
END_IF;
40: // StopPump
IF #_StepEntry THEN
#Pump.Cmd_Run := FALSE;
END_IF;
IF TRUE THEN
#_Step := 50;
END_IF;
50: // CloseValve
IF #_StepEntry THEN
#Valve.Cmd_Open := FALSE;
END_IF;
IF #Valve.Sts_Closed = TRUE THEN
#_Step := 60;
END_IF;
60: // Done
IF #_StepEntry THEN
#Pump.Cmd_Run := FALSE;
END_IF;
#Done := TRUE;
#Active := FALSE;
#_Step := 0;
END_CASE;
// HOLD management
IF #Hold AND #Active THEN
#Held := TRUE;
END_IF;
// ABORT management
IF #Abort AND #Active THEN
#Active := FALSE;
#_Step := 0;
END_IF;
END_FUNCTION_BLOCKStep 5: Import into TIA Portal
The final step generates the SCL, wraps it in SimaticML XML, imports it into TIA Portal, and auto-compiles to validate. All in a single API call:
curl -X POST http://localhost:9000/api/design-spec/generate-and-import \
-H "Content-Type: application/json" \
-d '{ "phase": "Fill", "device": "PLC_1" }'{
"phase": "Fill",
"blockName": "FB_Fill",
"imported": true,
"compiled": true,
"errors": [],
"warnings": 0
}