Skip to content

Example

Vita edited this page Nov 2, 2022 · 1 revision

Switch and light in TIA

Thanks to gertjanlobbens

User program in TIA Portal

Create a new FB (FB_Flip_Flop) At the top u define 1 input (In, Bool), 1 InOut (Out, Bool) and 2 statics (Flank, Bool and Memory, Bool). We only need 2 networks to make this work. The image below shows the entire config for the block.

image

Call the FB in your program and fill in the in and output parameters:

image

Download the program to your PLC.

OpenHAB configuration

Create a Simatic Bridge, fill in your plc's ip-address. Rack will be always 0 (except for S7-400), slot depends on the type of plc (S7-1200 = 1, S7-300 = 2, ...).

Create a Simatic Thing, in the config fill in the bridge u just made. On the top go to Channels and click on 'Add Channel' Give the channel a name and choose On/Off Switch. For the state address and command address fill in the output of the plc (Q0.0). Click create. Click on Add Link to Item... , choose 'Create a new item' and click Link.

You should now have a channel and an item linked to it:

image

On your OpenHab page you can now add a toggle card and choose the item you just created.

This is one of the most simple methods to switch a light with OpenHab and a Siemens PLC. I know there are many more options to do this but once you get the concept of it you can do almost anything you like.

On a side note

If you use DB's in your plc (S7-1200 / S7-1500) and like to connect to the items in it you MUST turn off 'optimized access' in the properties of the block!

Right click the DB and go to properties. Under attributes deactivate 'Optimized block acces'.

image

image

The X in DB200.DBX0.0 stands for a boolean (0 or 1) value. for number values u use: B (byte -> DB200.DBB0) W (word or integer -> DB200.DBW0) D (dword or dint or real -> DB200.DBD0) For real (also called floating points) you have to put an F in the address in OpenHab -> DB200.DBD0F

Hope this helps someone :-)

Clone this wiki locally