Skip to content
Snippets Groups Projects
Commit 5000b38d authored by Martin Teichmann's avatar Martin Teichmann
Browse files

fix the documentation for new argument style

parent 2cc55efe
No related branches found
No related tags found
No related merge requests found
...@@ -4,31 +4,36 @@ The EtherCAT master ...@@ -4,31 +4,36 @@ The EtherCAT master
Getting started Getting started
--------------- ---------------
Ethercat terminals are usually connected in a loop with the EtherCAT master. 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. via an ethernet interface. So we create a master object, and connect to that
The list of terminals then has to be given in correct order to the constructor interface an scan the loop. This takes time, so in a good asyncronous fashion
of the EtherCAT master object as follows:: we need to use await, which can only be done in an async function::
from ebpfcat.ebpfcat import FastEtherCat from ebpfcat.ebpfcat import FastEtherCat
from ebpfcat.terminals import EL4104, Generic
out = EL4104() # later, in an async function:
unknown = Generic() # use "Generic" for terminals of unknown type 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 out = EL4104(master)
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::
await master.connect() This terminal needs to be initialized. The initialization method takes two
await master.scan_bus() 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 The terminals are usually controlled by devices, where one terminal may be
several devices, or one device is controlled by several terminals. The devices controlled by several devices, or one device controls several terminals. The
are represented by `Device` objects. Upon instantiation, they are connected to devices are represented by `Device` objects. Upon instantiation, they are
the terminals:: connected to the terminals::
from ebpfcat.devices import AnalogOutput from ebpfcat.devices import AnalogOutput
...@@ -73,7 +78,7 @@ Before they can be used, their `TerminalVar`\ s need to be initialized:: ...@@ -73,7 +78,7 @@ Before they can be used, their `TerminalVar`\ s need to be initialized::
motor.position = encoderTerminal.value motor.position = encoderTerminal.value
whenever new data is read from the loop, the `update` method of the device is 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): def update(self):
"""a idiotic speed controller""" """a idiotic speed controller"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment