AI SCL generator for TIA Portal
Describe what the block should do and the AI generates SCL code straight into your TIA Portal project: FBs, FCs, DBs and UDTs following your conventions. It compiles the block right away, fixes compile errors and checks that the instructions used exist on your CPU. You review the result and decide what stays in the project.
What the AI SCL generator can do
Generating SCL code is only the start. AI with TIA MCP works directly in the project, so it knows your tags, UDTs and blocks and verifies the result itself by compiling in TIA Portal.
FBs, FCs, DBs and UDTs from a description
From a plain-language description or a specification. The code is stored as an external SCL source, TIA Portal generates the blocks from it and compiles them straight away.
Compiling and fixing errors
The AI receives compile errors and warnings with their location in the code, fixes the source and compiles again until the block passes without errors.
No made-up instructions
Calls are checked against a reference of S7-1200 and S7-1500 system instructions. Unknown functions are flagged with a similar-name suggestion, as are instructions your CPU family does not have.
Your naming conventions
Before writing, the AI reads the project conventions: variable prefixes, languages and libraries. It checks the names and can correct them in a finished block according to the conventions.
LAD, FBD and S7-GRAPH
Besides SCL also LAD and FBD networks with contacts, coils, timers, comparisons and block calls. Sequences as S7-GRAPH with steps, transitions and actions.
State machines
The AI writes a sequence as a CASE in SCL or as S7-GRAPH. From an existing block with a CASE it can create a state diagram for the documentation.
DBs and UDTs from a table
A name-and-type list in CSV becomes a data block in SCL. Structured DBs and UDTs including start values and comments from a description or specification.
Block library
The AI uses master copies from your project or global library and saves a finished block to the library. Modbus TCP and RTU blocks from Benešl Automation are included too.
Unit tests
For an FB or FC it creates a test block from the given inputs and expected outputs and runs it in PLCSIM Advanced.
Example: request and generated SCL code
An illustrative, shortened example. The actual result depends on the project, your conventions and the AI model you choose.
Request: Write an FB for a pump: start and stop, dry-run protection (low level for more than 5 s), contactor feedback check within 2 s and a fault with acknowledgement.
Result (example):
FUNCTION_BLOCK "fbPump"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
iStart : Bool; // start command
iStop : Bool; // stop command
iLevelLow : Bool; // level below dry-run limit
iFeedback : Bool; // contactor feedback
iReset : Bool; // fault acknowledge
END_VAR
VAR_OUTPUT
oRun : Bool; // contactor
oFault : Bool; // fault alarm
END_VAR
VAR
sTonDryRun : TON_TIME;
sTonFeedback : TON_TIME;
END_VAR
BEGIN
// dry-run protection: low level for more than 5 s
#sTonDryRun(IN := #oRun AND #iLevelLow, PT := T#5S);
// no contactor feedback within 2 s
#sTonFeedback(IN := #oRun AND NOT #iFeedback, PT := T#2S);
IF #sTonDryRun.Q OR #sTonFeedback.Q THEN
#oFault := TRUE;
ELSIF #iReset THEN
#oFault := FALSE;
END_IF;
IF #iStop OR #oFault THEN
#oRun := FALSE;
ELSIF #iStart THEN
#oRun := TRUE;
END_IF;
END_FUNCTION_BLOCK
What happens in TIA Portal along the way:
- The AI reads the project conventions and checks the instructions used in the reference (here TON_TIME).
- It stores the SCL source in the project, TIA Portal generates the FB from it and compiles it. A backup is made before the write.
- If the compiler reports an error or warning, the AI fixes the source and compiles again.
- On request it adds the block call with an instance DB, comments and a unit test.
Always check the block logic yourself. The AI is the programmer's assistant, not a replacement for their experience and responsibility.
Not just new blocks
The AI changes code you already have in the project in the same way.
Converting STL to SCL
It converts older STL blocks to SCL and flags the parts that cannot be converted. More on the page about migrating S7-300/400 to S7-1500.
Changing existing blocks
Adding an input to the interface, renaming a variable in all its uses, adding comments to blocks and networks.
Project skeleton from a specification
From an Excel specification it prepares a plan: tags from the I/O list, data types, FBs for motors, valves and analogues, and station DBs. It is written to the project only after your approval.
FAQ about generating SCL with AI
What is an AI SCL generator?
It is an AI assistant (ChatGPT, Claude, Copilot, Gemini or a local model) connected through TIA MCP to the project open in TIA Portal. From a description it creates blocks in SCL, LAD or FBD, writes them into the project and compiles them. It is not a separate program that just prints code into a window.
Which CPUs does it generate code for?
For S7-1500 and S7-1200 in TIA Portal V17 to V21. The instruction check knows both families and warns about instructions the selected CPU does not have.
Doesn't the AI make up functions that don't exist?
That is a common problem with a general chat. TIA MCP therefore checks the code against a reference of S7-1200 and S7-1500 system instructions and against the project's blocks, and every block is compiled in TIA Portal. A non-existent call shows up immediately.
Can I use my own naming conventions?
Yes. The conventions are in a text file that you adapt to your standard. The AI reads them before generating and checks variable names against them.
What if a block with the same name is already in the project?
Before every write the original state is backed up and can be restored with one command. You can switch writing off completely (read-only mode) or approve changes one by one.
Does the SCL generator work offline?
Yes, with a local AI model on your computer (for example Ollama or LM Studio). The project then never leaves your network. With a cloud assistant the AI receives only the data it requests for the task.
How much does it cost?
The SCL generator is part of TIA MCP. A PRO licence costs €295 per year per computer, excluding VAT, and you can try TIA MCP free for the first 7 days.