Skip to main content

Library for NEXTW ECM-SK and ECM-XF Module

Project description

libecm is a library for EtherCAT master ( NEXTW ECM-SK and NEXTW ECM-XF )

Installation

# pip3 install libecm

or

# python3 setup.py build
# python3 setup.py install

After installation you can run unit tests to make sure that the library works fine. Execute

# python3 -m libecm.test.test_csp           # For ECM-SK
# python3 -m libecm.test.test_ecmxf_elmo    # For ECM-XF elmo 8 servo

Usage

In Python 3 ( ECM-SK 12bits )

from libecm import sk12 as ethercat

from libecm.sk12 import WO, WR
from libecm.sk12 import DRIVE, IO
from libecm.sk12 import FREERUN, DCSYNC
from libecm.sk12 import MODE_CSP, MODE_CSV, MODE_CST
from libecm.sk12 import MAX_SLAVES, MAX_CHANNELS, MAX_BYTES
from libecm.sk12 import STATE_INIT, STATE_PRE_OP, STATE_SAFE_OP, STATE_OP

In Python 3 ( ECM-SK 16bits )

from libecm import sk16 as ethercat

from libecm.sk16 import WO, WR
from libecm.sk16 import DRIVE, IO
from libecm.sk16 import FREERUN, DCSYNC
from libecm.sk16 import MODE_CSP, MODE_CSV, MODE_CST
from libecm.sk16 import MAX_SLAVES, MAX_CHANNELS, MAX_BYTES
from libecm.sk16 import STATE_INIT, STATE_PRE_OP, STATE_SAFE_OP, STATE_OP

In Python 3( ECM-XF )

from libecm.ecmxf import ecmxf_library
from libecm.ecmxf import DATA_DEFAULT_SIZE
from libecm.ecmxf import MODE_CSP, MODE_CSV, MODE_CST
from libecm.ecmxf import STATE_INIT, STATE_PRE_OP, STATE_SAFE_OP, STATE_OP

# ELMO SERVO
from libecm.servo.elmo_gold_pdo_mapping import get_rx_pdo_mapping
from libecm.servo.elmo_gold_pdo_mapping import get_tx_pdo_mapping

# UNIVERSAL SERVO
from libecm.servo.universal_pdo_mapping import get_rx_pdo_mapping
from libecm.servo.universal_pdo_mapping import get_tx_pdo_mapping

ECM-SK Example

  1. Open EtherCAT

ethercat.open( )
  1. EtherCAT initial.

ethercat.set_state( STATE_PRE_OP )                # Set EtherCAT state
ethercat.axis( group=0, topology=[ DRIVE ]*8 )    # Return number of slaves.
ethercat.set_dc( 1000 )                           # Cycle Time Unit : us
ethercat.set_mode( slaves=[1], modes=[ MODE_CSP ]*1, types=[ DCSYNC ]*1)
time.sleep( 1 )
ethercat.set_state( STATE_SAFE_OP )
time.sleep( 1 )
ethercat.set_state( STATE_OP )
  1. Servo ON

ethercat.servo_on( slaves=[1] )
  1. CSP, CSV, CST Mode

ethercat.csp( slaves=[1], values=[ int(position) ], rw=WR )
ethercat.csv( slaves=[1], values=[ int(velocity) ], rw=WR )
ethercat.cst( slaves=[1], values=[ int(torque) ],   rw=WR )

ethercat.mixing( [ dict( slaves=1, modes=MODE_CSV, values=0x55555555 ), dict( slaves=2, modes=MODE_CSP, values=0xAAAAAAAA ) ] )
  1. Close EtherCAT

result = ethercat.servo_off( slaves=[1] )    # Return list    """ [ { 'index':0, 'status':0, 'position':0, 'torque':0 }, ]    """
ethercat.set_state( STATE_INIT )
ethercat.close()
  1. Other Functions

ethercat.get_status( )

ethercat.sdo( 1, 0x607A, 0, size=4, alias='Target Position' ).value     # Read SDO
ethercat.sdo( 1, 0x60C2, 1, size=1, alias='Interpolation').value = 125  # Write SDO

ethercat.clear_alarm( slaves=[ 1, 2, 3, 4, 5, 6, 7, 8 ] )
ethercat.go_home( [ 1, 2, 3, 4, 5, 6, 7, 8 ] )
ethercat.abort_home( [ 1, 2, 3, 4, 5, 6, 7, 8 ] )
ethercat.set_ex( 0, 0 ) # Param1 Disable(Enable) Command CRC Verification
                        # Param2 Disable(Enable) Response CRC Verification

ethercat.read_dio( slaves=[ 1, 2, 3, 4, 5, 6, 7, 8 ])
ethercat.write_dio(slaves=[ 1, 2, 3, 4, 5, 6, 7, 8 ], values=[ 0x55, 0x66, 0x77, 8, 9, 10, 11, 12 ] )

ethercat.reset( )   # Module hardware reset
ethercat.reboot( )  # Module software reset
ethercat.ric_io( )  # Read ECM IC DIO
ethercat.wic_io( 0x55555555 ) # Write ECM IC DIO

ECM-XF Example

  1. Open EtherCAT

from libecm.servo.universal_pdo_mapping import get_rx_pdo_mapping
from libecm.servo.universal_pdo_mapping import get_tx_pdo_mapping

COUNT  = 1
SLAVES = [ i for i in range( 0, COUNT ) ]
MODES  = [ MODE_CSV ]

RX_PDO_MAPPING = get_rx_pdo_mapping( MODES )
TX_PDO_MAPPING = get_rx_pdo_mapping( MODES )

ethercat = ecmxf_library( SLAVES, RX_PDO_MAPPING, TX_PDO_MAPPING )
ethercat.open( dev='/dev/spidev0.0' )
  1. EtherCAT initial

ethercat.set_dc( 5000000 )    # ns
ethercat.firmware()           # Get ECMXF firmware version
ethercat.axis( )              # Get slave count
ethercat.set_state( STATE_PRE_OP )
ethercat.reconfig( slaves=SLAVES, rx_mapping=RX_PDO_MAPPING, tx_mapping=TX_PDO_MAPPING )
ethercat.set_mode( slaves=SLAVES, modes=MODES )

ethercat.set_state( STATE_SAFE_OP )
for slave in SLAVES:
  ethercat.align_position( slave=slave, homing=True, position=0 )

ethercat.set_state( STATE_OP )
  1. Servo ON

ethercat.servo_on( slaves=SLAVES )
  1. CSP, CSV, CST Mode

ethercat.mixing( slaves=SLAVES, values=[ 0 ]*COUNT, syntax=False )  # Not monitor FIFO
ethercat.mixing( slaves=SLAVES, values=[ 0 ]*COUNT, syntax=True  )   # monitor FIFO

# Get ECMXF feedback values
ethercat.feedback( slaves=SLAVES )
  1. Close EtherCAT

ethercat.servo_off( slaves=SLAVES )
ethercat.close( )
  1. Other Functions

from libecm.ecmxf import sdo

ethercat.sdo( 1, 0x607A, 0, size=4, alias='Target Position' ).value     # Read SDO
ethercat.sdo( 1, 0x60C2, 1, size=1, alias='Interpolation').value = 125  # Write SDO

ethercat.reset( )   # Module hardware reset
ethercat.reboot( )  # Module software reset

ethercat.show_pdo( slaves=SLAVES, index=0x1C12 )
ethercat.show_pdo( slaves=SLAVES, index=0x1C13 )

ethercat.show_pdo_size()

V1.2 (2021-05-31 dev)

  • New add hardware reset function ( For Raspberry Pi 4B, RESET PIN = WIRINGPI CODE 3 ).

  • Optimized class hexinSigmoid

  • Fixed some bugs.

V1.1 (2021-05-13)

  • New add ECMXF library.

V0.6 (2020-09-28)

  • Optimized code.

Project details


Release history Release notifications | RSS feed

This version

1.2

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

libecm-1.2-cp38-cp38-linux_armv7l.whl (269.3 kB view details)

Uploaded CPython 3.8

libecm-1.2-cp37-cp37m-linux_armv7l.whl (269.5 kB view details)

Uploaded CPython 3.7m

libecm-1.2-cp36-cp36m-linux_armv7l.whl (267.4 kB view details)

Uploaded CPython 3.6m

File details

Details for the file libecm-1.2-cp38-cp38-linux_armv7l.whl.

File metadata

  • Download URL: libecm-1.2-cp38-cp38-linux_armv7l.whl
  • Upload date:
  • Size: 269.3 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.5

File hashes

Hashes for libecm-1.2-cp38-cp38-linux_armv7l.whl
Algorithm Hash digest
SHA256 dfd349b1f702d5d3dc55120bcc936c5c5a681182960df9dc06c9677e11a32291
MD5 cd005cce85de0476c0e6911054d5ebb9
BLAKE2b-256 862c8aa623588c7db424577af57eb863ebf129591da882da75c69fe9b435e981

See more details on using hashes here.

File details

Details for the file libecm-1.2-cp37-cp37m-linux_armv7l.whl.

File metadata

  • Download URL: libecm-1.2-cp37-cp37m-linux_armv7l.whl
  • Upload date:
  • Size: 269.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.5

File hashes

Hashes for libecm-1.2-cp37-cp37m-linux_armv7l.whl
Algorithm Hash digest
SHA256 5d395949a5f579ddb2afe901f6f928d52fc84d116dcbcc6ce4fc15e5e5b891f9
MD5 fee5dceed04f766dbedf38040bc35d6e
BLAKE2b-256 6647326ddc22657b19d3b5be71b666bde9e166e426a82a31064e0e7354f1d53e

See more details on using hashes here.

File details

Details for the file libecm-1.2-cp36-cp36m-linux_armv7l.whl.

File metadata

  • Download URL: libecm-1.2-cp36-cp36m-linux_armv7l.whl
  • Upload date:
  • Size: 267.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.5

File hashes

Hashes for libecm-1.2-cp36-cp36m-linux_armv7l.whl
Algorithm Hash digest
SHA256 50ada73e64fe67a6a5f4df796db1eb8f190f515b64113ed896f023a27790f4ee
MD5 de11a9e43f93e057f6652c30b0fc32cd
BLAKE2b-256 7d3080a94ede8f0b01a96877adaf18be974207d67ee58a5eb0f2634caec0824a

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