GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SNS-Automatyk/python-snap7-easy-vars: A Python wrapper for the snap7 PLC communication library with easy variable management

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
snap7_easy_vars
snap7_easy_vars
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
requirements.txt
requirements.txt
 
 
setup.cfg
setup.cfg
 
 

Repository files navigation

Python Snap7 Easy Vars

A Python wrapper for the snap7 PLC communication library with easy variable management. This library simplifies reading and writing variables to Siemens PLCs using snap7 by allowing users to define data structures that map directly to PLC data blocks. It wraps around the python-snap7 library and provides an easy-to-use interface for defining PLC variables, reading from, and writing to the PLC.

Quick Start

Install the package via pip:

pip install python-snap7-easy-vars

Import the library and create a data structure:

import snap7_easy_vars

class MyPLCData(snap7_easy_vars.PLCData):
    # Define PLC variables with their data types and offsets
    temperature = snap7_easy_vars.PLCRealField(byte_offset=0) 
    pressure = snap7_easy_vars.PLCWordField(byte_offset=4)

    # By default, fields are read-only; to make a field settable, use the 'settable' parameter
    status = snap7_easy_vars.PLCBoolField(byte_offset=6, bit_offset=0, settable=True)

Connect to the PLC and read/write data:

my_plc_data = MyPLCData()
my_plc_connection = snap7_easy_vars.PLCConnection(
    ip_address="192.168.0.1", # PLC IP address
    data_store=my_plc_data,
    db_number=1, # PLC DB number
    rack=0, # PLC rack number
    slot=1, # PLC slot number
    port=102, # PLC port number
)

# Connect to the PLC
my_plc_connection.connect()

# Read data from the PLC
my_plc_connection.read()

# Read variables
print(f"Temperature: {my_plc_data.temperature}")
print(f"Pressure: {my_plc_data.pressure}")
print(f"Status: {my_plc_data.status}")

# Modify a variable and write back to the PLC
my_plc_data.status = True
my_plc_connection.write()

Authors

  • Marvin Ruciński

About

A Python wrapper for the snap7 PLC communication library with easy variable management

Topics

plcpythons7-1200s7-plcsnap7

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.