libecm
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
Open EtherCAT
ethercat.open( )
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 )
Servo ON
ethercat.servo_on( slaves=[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 ) ] )
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()
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
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' )
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 )
Servo ON
ethercat.servo_on( slaves=SLAVES )
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 )
Close EtherCAT
ethercat.servo_off( slaves=SLAVES )
ethercat.close( )
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.
Metadata
Release files for libecm 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| libecm-1.2-cp38-cp38-linux_armv7l.whl | CPython 3.8 | CPython 3.8 | linux armv7l | Details for libecm-1.2-cp38-cp38-linux_armv7l.whl |
| libecm-1.2-cp37-cp37m-linux_armv7l.whl | CPython 3.7 | CPython 3.7 pymalloc | linux armv7l | Details for libecm-1.2-cp37-cp37m-linux_armv7l.whl |
| libecm-1.2-cp36-cp36m-linux_armv7l.whl | CPython 3.6 | CPython 3.6 pymalloc | linux armv7l | Details for libecm-1.2-cp36-cp36m-linux_armv7l.whl |
Total release size: 806.3 kB
Release files / libecm-1.2-cp38-cp38-linux_armv7l.whl
| Download URL | libecm-1.2-cp38-cp38-linux_armv7l.whl |
|---|---|
| Size | 269.3 kB |
| Tags | CPython 3.8 linux armv7l |
|
SHA-256 checksum How to use checksums |
dfd349b1f702d5d3dc55120bcc936c5c5a681182960df9dc06c9677e11a32291
|
|
BLAKE2b-256 checksum How to use checksums |
862c8aa623588c7db424577af57eb863ebf129591da882da75c69fe9b435e981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / libecm-1.2-cp37-cp37m-linux_armv7l.whl
| Download URL | libecm-1.2-cp37-cp37m-linux_armv7l.whl |
|---|---|
| Size | 269.5 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
5d395949a5f579ddb2afe901f6f928d52fc84d116dcbcc6ce4fc15e5e5b891f9
|
|
BLAKE2b-256 checksum How to use checksums |
6647326ddc22657b19d3b5be71b666bde9e166e426a82a31064e0e7354f1d53e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / libecm-1.2-cp36-cp36m-linux_armv7l.whl
| Download URL | libecm-1.2-cp36-cp36m-linux_armv7l.whl |
|---|---|
| Size | 267.4 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
50ada73e64fe67a6a5f4df796db1eb8f190f515b64113ed896f023a27790f4ee
|
|
BLAKE2b-256 checksum How to use checksums |
7d3080a94ede8f0b01a96877adaf18be974207d67ee58a5eb0f2634caec0824a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for libecm 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.