Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ebpfCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
karaboDevices
ebpfCAT
Commits
fdda3301
Commit
fdda3301
authored
1 year ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
fix the documentation for new argument style
parent
9c1b68cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/ethercat.rst
+24
-19
24 additions, 19 deletions
ebpfcat/ethercat.rst
with
24 additions
and
19 deletions
ebpfcat/ethercat.rst
+
24
−
19
View file @
fdda3301
...
...
@@ -4,31 +4,36 @@ The EtherCAT master
Getting started
---------------
Ethercat terminals are usually connected in a loop with the EtherCAT master
.
The EtherCAT master has to know the order and function of these terminals.
The list of terminals then has to be given in correct order to the constructor
of the EtherCAT master object as follows
::
Ethercat terminals are usually connected in a loop with the EtherCAT master
,
via an ethernet interface. So we create a master object, and connect to that
interface an scan the loop. This takes time, so in a good asyncronous fashion
we need to use await, which can only be done in an async function
::
from ebpfcat.ebpfcat import FastEtherCat
from ebpfcat.terminals import EL4104, Generic
out = EL4104()
unknown = Generic() # use "Generic" for terminals of unknown type
# later, in an async function:
master = FastEtherCat("eth0")
await master.connect()
await master.scan_bus()
Next we create an object for each terminal that we want to use. As an example,
take some Beckhoff output terminal::
master = FastEtherCat("eth0", [out, unknown])
from ebpfcat.terminals import EL4104, Generic
Once we have defined the order of devices, we can connect to the loop and
scan it to actually find all terminals. This takes time, so in a good
asyncronous fashion we need to use await, which can only be done in an
async function::
out = EL4104(master)
await master.connect()
await master.scan_bus()
This terminal needs to be initialized. The initialization method takes two
arguments, the relative position in the loop, starting with 0 for the terminal
directly connected to the interface, counting downwards to negative values. The
second argument is the absolute address this terminal should be assigned to::
await out.initialize(-1, 20) # assign address 20 to the first terminal
The terminals usually control
some
devices, where one terminal may
control
several devices, or one device
is
control
led by
several terminals. The
devices
are represented by `Device` objects. Upon instantiation, they are
connected to
the terminals::
The terminals
are
usually control
led by
devices, where one terminal may
be
controlled by
several devices, or one device control
s
several terminals. The
devices
are represented by `Device` objects. Upon instantiation, they are
connected to
the terminals::
from ebpfcat.devices import AnalogOutput
...
...
@@ -73,7 +78,7 @@ Before they can be used, their `TerminalVar`\ s need to be initialized::
motor.position = encoderTerminal.value
whenever new data is read from the loop, the `update` method of the device is
called, in which one can evaluate the `TerminalVar`\ s::
called, in which one can evaluate the `TerminalVar`\ s
, or set them
::
def update(self):
"""a idiotic speed controller"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment