Skip to content

eliasrhoden/tia-statemachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

State machine generation for Siemens TIA-Portal

A python library for generation of state-machine template Function Blocks for Siemens TIA-Portal.

This library makes it possible to start with the design documentation and generate the code from it. I always find that when I start with a rough outline (documentation) of what I want to do, the code usualy turns out better, this library is to support that kind of workflow.

Workflow

  1. Design the state machine with Events, that have a source state, destination state and transition name.
  2. Verify that the generated state diagram reflects the desired behaviour.
  3. Generate Simatic-ML file and import into TIA
  4. Add your input/output signals and connect them to states or trigger transitions.

Example

import graph2LAD
from graph2LAD import Event


events = [Event('INIT','GOTO_HOME','init to home'),
        Event('GOTO_HOME','AT_HOME_POS','Reached home pos'),
        Event('AT_HOME_POS','LOADING','Start loading'),
        Event('LOADING','WORKING','Loading completed'),
        Event('WORKING','UNLOADING','Work complete'),
        Event('UNLOADING','AT_HOME_POS','Unloading complete'),
        Event('INIT','UNLOADING','Direct unloading')]


graph2LAD.render_graph(events,init_state='INIT',fname='demo')
graph2LAD.export_graph(events,'INIT','DemoSchrittKette','demo_FB',45)

State diagram

Import into TIA

Interface of generated FB

State networks in generated FB

Last network, the static variables statStepand statNextStepensures that we remain in each state for at least 1 PLC cycle.

Installation

  1. Install GraphViz https://graphviz.org/
  2. pip install graphviz
  3. TIA Export/Import Add-in (https://support.industry.siemens.com/cs/document/109773999/tia-add-ins?dti=0&lc=en-SE)

About

Generation of state machines for Siemens TIA Portal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages