Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

S7-KNX communication gateway

License

NotificationsYou must be signed in to change notification settings

A3KSA/s7-knx

Repository files navigation

IssuesMIT License


Logo

S7-KNX

Gateway for communicating between Siemens S7 PLCs and KNX
·Report Bug ·Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage

About The Project

This project was made to allow interactions between Siemens S7 PLCs and the KNX bus.

(back to top)

Built With

  • NodeJS

(back to top)

Getting Started

Prerequisites

You need NodeJS and NPM to run this project. Tested with node v18.19.0 and v20.11.0 (current LTS)

SeeNodeJS-inst-url

Installation

  1. Clone the repo
    git clone https://github.com/A3KSA/s7-knx.git
  2. Install NPM packages
    npm install
  3. Set up your.env
     KNX_IP=192.168.1.100 KNX_PORT=3671 KNX_ADDRESS=15.15.15 KNX_MIN_DELAY=10 KNX_MANUAL_CONNECT=false DEBUG='s7-knx:*' SEND_AT_START=false S7_READ_INTERVAL=100 S7_IP=10.10.6.159 S7_DB=10 S7_START_OFFSET=2
  4. Set up your S7 project with the given UDT and DB
  5. Start
    npm start
  6. Or with PM2
    pm2 start ecosystem.config.js

(back to top)

Usage

The configuration is made through the env variable. Since this project require dotenv, you can create a .env file with the above variable and it will be imported automatically.

The SEND_AT_START (send actual S7 value directly to the bus at launch) is not currently supported but will be in the future.

For the gateway to work, you need to use the given user data type in the resources folder. You can also find an exemple DB.The DB should always start with an Int specifiyng the DB size.

You can use the following code in your S7 project to update it dynamically :

   AUF   "KNX"   L DBLG   T     "KNX".DB_SIZE

UDT description

You need a row in the PLC's DB for each telegram. For the moment there is a generic UDT and one for the DPT232.

The UDT define the structure with the necessary data and variable for a telegramm to be sent or received.

Generic UDT

LineDescriptionExemple
GAKNX Group Address0107064
TypeKNX Datapoint type1
READ_ONLYIf true, it is not sent to KNXfalse
WRITE_ONLYIf true, it is not read from KNXfalse
SEND_REQRequest sending to KNXtrue
SEND_ACKAcknowledge of the sending requestfalse
val_boolValue from KNX if set to type 1true
val_intInt value from KNX if type 510
val_realReal value from KXN if type 9, 1442.5

UDT for KNX DPT 232 (RGB)

LineDescriptionExemple
GAKNX Group Address0107064
TypeKNX Datapoint type1
READ_ONLYIf true, it is not sent to KNXfalse
WRITE_ONLYIf true, it is not read from KNXfalse
SEND_REQRequest sending to KNXtrue
SEND_ACKAcknowledge of the sending requestfalse
byte_0Red hex valueFF
byte_0Green hex value06
byte_0Blue hex valueAA

Group Address (GA)

The group address in KNX is represented with slash : 01/07/064.The max value for a GA is 15/07/255, in the db it will be represented as 1507255.Always add the missings 0 so the gateway know how to translate the main/middle/sub value (00/00/000).

SEND_REQ and SEND_ACK

Setting the SEND_REQ to true will tell the gateway to send the value to KNX even if the value asn't changed.The gateway then set SEND_ACK to true to tell the PLC it was sent. It is the PLC responsability to set those two flags to false at the next cycle.

Data type and conversion

DatapointKNX sizeKNX TypeS7 EquivalentS7 SizeTypeSupported
DPT11 bitUp/Down...Bool1 bit1Yes
DPT21 bitControlBool1 bit1Yes
DPT34 bitdimming/blind8 bitNo
DPT48 bitCharacter8 bitNo
DPT58 bit UIntUnsigned valueUInt16 bit5Yes*
DPT68 bit IntSigned valueInt16 bitNo
DPT716 bit UIntUnsigned valueUInt16 bitNo
DPT816 bit IntSigned valueInt16 bitNo
DPT916 bit floatFloatReal32 bit9Yes*
DPT1024 bit timeTimeDWord32 bitNo
DPT1124 bit dateDateDWord32 bitNo
DPT1232 bit UIntUnsigned valueUDint32 bitNo
DPT1332 bit IntSigned valueDInt32 bit13Yes
DPT1432 bit floatFloatReal32 bit14Yes
DPT1532 bitUnsigned valueUDInt32 bitNo
DPT1614 byte14 char stringString640 bitNo
DPT178 bit UIntScene number8 bitNo
DPT188 bit UIntScene control8 bitNo
DPT198 byte date & timeDate and timeLWordNo
DPT2323 byteRGB3 byte232Yes
  • The value from the PLC should not exceed the size of the KNX DPT.

Since a complete word is used in the PLC for each variable, we will store them in a full word for simplicity.A feature to cap the max value in the gateway to prevent error should be added in the next version.

(back to top)

Roadmap

  • Add support for multiple KNX connection
  • Add the SEND_AT_START feature
  • Limit value that could be out of range and throw necessary message
  • Add new type
  • Improve logging (debug, trace, info...)

See theopen issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. SeeLICENSE.txt for more information.

(back to top)

Contact

Zacharie Monnet -zacharie.monnet@automation3000.ch

Project Link:https://github.com/A3KSA/s7-knx

(back to top)


[8]ページ先頭

©2009-2025 Movatter.jp