Skip to main content

Python package source for KELLER protocol

Project description

keller-protocol - The KELLER Protocol (Python)

General Pre-requirement:

  • A KELLER device is needed that can communicate with the Serial Port.
  • ...with a USB-COM converter cable (eg.K114 series) AND the needed FTDI driver (https://www.ftdichip.com/Drivers/VCP.htm)
  • ...or directly with a cable of the K-10X series

Installation

pip install keller-protocol
See https://pypi.org/project/keller-protocol/

Usage

See https://keller-druck.com/en/downloads?categories=Software.Communication-Protocols for the Communication Protocol.

  1. Import the Keller Protocol (keller_protocol.py) in your Python Project:
from keller_protocol import keller_protocol as kp
  1. Define Communication settings like port, baud-rate (Default 9600), timeout (Default 0.3s) and echo (Default True):
transmitter = kp.KellerProtocol(
    port="COM17", baud_rate=9600, timeout=0.3, echo=True
)
  1. To be able to communicate with the transmitter you will have to use F48 first to initialize. Otherwise, an exception occurs. F48 will return the firmware version. Make sure the device address is correct. (Default 1). If only one transmitter is connected, you can use the "transparent" address 250.
device_address = 1
firmware = transmitter.f48(device_address)
  1. Read out current pressure value from the transmitter. You will receive the pressure value P1 with channel 1.
p1 = transmitter.f73(device_address, 1)

Usage Example with X Line

import keller_protocol.keller_protocol as kp
import time


class XLine:
    def __init__(self, port, baud_rate, address, timeout, echo=True):
        self.bus = kp.KellerProtocol(port, baud_rate, timeout, echo)
        self.address = address
        self.serial_number = None
        self.f73_channels = {
            "CH0": 0,
            "P1": 1,
            "P2": 2,
            "T": 3,
            "TOB1": 4,
            "TOB2": 5,
            "ConTc": 10,
            "ConRaw": 11,
        }
        self.init_f48()

    def init_f48(self) -> str:
        """Initialise and release"""
        answer = self.bus.f48(self.address)
        print(f" Init of Device Address: {self.address} with Firmware: {answer}")

    def get_serial(self) -> int:
        """Get Serial Number from X-Line

        :returns Serial Number
        """
        self.serial_number = self.bus.f69(self.address)
        return self.serial_number

    def get_address(self) -> int:
        return self.address

    def set_address(self, new_address: int) -> int:
        """Change the Device address. -> Has to be unique on the RS485 bus

        :param new_address: New address of the Device
        :return: If successful return new_address otherwise old address and throw exception
        """
        self.address = self.bus.f66(self.address, new_address)
        return self.address

    def measure_tob1(self) -> float:
        """Get temperature TOB1

        :return: temperature
        """
        temperature = self.bus.f73(self.address, self.f73_channels["TOB1"])
        return temperature

    def measure_p1(self) -> float:
        """Get pressure P1

        :return: pressure
        """
        pressure = self.bus.f73(self.address, self.f73_channels["P1"])
        return pressure


if __name__ == "__main__":
    # Example usage:
    # Init transmitter
    transmitter = XLine(
        port="COM17", baud_rate=9600, address=1, timeout=0.3, echo=True
    )
    serial_number = transmitter.get_serial()
    print(f"Transmitter serial number:{serial_number}")
    print("Press CTRL + C to quit")
    while True:
        try:
            p1 = transmitter.measure_p1()
            tob1 = transmitter.measure_tob1()
            print(f"Pressure P1:{p1:.3f} Temperature TOB1:{tob1:.3f}")
            time.sleep(1)
        except KeyboardInterrupt:
            print("Quit!")
            break

Code style: black Upload Python Package License: MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keller_protocol-1.0.22.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keller_protocol-1.0.22-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file keller_protocol-1.0.22.tar.gz.

File metadata

  • Download URL: keller_protocol-1.0.22.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for keller_protocol-1.0.22.tar.gz
Algorithm Hash digest
SHA256 ddaea87f85569a08187ed891f3a0b91b32321f6234b4cecebc2341576ab7f9b1
MD5 f77b53842cf5e2c40a3624a7e6b84e64
BLAKE2b-256 258b459ae14b4f7fd8b37d711234675e53340e3ac289fe5ad02c652de164d79f

See more details on using hashes here.

File details

Details for the file keller_protocol-1.0.22-py3-none-any.whl.

File metadata

File hashes

Hashes for keller_protocol-1.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 3435e883550f6861d5a0d9aea808435d82e7f6960328b9e59a51c71770acd1ab
MD5 41af7eb9a9583deb3717dfb9170039fc
BLAKE2b-256 eeb012287b0012ede3e18bccf8685f9e68bef15a220846e77c35754f1717b68a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page