Programming examples

Select your interface first: standard Ethernet (ETH) or EtherCAT (ETC).

HDrive17-ETH · Python

Control the drive over standard Ethernet, no PLC needed. Install with pip install hdrive-eth. Source code: python-hdrive17-eth.

Download ETH examples (v1.0 ZIP) GitHub

Quickstart

Position move and telemetry

basic_control.py
from hdrive_eth import HDriveETH
import time

with HDriveETH("192.168.122.102") as motor:
    motor.move_to(90)
    time.sleep(1)
    frame = motor.telemetry
    if frame:
        print(f"Position: {frame.position}, Velocity: {frame.velocity}")

Velocity

Constant speed mode

velocity_mode.py
from hdrive_eth import HDriveETH
import time

with HDriveETH("192.168.122.102") as motor:
    motor.set_speed(speed=500)          # RPM
    time.sleep(2)
    motor.stop()

Torque

Direct torque setpoint (mNm)

torque_mode.py
from hdrive_eth import HDriveETH
import time

with HDriveETH("192.168.122.102") as motor:
    motor.set_torque(torque=200)        # mNm
    time.sleep(1)
    motor.stop()

Object dictionary

Read / write drive objects over TCP

read_object.py
from hdrive_eth import HDriveETH

with HDriveETH("192.168.122.102") as motor:
    version = motor.read_object(index=3, subindex=0)
    print(f"Firmware version: {version}")

Also accessible from C#, C++, Java or Matlab via TCP/UDP/HTTP. The built-in web server allows setup from a browser.