201 \item The master code supports any Linux realtime extension through its |
201 \item The master code supports any Linux realtime extension through its |
202 independent architecture. |
202 independent architecture. |
203 |
203 |
204 \begin{itemize} |
204 \begin{itemize} |
205 |
205 |
206 \item RTAI\nomenclature{RTAI}{Realtime Application Interface} \cite{rtai}, |
206 \item RTAI\nomenclature{RTAI}{Realtime Application Interface} \cite{rtai} |
207 ADEOS\nomenclature{ADEOS}{Adaptive Domain Environment for Operating |
207 (including LXRT via RTDM), ADEOS\nomenclature{ADEOS}{Adaptive Domain |
208 Systems}, RT-Preempt \cite{rt-preempt}, etc. |
208 Environment for Operating Systems}, RT-Preempt \cite{rt-preempt}, Xenomai |
|
209 (including RTDM), etc. |
209 |
210 |
210 \item It runs well even without realtime extensions. |
211 \item It runs well even without realtime extensions. |
211 |
212 |
212 \end{itemize} |
213 \end{itemize} |
213 |
214 |
214 \item Common ``Application Interface'' for applications, that want to use |
215 \item Common ``Application Interface'' for applications, that want to use |
215 EtherCAT functionality (see chap.~\ref{chap:api}). |
216 EtherCAT functionality (see \autoref{chap:api}). |
216 |
217 |
217 \item \textit{Domains} are introduced, to allow grouping of process |
218 \item \textit{Domains} are introduced, to allow grouping of process |
218 data transfers with different slave groups and task periods. |
219 data transfers with different slave groups and task periods. |
219 |
220 |
220 \begin{itemize} |
221 \begin{itemize} |
354 Public License (GPL \cite{gpl})\index{GPL}, version 2. Other developers, that |
358 Public License (GPL \cite{gpl})\index{GPL}, version 2. Other developers, that |
355 want to use EtherCAT with Linux systems, are invited to use the master code or |
359 want to use EtherCAT with Linux systems, are invited to use the master code or |
356 even participate on development. |
360 even participate on development. |
357 |
361 |
358 To allow static linking of userspace application against the master's |
362 To allow static linking of userspace application against the master's |
359 application interface (see chap.~\ref{chap:api}), the userspace library (see |
363 application interface (see \autoref{chap:api}), the userspace library (see |
360 sec.~\ref{sec:userlib}) is licensed under the terms and conditions of the GNU |
364 \autoref{sec:userlib}) is licensed under the terms and conditions of the GNU |
361 Lesser General Public License (LGPL \cite{lgpl})\index{LGPL}, version 2.1. |
365 Lesser General Public License (LGPL \cite{lgpl})\index{LGPL}, version 2.1. |
362 |
366 |
363 %------------------------------------------------------------------------------ |
367 %------------------------------------------------------------------------------ |
364 |
368 |
365 \chapter{Architecture} |
369 \chapter{Architecture} |
366 \label{chap:arch} |
370 \label{chap:arch} |
367 \index{Master!Architecture} |
371 \index{Master!Architecture} |
368 |
372 |
369 The EtherCAT master is integrated into the Linux 2.6 kernel. This was |
373 The EtherCAT master is integrated into the Linux kernel. This was an early |
370 an early design decision, which has been made for several reasons: |
374 design decision, which has been made for several reasons: |
371 |
375 |
372 \begin{itemize} |
376 \begin{itemize} |
373 |
377 |
374 \item Kernel code has significantly better realtime characteristics, i.\,e.\ |
378 \item Kernel code has significantly better realtime characteristics, i.\,e.\ |
375 less latency than userspace code. It was foreseeable, that a fieldbus master |
379 less latency than userspace code. It was foreseeable, that a fieldbus master |
397 The components of the master environment are described below: |
401 The components of the master environment are described below: |
398 |
402 |
399 \begin{description} |
403 \begin{description} |
400 |
404 |
401 \item[Master Module]\index{Master Module} Kernel module containing one or more |
405 \item[Master Module]\index{Master Module} Kernel module containing one or more |
402 EtherCAT master instances (see sec.~\ref{sec:mastermod}), the ``Device |
406 EtherCAT master instances (see \autoref{sec:mastermod}), the ``Device |
403 Interface'' (see sec.~\ref{sec:ecdev}) and the ``Application Interface'' (see |
407 Interface'' (see \autoref{sec:ecdev}) and the ``Application Interface'' (see |
404 chap.~\ref{chap:api}). |
408 \autoref{chap:api}). |
405 |
409 |
406 \item[Device Modules]\index{Device modules} EtherCAT-capable Ethernet device |
410 \item[Device Modules]\index{Device modules} EtherCAT-capable Ethernet device |
407 driver modules\index{Device modules}, that offer their devices to the EtherCAT |
411 driver modules\index{Device modules}, that offer their devices to the EtherCAT |
408 master via the device interface (see sec.~\ref{sec:ecdev}). These modified |
412 master via the device interface (see \autoref{sec:ecdev}). These modified |
409 network drivers can handle network devices used for EtherCAT operation and |
413 network drivers can handle network devices used for EtherCAT operation and |
410 ``normal'' Ethernet devices in parallel. A master can accept a certain device |
414 ``normal'' Ethernet devices in parallel. A master can accept a certain device |
411 and then is able to send and receive EtherCAT frames. Ethernet devices |
415 and then is able to send and receive EtherCAT frames. Ethernet devices |
412 declined by the master module are connected to the kernel's network stack as |
416 declined by the master module are connected to the kernel's network stack as |
413 usual. |
417 usual. |
414 |
418 |
415 \item[Application]\index{Application} A program that uses the EtherCAT master |
419 \item[Application]\index{Application} A program that uses the EtherCAT master |
416 (usually for cyclic exchange of process data with EtherCAT slaves). These |
420 (usually for cyclic exchange of process data with EtherCAT slaves). These |
417 programs are not part of the EtherCAT master code\footnote{Although there are |
421 programs are not part of the EtherCAT master code\footnote{Although there are |
418 some examples provided in the \textit{examples/} directory.}, but have to be |
422 some examples provided in the \textit{examples/} directory.}, but have to be |
419 generated or written by the user. An application can ``request'' a master |
423 generated or written by the user. An application can request a master through |
420 through the application interface (see chap.~\ref{chap:api}). If this |
424 the application interface (see \autoref{chap:api}). If this succeeds, it has |
421 succeeds, it has the control over the master: It can provide a bus |
425 the control over the master: It can provide a bus configuration and exchange |
422 configuration and exchange process data. Applications can be kernel modules |
426 process data. Applications can be kernel modules (that use the kernel |
423 (that use the kernel application interface directly) or userspace programs, |
427 application interface directly) or userspace programs, that use the |
424 that use the application interface via the EtherCAT library (see |
428 application interface via the EtherCAT library (see \autoref{sec:userlib}), or |
425 sec.~\ref{sec:userlib}). |
429 the RTDM library (see~\autoref{sec:rtdm}). |
426 |
430 |
427 \end{description} |
431 \end{description} |
428 |
432 |
429 %------------------------------------------------------------------------------ |
433 %------------------------------------------------------------------------------ |
430 |
434 |
431 \section{Master Module} |
435 \section{Master Module} |
432 \label{sec:mastermod} |
436 \label{sec:mastermod} |
433 \index{Master module} |
437 \index{Master module} |
434 |
438 |
435 The EtherCAT master kernel module \textit{ec\_master} can contain multiple |
439 The EtherCAT master kernel module \textit{ec\_master} can contain multiple |
436 master instances. Each master waits for a certain Ethernet device identified |
440 master instances. Each master waits for certain Ethernet device(s) identified |
437 by its MAC address\index{MAC address}. These addresses have to be specified on |
441 by its MAC address(es)\index{MAC address}. These addresses have to be |
438 module loading via the \textit{main\_devices} module parameter. The number of |
442 specified on module loading via the \textit{main\_devices} (and optional: |
439 master instances to initialize is taken from the number of MAC addresses |
443 \textit{backup\_devices}) module parameter. The number of master instances to |
440 given. |
444 initialize is taken from the number of MAC addresses given. |
441 |
445 |
442 The below command loads the master module with a single master instance that |
446 The below command loads the master module with a single master instance that |
443 waits for the Ethernet device with the MAC address |
447 waits for one Ethernet device with the MAC address |
444 \lstinline+00:0E:0C:DA:A2:20+. The master will be accessible via index $0$. |
448 \lstinline+00:0E:0C:DA:A2:20+. The master will be accessible via index $0$. |
445 |
449 |
446 \begin{lstlisting} |
450 \begin{lstlisting} |
447 # `\textbf{modprobe ec\_master main\_devices=00:0E:0C:DA:A2:20}` |
451 # `\textbf{modprobe ec\_master main\_devices=00:0E:0C:DA:A2:20}` |
448 \end{lstlisting} |
452 \end{lstlisting} |
467 \label{fig:masters} |
471 \label{fig:masters} |
468 \end{figure} |
472 \end{figure} |
469 |
473 |
470 \paragraph{Debug Level} The master module also has a parameter |
474 \paragraph{Debug Level} The master module also has a parameter |
471 \textit{debug\_level} to set the initial debug level for all masters (see |
475 \textit{debug\_level} to set the initial debug level for all masters (see |
472 also~\ref{sec:ethercat-debug}). |
476 also~\autoref{sec:ethercat-debug}). |
473 |
477 |
474 \paragraph{Init Script} |
478 \paragraph{Init Script} |
475 \index{Init script} |
479 \index{Init script} |
476 |
480 |
477 In most cases it is not necessary to load the master module and the Ethernet |
481 In most cases it is not necessary to load the master module and the Ethernet |
478 driver modules manually. There is an init script available, so the master can |
482 driver modules manually. There is an init script available, so the master can |
479 be started as a service (see sec.~\ref{sec:system}). |
483 be started as a service (see \autoref{sec:system}). For systems that are |
|
484 managed by systemd \cite{systemd}, there is also a service file available. |
480 |
485 |
481 \paragraph{Syslog} |
486 \paragraph{Syslog} |
482 |
487 |
483 The master module outputs information about its state and events to the kernel |
488 The master module outputs information about its state and events to the kernel |
484 ring buffer. These also end up in the system logs. The above module loading |
489 ring buffer. These also end up in the system logs. The above module loading |
485 command should result in the messages below: |
490 command should result in the messages below: |
486 |
491 |
487 \begin{lstlisting} |
492 \begin{lstlisting} |
488 # `\textbf{dmesg | tail -2}` |
493 # `\textbf{dmesg | tail -2}` |
489 EtherCAT: Master driver `\masterversion` |
494 EtherCAT: Master driver `\masterversion` |
493 Jul 4 10:22:45 ethercat kernel: EtherCAT: Master driver `\masterversion` |
498 Jul 4 10:22:45 ethercat kernel: EtherCAT: Master driver `\masterversion` |
494 Jul 4 10:22:45 ethercat kernel: EtherCAT: 2 masters waiting |
499 Jul 4 10:22:45 ethercat kernel: EtherCAT: 2 masters waiting |
495 for devices. |
500 for devices. |
496 \end{lstlisting} |
501 \end{lstlisting} |
497 |
502 |
498 All EtherCAT master output is prefixed with \lstinline+EtherCAT+ which makes |
503 Master output is prefixed with \lstinline+EtherCAT+ which makes searching the |
499 searching the logs easier. |
504 logs easier. |
500 |
505 |
501 %------------------------------------------------------------------------------ |
506 %------------------------------------------------------------------------------ |
502 |
507 |
503 \section{Master Phases} |
508 \section{Master Phases} |
504 \index{Master phases} |
509 \index{Master phases} |
505 |
510 |
506 Every EtherCAT master provided by the master module (see |
511 Every EtherCAT master provided by the master module (see |
507 sec.~\ref{sec:mastermod}) runs through several phases (see |
512 \autoref{sec:mastermod}) runs through several phases (see |
508 fig.~\ref{fig:phases}): |
513 \autoref{fig:phases}): |
509 |
514 |
510 \begin{figure}[htbp] |
515 \begin{figure}[htbp] |
511 \centering |
516 \centering |
512 \includegraphics[width=.9\textwidth]{images/phases} |
517 \includegraphics[width=.9\textwidth]{images/phases} |
513 \caption{Master phases and transitions} |
518 \caption{Master phases and transitions} |
515 \end{figure} |
520 \end{figure} |
516 |
521 |
517 \begin{description} |
522 \begin{description} |
518 |
523 |
519 \item[Orphaned phase]\index{Orphaned phase} This mode takes effect, when the |
524 \item[Orphaned phase]\index{Orphaned phase} This mode takes effect, when the |
520 master still waits for its Ethernet device to connect. No bus communication is |
525 master still waits for its Ethernet device(s) to connect. No bus communication |
521 possible until then. |
526 is possible until then. |
522 |
527 |
523 \item[Idle phase]\index{Idle phase} takes effect when the master has accepted |
528 \item[Idle phase]\index{Idle phase} takes effect when the master has accepted |
524 an Ethernet device, but is not requested by any application yet. The master |
529 all required Ethernet devices, but is not requested by any application yet. |
525 runs its state machine (see sec.~\ref{sec:fsm-master}), that automatically |
530 The master runs its state machine (see \autoref{sec:fsm-master}), that |
526 scans the bus for slaves and executes pending operations from the userspace |
531 automatically scans the bus for slaves and executes pending operations from |
527 interface (for example SDO access). The command-line tool can be used to |
532 the userspace interface (for example SDO access). The command-line tool can be |
528 access the bus, but there is no process data exchange because of the missing |
533 used to access the bus, but there is no process data exchange because of the |
529 bus configuration. |
534 missing bus configuration. |
530 |
535 |
531 \item[Operation phase]\index{Operation phase} The master is requested by an |
536 \item[Operation phase]\index{Operation phase} The master is requested by an |
532 application that can provide a bus configuration and exchange process data. |
537 application that can provide a bus configuration and exchange process data. |
533 |
538 |
534 \end{description} |
539 \end{description} |
544 \paragraph{Process Data Image} |
549 \paragraph{Process Data Image} |
545 \index{Process data} |
550 \index{Process data} |
546 |
551 |
547 Slaves offer their inputs and outputs by presenting the master so-called |
552 Slaves offer their inputs and outputs by presenting the master so-called |
548 ``Process Data Objects'' (PDOs\index{PDO}). The available PDOs can be either |
553 ``Process Data Objects'' (PDOs\index{PDO}). The available PDOs can be either |
549 determined by reading out the slave's TXPDO and RXPDO SII categories from the |
554 determined by reading out the slave's TxPDO and RxPDO SII categories from the |
550 E$^2$PROM (in case of fixed PDOs) or by reading out the appropriate CoE |
555 E$^2$PROM (in case of fixed PDOs) or by reading out the appropriate CoE |
551 objects (see sec.~\ref{sec:coe}), if available. The application can register |
556 objects (see \autoref{sec:coe}), if available. The application can register |
552 the PDOs' entries for exchange during cyclic operation. The sum of all |
557 the PDOs' entries for exchange during cyclic operation. The sum of all |
553 registered PDO entries defines the ``process data image'', which is exchanged |
558 registered PDO entries defines the ``process data image'', which is exchanged |
554 via datagrams with ``logical'' memory access (like LWR, LRD or LRW) introduced |
559 via datagrams with ``logical'' memory access (like LWR, LRD or LRW) introduced |
555 in~\cite[sec.~5.4]{dlspec}. |
560 in~\cite[sec.~5.4]{dlspec}. |
556 |
561 |
637 The application interface provides functions and data structures for |
642 The application interface provides functions and data structures for |
638 applications to access an EtherCAT master. The complete documentation of the |
643 applications to access an EtherCAT master. The complete documentation of the |
639 interface is included as Doxygen~\cite{doxygen} comments in the header file |
644 interface is included as Doxygen~\cite{doxygen} comments in the header file |
640 \textit{include/ecrt.h}. It can either be read directly from the file |
645 \textit{include/ecrt.h}. It can either be read directly from the file |
641 comments, or as a more comfortable HTML documentation. The HTML generation is |
646 comments, or as a more comfortable HTML documentation. The HTML generation is |
642 described in sec.~\ref{sec:gendoc}. |
647 described in \autoref{sec:gendoc}. |
643 |
648 |
644 The following sections cover a general description of the application |
649 The following sections cover a general description of the application |
645 interface. |
650 interface. |
646 |
651 |
647 Every application should use the master in two steps: |
652 Every application should use the master in two steps: |
648 |
653 |
649 \begin{description} |
654 \begin{description} |
650 |
655 |
651 \item[Configuration] The master is requested and the configuration is applied. |
656 \item[Configuration] The master is requested and the configuration is applied. |
652 For example, domains are created, slaves are configured and PDO entries are |
657 For example, domains are created, slaves are configured and PDO entries are |
653 registered (see sec.~\ref{sec:masterconfig}). |
658 registered (see \autoref{sec:masterconfig}). |
654 |
659 |
655 \item[Operation] Cyclic code is run and process data are exchanged (see |
660 \item[Operation] Cyclic code is run and process data are exchanged (see |
656 sec.~\ref{sec:cyclic}). |
661 \autoref{sec:cyclic}). |
657 |
662 |
658 \end{description} |
663 \end{description} |
659 |
664 |
660 \paragraph{Example Applications}\index{Example Applications} There are a few |
665 \paragraph{Example Applications}\index{Example Applications} There are a few |
661 example applications in the \textit{examples/} subdirectory of the master |
666 example applications in the \textit{examples/} subdirectory of the master |
688 with the given vendor id and product code at the given position. If this is |
693 with the given vendor id and product code at the given position. If this is |
689 the case, the slave configuration is ``attached'' to the real slave on the bus |
694 the case, the slave configuration is ``attached'' to the real slave on the bus |
690 and the slave is configured according to the settings provided by the |
695 and the slave is configured according to the settings provided by the |
691 application. The state of a slave configuration can either be queried via the |
696 application. The state of a slave configuration can either be queried via the |
692 application interface or via the command-line tool (see |
697 application interface or via the command-line tool (see |
693 sec.~\ref{sec:ethercat-config}). |
698 \autoref{sec:ethercat-config}). |
694 |
699 |
695 \paragraph{Slave Position} The slave position has to be specified as a tuple |
700 \paragraph{Slave Position} The slave position has to be specified as a tuple |
696 of ``alias'' and ``position''. This allows addressing slaves either via an |
701 of ``alias'' and ``position''. This allows addressing slaves either via an |
697 absolute bus position, or a stored identifier called ``alias'', or a mixture |
702 absolute bus position, or a stored identifier called ``alias'', or a mixture |
698 of both. The alias is a 16-bit value stored in the slave's E$^2$PROM. It can |
703 of both. The alias is a 16-bit value stored in the slave's E$^2$PROM. It can |
699 be modified via the command-line tool (see sec.~\ref{sec:ethercat-alias}). |
704 be modified via the command-line tool (see \autoref{sec:ethercat-alias}). |
700 Table~\ref{tab:slaveposition} shows, how the values are interpreted. |
705 \autoref{tab:slaveposition} shows, how the values are interpreted. |
701 |
706 |
702 \begin{table}[htbp] |
707 \begin{table}[htbp] |
703 \centering |
708 \centering |
704 \caption{Specifying a Slave Position} |
709 \caption{Specifying a Slave Position} |
705 \label{tab:slaveposition} |
710 \label{tab:slaveposition} |
751 \item Slave 2 is again the first slave with the alias \lstinline+0x2000+, but |
756 \item Slave 2 is again the first slave with the alias \lstinline+0x2000+, but |
752 position is now 1, so slave 3 is attached. |
757 position is now 1, so slave 3 is attached. |
753 |
758 |
754 \end{enumerate} |
759 \end{enumerate} |
755 |
760 |
|
761 If the master sources are configured with \lstinline+--enable-wildcards+, then |
|
762 \lstinline+0xffffffff+ matches every vendor ID and/or product code. |
|
763 |
756 %------------------------------------------------------------------------------ |
764 %------------------------------------------------------------------------------ |
757 |
765 |
758 \section{Cyclic Operation} |
766 \section{Cyclic Operation} |
759 \label{sec:cyclic} |
767 \label{sec:cyclic} |
760 |
768 |
761 |
769 |
762 To enter cyclic operation mode, the master has to be ``activated'' to |
770 To enter cyclic operation mode, the master has to be ``activated'' to |
763 calculate the process data image and apply the bus configuration for the first |
771 calculate the process data image and apply the bus configuration for the first |
764 time. After activation, the application is in charge to send and receive |
772 time. After activation, the application is in charge to send and receive |
765 frames. |
773 frames. The configuration can not be changed after activation. |
766 |
774 |
767 % TODO |
775 % TODO |
768 % |
776 % |
769 % PDO endianess |
777 % PDO endianess |
770 % Datagram injection |
778 % Datagram injection |
805 \index{Concurrency} |
813 \index{Concurrency} |
806 |
814 |
807 In some cases, one master is used by several instances, for example when an |
815 In some cases, one master is used by several instances, for example when an |
808 application does cyclic process data exchange, and there are EoE-capable |
816 application does cyclic process data exchange, and there are EoE-capable |
809 slaves that require to exchange Ethernet data with the kernel (see |
817 slaves that require to exchange Ethernet data with the kernel (see |
810 sec.~\ref{sec:eoe}). For this reason, the master is a shared resource, and |
818 \autoref{sec:eoe}). For this reason, the master is a shared resource, and |
811 access to it has to be sequentialized. This is usually done by locking with |
819 access to it has to be sequentialized. This is usually done by locking with |
812 semaphores, or other methods to protect critical sections. |
820 semaphores, or other methods to protect critical sections. |
813 |
821 |
814 The master itself can not provide locking mechanisms, because it has no chance |
822 The master itself can not provide locking mechanisms, because it has no chance |
815 to know the appropriate kind of lock. For example if the application is in |
823 to know the appropriate kind of lock. For example if the application is in |
827 \includegraphics[width=.6\textwidth]{images/master-locks} |
835 \includegraphics[width=.6\textwidth]{images/master-locks} |
828 \caption{Concurrent Master Access} |
836 \caption{Concurrent Master Access} |
829 \label{fig:locks} |
837 \label{fig:locks} |
830 \end{figure} |
838 \end{figure} |
831 |
839 |
832 Figure~\ref{fig:locks} exemplary shows, how two processes share one master: |
840 \autoref{fig:locks} exemplary shows, how two processes share one master: |
833 The application's cyclic task uses the master for process data exchange, while |
841 The application's cyclic task uses the master for process data exchange, while |
834 the master-internal EoE process uses it to communicate with EoE-capable |
842 the master-internal EoE process uses it to communicate with EoE-capable |
835 slaves. Both have to access the bus from time to time, but the EoE process |
843 slaves. Both have to access the bus from time to time, but the EoE process |
836 does this by ``asking'' the application to do the bus access for it. In this |
844 does this by ``asking'' the application to do the bus access for it. In this |
837 way, the application can use the appropriate locking mechanism to avoid |
845 way, the application can use the appropriate locking mechanism to avoid |
838 accessing the bus at the same time. See the application interface |
846 accessing the bus at the same time. See the application interface |
839 documentation (chap.~\ref{chap:api}) for how to use these callbacks. |
847 documentation (\autoref{chap:api}) for how to use these callbacks. |
840 |
848 |
841 %------------------------------------------------------------------------------ |
849 %------------------------------------------------------------------------------ |
842 |
850 |
843 \section{Distributed Clocks} |
851 \section{Distributed Clocks} |
844 \label{sec:dc} |
852 \label{sec:dc} |
924 latched and stored in a receive time register once the frame is received on |
932 latched and stored in a receive time register once the frame is received on |
925 the corresponding port. The master can read out the relative receive times, |
933 the corresponding port. The master can read out the relative receive times, |
926 then calculate time delays between the slaves (using its knowledge of the bus |
934 then calculate time delays between the slaves (using its knowledge of the bus |
927 topology), and finally calculate the time delays from the reference clock to |
935 topology), and finally calculate the time delays from the reference clock to |
928 each slave. These values are programmed into the slaves' transmission delay |
936 each slave. These values are programmed into the slaves' transmission delay |
929 registers. In this way, the drift compensation can reach nanosecond synchrony. |
937 registers. In this way, the drift compensation can reach nanosecond synchrony. |
930 |
938 |
931 \paragraph{Checking Synchrony} DC-capable slaves provide the 32-bit ``System |
939 \paragraph{Checking Synchrony} DC-capable slaves provide the 32-bit ``System |
932 time difference'' register at address \lstinline+0x092c+, where the system |
940 time difference'' register at address \lstinline+0x092c+, where the system |
933 time difference of the last drift compensation is stored in nanosecond |
941 time difference of the last drift compensation is stored in nanosecond |
934 resolution and in sign-and-magnitude coding\footnote{This allows |
942 resolution and in sign-and-magnitude coding\footnote{This allows |
935 broadcast-reading all system time difference registers on the bus to get an |
943 broadcast-reading all system time difference registers on the bus to get an |
936 upper approximation}. To check for bus synchrony, the system time difference |
944 upper approximation}. To check for bus synchrony, the system time difference |
937 registers can also be cyclically read via the command-line-tool (see |
945 registers can also be cyclically read via the command-line-tool (see |
938 sec.~\ref{sec:regaccess}): |
946 \autoref{sec:regaccess}): |
939 |
947 |
940 \begin{lstlisting} |
948 \begin{lstlisting} |
941 $ `\textbf{watch -n0 "ethercat reg\_read -p4 -tsm32 0x92c"}` |
949 $ `\textbf{watch -n0 "ethercat reg\_read -p4 -tsm32 0x92c"}` |
942 \end{lstlisting} |
950 \end{lstlisting} |
943 |
951 |
963 |
971 |
964 The term \textit{device} is used as a synonym for Ethernet network interface |
972 The term \textit{device} is used as a synonym for Ethernet network interface |
965 hardware. |
973 hardware. |
966 |
974 |
967 \paragraph{Native Ethernet Device Drivers} There are native device driver |
975 \paragraph{Native Ethernet Device Drivers} There are native device driver |
968 modules (see sec.~\ref{sec:native-drivers}) that handle Ethernet hardware, |
976 modules (see \autoref{sec:native-drivers}) that handle Ethernet hardware, |
969 which a master can use to connect to an EtherCAT bus. They offer their |
977 which a master can use to connect to an EtherCAT bus. They offer their |
970 Ethernet hardware to the master module via the device interface (see |
978 Ethernet hardware to the master module via the device interface (see |
971 sec.~\ref{sec:ecdev}) and must be capable to prepare Ethernet devices either |
979 \autoref{sec:ecdev}) and must be capable to prepare Ethernet devices either |
972 for EtherCAT (realtime) operation or for ``normal'' operation using the |
980 for EtherCAT (realtime) operation or for ``normal'' operation using the |
973 kernel's network stack. The advantage of this approach is that the master can |
981 kernel's network stack. The advantage of this approach is that the master can |
974 operate nearly directly on the hardware, which allows a high performance. The |
982 operate nearly directly on the hardware, which allows a high performance. The |
975 disadvantage is, that there has to be an EtherCAT-capable version of the |
983 disadvantage is, that there has to be an EtherCAT-capable version of the |
976 original Ethernet driver. |
984 original Ethernet driver. |
977 |
985 |
978 \paragraph{Generic Ethernet Device Driver} From master version 1.5, there is a |
986 \paragraph{Generic Ethernet Device Driver} From master version 1.5, there is a |
979 generic Ethernet device driver module (see sec.~\ref{sec:generic-driver}), |
987 generic Ethernet device driver module (see \autoref{sec:generic-driver}), |
980 that uses the lower layers of the network stack to connect to the hardware. |
988 that uses the lower layers of the network stack to connect to the hardware. |
981 The advantage is, that arbitrary Ethernet hardware can be used for EtherCAT |
989 The advantage is, that arbitrary Ethernet hardware can be used for EtherCAT |
982 operation, independently of the actual hardware driver (so all Linux Ethernet |
990 operation, independently of the actual hardware driver (so all Linux Ethernet |
983 drivers are supported without modifications). The disadvantage is, that this |
991 drivers are supported without modifications). The disadvantage is, that this |
984 approach does not support realtime extensions like RTAI, because the Linux |
992 approach does not support realtime extensions like RTAI, because the Linux |
1197 \label{sec:generic-driver} |
1205 \label{sec:generic-driver} |
1198 |
1206 |
1199 Since there are approaches to enable the complete Linux kernel for realtime |
1207 Since there are approaches to enable the complete Linux kernel for realtime |
1200 operation \cite{rt-preempt}, it is possible to operate without native |
1208 operation \cite{rt-preempt}, it is possible to operate without native |
1201 implementations of EtherCAT-capable Ethernet device drivers and use the Linux |
1209 implementations of EtherCAT-capable Ethernet device drivers and use the Linux |
1202 network stack instead. Fig.~\ref{fig:arch} shows the ``Generic Ethernet Driver |
1210 network stack instead. \autoref{fig:arch} shows the ``Generic Ethernet Driver |
1203 Module'', that connects to local Ethernet devices via the network stack. The |
1211 Module'', that connects to local Ethernet devices via the network stack. The |
1204 kernel module is named \lstinline+ec_generic+ and can be loaded after the |
1212 kernel module is named \lstinline+ec_generic+ and can be loaded after the |
1205 master module like a native EtherCAT-capable Ethernet driver. |
1213 master module like a native EtherCAT-capable Ethernet driver. |
1206 |
1214 |
1207 The generic device driver scans the network stack for interfaces, that have |
1215 The generic device driver scans the network stack for interfaces, that have |
1208 been registered by Ethernet device drivers. It offers all possible devices to |
1216 been registered by Ethernet device drivers. It offers all possible devices to |
1209 the EtherCAT master. If the master accepts a device, the generic driver |
1217 the EtherCAT master. If the master accepts a device, the generic driver |
1210 creates a packet socket (see \lstinline+man 7 packet+) with |
1218 creates a packet socket (see \lstinline+man 7 packet+) with |
1211 \lstinline+socket_type+ set to \lstinline+SOCK_RAW+, bound to that device. All |
1219 \lstinline+socket_type+ set to \lstinline+SOCK_RAW+, bound to that device. All |
1212 functions of the device interface (see sec.~\ref{sec:ecdev}) will then operate |
1220 functions of the device interface (see \autoref{sec:ecdev}) will then operate |
1213 on that socket. |
1221 on that socket. |
1214 |
1222 |
1215 Below are the advantages of this solution: |
1223 Below are the advantages of this solution: |
1216 |
1224 |
1217 \begin{itemize} |
1225 \begin{itemize} |
1229 the generic driver, because the network stack code uses dynamic memory |
1237 the generic driver, because the network stack code uses dynamic memory |
1230 allocations and other things, that could cause the system to freeze in |
1238 allocations and other things, that could cause the system to freeze in |
1231 realtime context. |
1239 realtime context. |
1232 \end{itemize} |
1240 \end{itemize} |
1233 |
1241 |
|
1242 \paragraph{Device Activation} In order to send and receive frames through a |
|
1243 socket, the Ethernet device linked to that socket has to be activated, |
|
1244 otherwise all frames will be rejected. Activation has to take place before the |
|
1245 master module is loaded and can happen in several ways: |
|
1246 |
|
1247 \begin{itemize} |
|
1248 |
|
1249 \item Ad-hoc, using the command \lstinline+ip link set dev ethX up+ (or the |
|
1250 older \lstinline+ifconfig ethX up+), |
|
1251 |
|
1252 \item Configured, depending on the distribution, for example using |
|
1253 \lstinline+ifcfg+ files (\lstinline+/etc/sysconfig/network/ifcfg-ethX+) in |
|
1254 openSUSE and others. This is the better choice, if the EtherCAT master shall |
|
1255 start at system boot time. Since the Ethernet device shall only be activated, |
|
1256 but no IP address etc.\ shall be assigned, it is enough to use |
|
1257 \lstinline+STARTMODE=auto+ as configuration. |
|
1258 |
|
1259 \end{itemize} |
|
1260 |
1234 %------------------------------------------------------------------------------ |
1261 %------------------------------------------------------------------------------ |
1235 |
1262 |
1236 \section{Providing Ethernet Devices} |
1263 \section{Providing Ethernet Devices} |
1237 \label{sec:providing-devices} |
1264 \label{sec:providing-devices} |
1238 |
1265 |
1239 After loading the master module, additional module(s) have to be loaded to |
1266 After loading the master module, additional module(s) have to be loaded to |
1240 offer devices to the master(s) (see sec.~\ref{sec:ecdev}). The master module |
1267 offer devices to the master(s) (see \autoref{sec:ecdev}). The master module |
1241 knows the devices to choose from the module parameters (see |
1268 knows the devices to choose from the module parameters (see |
1242 sec.~\ref{sec:mastermod}). If the init script is used to start the master, the |
1269 \autoref{sec:mastermod}). If the init script is used to start the master, the |
1243 drivers and devices to use can be specified in the sysconfig file (see |
1270 drivers and devices to use can be specified in the sysconfig file (see |
1244 sec.~\ref{sec:sysconfig}). |
1271 \autoref{sec:sysconfig}). |
1245 |
1272 |
1246 Modules offering Ethernet devices can be |
1273 Modules offering Ethernet devices can be |
1247 |
1274 |
1248 \begin{itemize} |
1275 \begin{itemize} |
1249 \item native EtherCAT-capable network driver modules (see |
1276 \item native EtherCAT-capable network driver modules (see |
1250 sec.~\ref{sec:native-drivers}) or |
1277 \autoref{sec:native-drivers}) or |
1251 \item the generic EtherCAT device driver module (see |
1278 \item the generic EtherCAT device driver module (see |
1252 sec.~\ref{sec:generic-driver}). |
1279 \autoref{sec:generic-driver}). |
1253 \end{itemize} |
1280 \end{itemize} |
|
1281 |
|
1282 %------------------------------------------------------------------------------ |
|
1283 |
|
1284 \section{Redundancy} |
|
1285 \label{sec:redundancy} |
|
1286 \index{Redundancy} |
|
1287 |
|
1288 Redundant bus operation means, that there is more than one Ethernet connection |
|
1289 from the master to the slaves. Process data exchange datagrams are sent out on |
|
1290 every master link, so that the exchange is still complete, even if the bus is |
|
1291 disconnected somewhere in between. |
|
1292 |
|
1293 Prerequisite for fully redundant bus operation is, that every slave can be |
|
1294 reached by at least one master link. In this case a single connection failure |
|
1295 (i.\,e.~cable break) will never lead to incomplete process data. Double-faults |
|
1296 can not be handled with two Ethernet devices. |
|
1297 |
|
1298 Redundancy is configured with the \lstinline+--with-devices+ switch at |
|
1299 configure time (see \autoref{sec:installation}) and using the |
|
1300 \lstinline+backup_devices+ parameter of the \lstinline+ec_master+ kernel |
|
1301 module (see \autoref{sec:mastermod}) or the appropriate variable |
|
1302 \lstinline+MASTERx_BACKUP+ in the (sys-)config file (see |
|
1303 \autoref{sec:sysconfig}). |
|
1304 |
|
1305 Bus scanning is done after a topology change on any Ethernet link. The |
|
1306 application interface (see \autoref{chap:api}) and the command-line tool (see |
|
1307 \autoref{sec:tool}) both have methods to query the status of the redundant |
|
1308 operation. |
1254 |
1309 |
1255 %------------------------------------------------------------------------------ |
1310 %------------------------------------------------------------------------------ |
1256 |
1311 |
1257 \section{EtherCAT Device Interface} |
1312 \section{EtherCAT Device Interface} |
1258 \label{sec:ecdev} |
1313 \label{sec:ecdev} |
1259 \index{Device interface} |
1314 \index{Device interface} |
1260 |
1315 |
1261 An anticipation to the section about the master module |
1316 An anticipation to the section about the master module |
1262 (sec.~\ref{sec:mastermod}) has to be made in order to understand the way, a |
1317 (\autoref{sec:mastermod}) has to be made in order to understand the way, a |
1263 network device driver module can connect a device to a specific EtherCAT |
1318 network device driver module can connect a device to a specific EtherCAT |
1264 master. |
1319 master. |
1265 |
1320 |
1266 The master module provides a ``device interface'' for network device drivers. |
1321 The master module provides a ``device interface'' for network device drivers. |
1267 To use this interface, a network device driver module must include the header |
1322 To use this interface, a network device driver module must include the header |
1311 a \lstinline+net_device+ structure with a \lstinline+priv_data+ field to |
1366 a \lstinline+net_device+ structure with a \lstinline+priv_data+ field to |
1312 attach driver-dependent data to the structure. To distinguish between normal |
1367 attach driver-dependent data to the structure. To distinguish between normal |
1313 Ethernet devices and the ones used by EtherCAT masters, the private data |
1368 Ethernet devices and the ones used by EtherCAT masters, the private data |
1314 structure used by the driver could be extended by a pointer, that points to an |
1369 structure used by the driver could be extended by a pointer, that points to an |
1315 \lstinline+ec_device_t+ object returned by \lstinline+ecdev_offer()+ (see |
1370 \lstinline+ec_device_t+ object returned by \lstinline+ecdev_offer()+ (see |
1316 sec.~\ref{sec:ecdev}) if the device is used by a master and otherwise is zero. |
1371 \autoref{sec:ecdev}) if the device is used by a master and otherwise is zero. |
1317 |
1372 |
1318 The RealTek RTL-8139 Fast Ethernet driver is a ``simple'' Ethernet driver and |
1373 The RealTek RTL-8139 Fast Ethernet driver is a ``simple'' Ethernet driver and |
1319 can be taken as an example to patch new drivers. The interesting sections can |
1374 can be taken as an example to patch new drivers. The interesting sections can |
1320 be found by searching the string ``ecdev" in the file |
1375 be found by searching the string ``ecdev" in the file |
1321 \textit{devices/8139too-2.6.24-ethercat.c}. |
1376 \textit{devices/8139too-2.6.24-ethercat.c}. |
1352 This sequential approach is very simple, reflecting in only three lines of |
1407 This sequential approach is very simple, reflecting in only three lines of |
1353 code. The disadvantage is, that the master is blocked for the time it waits |
1408 code. The disadvantage is, that the master is blocked for the time it waits |
1354 for datagram reception. There is no difficulty when only one instance is using |
1409 for datagram reception. There is no difficulty when only one instance is using |
1355 the master, but if more instances want to (synchronously\footnote{At this |
1410 the master, but if more instances want to (synchronously\footnote{At this |
1356 time, synchronous master access will be adequate to show the advantages of an |
1411 time, synchronous master access will be adequate to show the advantages of an |
1357 FSM. The asynchronous approach will be discussed in sec.~\ref{sec:eoe}}) use |
1412 FSM. The asynchronous approach will be discussed in \autoref{sec:eoe}}) use |
1358 the master, it is inevitable to think about an alternative to the sequential |
1413 the master, it is inevitable to think about an alternative to the sequential |
1359 model. |
1414 model. |
1360 |
1415 |
1361 Master access has to be sequentialized for more than one instance |
1416 Master access has to be sequentialized for more than one instance |
1362 wanting to send and receive datagrams synchronously. With the present |
1417 wanting to send and receive datagrams synchronously. With the present |
1430 \end{itemize} |
1485 \end{itemize} |
1431 |
1486 |
1432 The state transition function $\delta$ is often specified by a |
1487 The state transition function $\delta$ is often specified by a |
1433 \textit{state transition table}, or by a \textit{state transition |
1488 \textit{state transition table}, or by a \textit{state transition |
1434 diagram}. The transition table offers a matrix view of the state |
1489 diagram}. The transition table offers a matrix view of the state |
1435 machine behavior (see table~\ref{tab:statetrans}). The matrix rows |
1490 machine behavior (see \autoref{tab:statetrans}). The matrix rows |
1436 correspond to the states ($S = \{s_0, s_1, s_2\}$) and the columns |
1491 correspond to the states ($S = \{s_0, s_1, s_2\}$) and the columns |
1437 correspond to the input symbols ($\Gamma = \{a, b, \varepsilon\}$). |
1492 correspond to the input symbols ($\Gamma = \{a, b, \varepsilon\}$). |
1438 The table contents in a certain row $i$ and column $j$ then represent |
1493 The table contents in a certain row $i$ and column $j$ then represent |
1439 the next state (and possibly the output) for the case, that a certain |
1494 the next state (and possibly the output) for the case, that a certain |
1440 input symbol $\sigma_j$ is read in the state $s_i$. |
1495 input symbol $\sigma_j$ is read in the state $s_i$. |
1578 \paragraph{Mealy and Moore} |
1633 \paragraph{Mealy and Moore} |
1579 |
1634 |
1580 If a closer look is taken to the above listing, it can be seen that the |
1635 If a closer look is taken to the above listing, it can be seen that the |
1581 actions executed (the ``outputs'' of the state machine) only depend on the |
1636 actions executed (the ``outputs'' of the state machine) only depend on the |
1582 current state. This accords to the ``Moore'' model introduced in |
1637 current state. This accords to the ``Moore'' model introduced in |
1583 sec.~\ref{sec:fsmtheory}. As mentioned, the ``Mealy'' model offers a higher |
1638 \autoref{sec:fsmtheory}. As mentioned, the ``Mealy'' model offers a higher |
1584 flexibility, which can be seen in the listing below: |
1639 flexibility, which can be seen in the listing below: |
1585 |
1640 |
1586 \begin{lstlisting}[gobble=2,language=C,numbers=left] |
1641 \begin{lstlisting}[gobble=2,language=C,numbers=left] |
1587 void state7(void *priv_data) { |
1642 void state7(void *priv_data) { |
1588 if (some_condition) { |
1643 if (some_condition) { |
1627 \paragraph{Using Sub State Machines} |
1682 \paragraph{Using Sub State Machines} |
1628 |
1683 |
1629 To avoid having too much states, certain functions of the EtherCAT master |
1684 To avoid having too much states, certain functions of the EtherCAT master |
1630 state machine have been sourced out into sub state machines. This helps to |
1685 state machine have been sourced out into sub state machines. This helps to |
1631 encapsulate the related workflows and moreover avoids the ``state explosion'' |
1686 encapsulate the related workflows and moreover avoids the ``state explosion'' |
1632 phenomenon described in sec.~\ref{sec:fsmtheory}. If the master would instead |
1687 phenomenon described in \autoref{sec:fsmtheory}. If the master would instead |
1633 use one big state machine, the number of states would be a multiple of the |
1688 use one big state machine, the number of states would be a multiple of the |
1634 actual number. This would increase the level of complexity to a non-manageable |
1689 actual number. This would increase the level of complexity to a non-manageable |
1635 grade. |
1690 grade. |
1636 |
1691 |
1637 \paragraph{Executing Sub State Machines} |
1692 \paragraph{Executing Sub State Machines} |
1792 |
1847 |
1793 \item[PREOP] The state change FSM is used to bring the slave to PREOP state. |
1848 \item[PREOP] The state change FSM is used to bring the slave to PREOP state. |
1794 If this is the requested state, the state machine is finished. |
1849 If this is the requested state, the state machine is finished. |
1795 |
1850 |
1796 \item[SDO Configuration] If there is a slave configuration attached (see |
1851 \item[SDO Configuration] If there is a slave configuration attached (see |
1797 sec.~\ref{sec:masterconfig}), and there are any SDO configurations are |
1852 \autoref{sec:masterconfig}), and there are any SDO configurations are |
1798 provided by the application, these are sent to the slave. |
1853 provided by the application, these are sent to the slave. |
1799 |
1854 |
1800 \item[PDO Configuration] The PDO configuration state machine is executed to |
1855 \item[PDO Configuration] The PDO configuration state machine is executed to |
1801 apply all necessary PDO configurations. |
1856 apply all necessary PDO configurations. |
1802 |
1857 |
1803 \item[PDO Sync Manager Configuration] If any PDO sync managers exist, they are |
1858 \item[PDO Sync Manager Configuration] If any PDO sync managers exist, they are |
1804 configured. |
1859 configured. |
1805 |
1860 |
1806 \item[FMMU Configuration] If there are FMMUs configurations supplied by the |
1861 \item[FMMU Configuration] If there are FMMUs configurations supplied by the |
1807 application (i.\,e.\ if the application registered PDO entries), they are |
1862 application (i.\,e.\ if the application registered PDO entries), they are |
1808 applied. |
1863 applied. |
1809 |
1864 |
1810 \item[SAFEOP] The state change FSM is used to bring the slave to SAFEOP state. |
1865 \item[SAFEOP] The state change FSM is used to bring the slave to SAFEOP state. |
1811 If this is the requested state, the state machine is finished. |
1866 If this is the requested state, the state machine is finished. |
1812 |
1867 |
1813 \item[OP] The state change FSM is used to bring the slave to OP state. |
1868 \item[OP] The state change FSM is used to bring the slave to OP state. |
1921 \index{FSM!PDO} |
1976 \index{FSM!PDO} |
1922 |
1977 |
1923 The PDO state machines are a set of state machines that read or write the PDO |
1978 The PDO state machines are a set of state machines that read or write the PDO |
1924 assignment and the PDO mapping via the ``CoE Communication Area'' described in |
1979 assignment and the PDO mapping via the ``CoE Communication Area'' described in |
1925 \cite[sec. 5.6.7.4]{alspec}. For the object access, the CANopen over EtherCAT |
1980 \cite[sec. 5.6.7.4]{alspec}. For the object access, the CANopen over EtherCAT |
1926 access primitives are used (see sec.~\ref{sec:coe}), so the slave must support |
1981 access primitives are used (see \autoref{sec:coe}), so the slave must support |
1927 the CoE mailbox protocol. |
1982 the CoE mailbox protocol. |
1928 |
1983 |
1929 \paragraph{PDO Reading FSM} This state machine (fig.~\ref{fig:fsm-pdo-read}) |
1984 \paragraph{PDO Reading FSM} This state machine (\autoref{fig:fsm-pdo-read}) |
1930 has the purpose to read the complete PDO configuration of a slave. It reads |
1985 has the purpose to read the complete PDO configuration of a slave. It reads |
1931 the PDO assignment for each Sync Manager and uses the PDO Entry Reading FSM |
1986 the PDO assignment for each Sync Manager and uses the PDO Entry Reading FSM |
1932 (fig.~\ref{fig:fsm-pdo-entry-read}) to read the mapping for each assigned PDO. |
1987 (\autoref{fig:fsm-pdo-entry-read}) to read the mapping for each assigned PDO. |
1933 |
1988 |
1934 \begin{figure}[htbp] |
1989 \begin{figure}[htbp] |
1935 \centering |
1990 \centering |
1936 \includegraphics[width=.4\textwidth]{graphs/fsm_pdo_read} |
1991 \includegraphics[width=.4\textwidth]{graphs/fsm_pdo_read} |
1937 \caption{Transition Diagram of the PDO Reading State Machine} |
1992 \caption{Transition Diagram of the PDO Reading State Machine} |
1943 PDOs for this sync manager and then reads out the subindices of the SDO to get |
1998 PDOs for this sync manager and then reads out the subindices of the SDO to get |
1944 the assigned PDO's indices. When a PDO index is read, the PDO Entry Reading |
1999 the assigned PDO's indices. When a PDO index is read, the PDO Entry Reading |
1945 FSM is executed to read the PDO's mapped PDO entries. |
2000 FSM is executed to read the PDO's mapped PDO entries. |
1946 |
2001 |
1947 \paragraph{PDO Entry Reading FSM} This state machine |
2002 \paragraph{PDO Entry Reading FSM} This state machine |
1948 (fig.~\ref{fig:fsm-pdo-entry-read}) reads the PDO mapping (the PDO entries) of |
2003 (\autoref{fig:fsm-pdo-entry-read}) reads the PDO mapping (the PDO entries) of |
1949 a PDO. It reads the respective mapping SDO (\lstinline+0x1600+ -- |
2004 a PDO. It reads the respective mapping SDO (\lstinline+0x1600+ -- |
1950 \lstinline+0x17ff+, or \lstinline+0x1a00+ -- \lstinline+0x1bff+) for the given |
2005 \lstinline+0x17ff+, or \lstinline+0x1a00+ -- \lstinline+0x1bff+) for the given |
1951 PDO by reading first the subindex zero (number of elements) to determine the |
2006 PDO by reading first the subindex zero (number of elements) to determine the |
1952 number of mapped PDO entries. After that, each subindex is read to get the |
2007 number of mapped PDO entries. After that, each subindex is read to get the |
1953 mapped PDO entry index, subindex and bit size. |
2008 mapped PDO entry index, subindex and bit size. |
2048 up, the passing of new socket buffers is suspended with a call to |
2103 up, the passing of new socket buffers is suspended with a call to |
2049 \lstinline+netif_stop_queue()+. |
2104 \lstinline+netif_stop_queue()+. |
2050 |
2105 |
2051 \paragraph{Creation of EoE Handlers} |
2106 \paragraph{Creation of EoE Handlers} |
2052 |
2107 |
2053 During bus scanning (see sec.~\ref{sec:fsm-scan}), the master determines the |
2108 During bus scanning (see \autoref{sec:fsm-scan}), the master determines the |
2054 supported mailbox protocols foe each slave. This is done by examining the |
2109 supported mailbox protocols foe each slave. This is done by examining the |
2055 ``Supported Mailbox Protocols'' mask field at word address 0x001C of the |
2110 ``Supported Mailbox Protocols'' mask field at word address 0x001C of the |
2056 SII\index{SII}. If bit 1 is set, the slave supports the EoE protocol. In this |
2111 SII\index{SII}. If bit 1 is set, the slave supports the EoE protocol. In this |
2057 case, an EoE handler is created for that slave. |
2112 case, an EoE handler is created for that slave. |
2058 |
2113 |
2121 \paragraph{EoE Processing} |
2176 \paragraph{EoE Processing} |
2122 |
2177 |
2123 To execute the EoE state machine of every active EoE handler, there must be a |
2178 To execute the EoE state machine of every active EoE handler, there must be a |
2124 cyclic process. The easiest solution would be to execute the EoE state |
2179 cyclic process. The easiest solution would be to execute the EoE state |
2125 machines synchronously with the master state machine (see |
2180 machines synchronously with the master state machine (see |
2126 sec.~\ref{sec:fsm-master}). This approach has the following disadvantage: |
2181 \autoref{sec:fsm-master}). This approach has the following disadvantage: |
2127 |
2182 |
2128 Only one EoE fragment could be sent or received every few cycles. This |
2183 Only one EoE fragment could be sent or received every few cycles. This |
2129 causes the data rate to be very low, because the EoE state machines are not |
2184 causes the data rate to be very low, because the EoE state machines are not |
2130 executed in the time between the application cycles. Moreover, the data rate |
2185 executed in the time between the application cycles. Moreover, the data rate |
2131 would be dependent on the period of the application task. |
2186 would be dependent on the period of the application task. |
2132 |
2187 |
2133 To overcome this problem, an own cyclic process is needed to asynchronously |
2188 To overcome this problem, an own cyclic process is needed to asynchronously |
2134 execute the EoE state machines. For that, the master owns a kernel timer, that |
2189 execute the EoE state machines. For that, the master owns a kernel timer, that |
2135 is executed each timer interrupt. This guarantees a constant bandwidth, but |
2190 is executed each timer interrupt. This guarantees a constant bandwidth, but |
2136 poses the new problem of concurrent access to the master. The locking |
2191 poses the new problem of concurrent access to the master. The locking |
2137 mechanisms needed for this are introduced in sec.~\ref{sec:concurr}. |
2192 mechanisms needed for this are introduced in \autoref{sec:concurr}. |
2138 |
2193 |
2139 \paragraph{Automatic Configuration} |
2194 \paragraph{Automatic Configuration} |
2140 |
2195 |
2141 By default, slaves are left in PREOP state, if no configuration is applied. If |
2196 By default, slaves are left in PREOP state, if no configuration is applied. If |
2142 an EoE interface link is set to ``up'', the requested slave's |
2197 an EoE interface link is set to ``up'', the requested slave's |
2164 |
2219 |
2165 The best time to apply SDO configurations is during the slave's PREOP state, |
2220 The best time to apply SDO configurations is during the slave's PREOP state, |
2166 because mailbox communication is already possible and slave's application will |
2221 because mailbox communication is already possible and slave's application will |
2167 start with updating input data in the succeeding SAFEOP state. Therefore the |
2222 start with updating input data in the succeeding SAFEOP state. Therefore the |
2168 SDO configuration has to be part of the slave configuration state machine (see |
2223 SDO configuration has to be part of the slave configuration state machine (see |
2169 sec.~\ref{sec:fsm-conf}): It is implemented via an SDO download state machine, |
2224 \autoref{sec:fsm-conf}): It is implemented via an SDO download state machine, |
2170 that is executed just before entering the slave's SAFEOP state. In this way, |
2225 that is executed just before entering the slave's SAFEOP state. In this way, |
2171 it is guaranteed that the SDO configurations are applied each time, the slave |
2226 it is guaranteed that the SDO configurations are applied each time, the slave |
2172 is reconfigured. |
2227 is reconfigured. |
2173 |
2228 |
2174 The transition diagram of the SDO Download state machine can be seen |
2229 The transition diagram of the SDO Download state machine can be seen |
2175 in figure~\ref{fig:fsm-coedown}. |
2230 in \autoref{fig:fsm-coedown}. |
2176 |
2231 |
2177 \begin{figure}[htbp] |
2232 \begin{figure}[htbp] |
2178 \centering |
2233 \centering |
2179 \includegraphics[width=.9\textwidth]{images/fsm-coedown} % FIXME |
2234 \includegraphics[width=.9\textwidth]{images/fsm-coedown} % FIXME |
2180 \caption{Transition diagram of the CoE download state machine} |
2235 \caption{Transition diagram of the CoE download state machine} |
2227 communication protocol. VoE mailbox messages are prepended by a VoE header |
2282 communication protocol. VoE mailbox messages are prepended by a VoE header |
2228 containing a 32-bit vendor ID and a 16-bit vendor-type. There are no more |
2283 containing a 32-bit vendor ID and a 16-bit vendor-type. There are no more |
2229 constraints regarding this protocol. |
2284 constraints regarding this protocol. |
2230 |
2285 |
2231 The EtherCAT master allows to create multiple VoE handlers per slave |
2286 The EtherCAT master allows to create multiple VoE handlers per slave |
2232 configuration via the application interface (see chap.~\ref{chap:api}). These |
2287 configuration via the application interface (see \autoref{chap:api}). These |
2233 handlers contain the state machine necessary for the communication via VoE. |
2288 handlers contain the state machine necessary for the communication via VoE. |
2234 |
2289 |
2235 For more information about using VoE handlers, see sec.~\ref{sec:api-voe} or |
2290 For more information about using VoE handlers, see \autoref{sec:api-voe} or |
2236 the example applications provided in the \textit{examples/} subdirectory. |
2291 the example applications provided in the \textit{examples/} subdirectory. |
2237 |
2292 |
2238 %------------------------------------------------------------------------------ |
2293 %------------------------------------------------------------------------------ |
2239 |
2294 |
2240 \section{Servo Profile over EtherCAT (SoE)} |
2295 \section{Servo Profile over EtherCAT (SoE)} |
2243 |
2298 |
2244 The SoE protocol implements the Service Channel layer, specified in IEC |
2299 The SoE protocol implements the Service Channel layer, specified in IEC |
2245 61800-7 \cite{soespec} via EtherCAT mailboxes. |
2300 61800-7 \cite{soespec} via EtherCAT mailboxes. |
2246 |
2301 |
2247 The SoE protocol is quite similar to the CoE protocol (see |
2302 The SoE protocol is quite similar to the CoE protocol (see |
2248 sec.~\ref{sec:coe}). Instead of SDO indices and subindices, so-called |
2303 \autoref{sec:coe}). Instead of SDO indices and subindices, so-called |
2249 identification numbers (IDNs) identify parameters. |
2304 identification numbers (IDNs) identify parameters. |
2250 |
2305 |
2251 The implementation covers the ``SCC Read'' and ``SCC Write'' primitives, each |
2306 The implementation covers the ``SCC Read'' and ``SCC Write'' primitives, each |
2252 with the ability to fragment data. |
2307 with the ability to fragment data. |
2253 |
2308 |
2254 There are several ways to use the SoE implementation: |
2309 There are several ways to use the SoE implementation: |
2255 |
2310 |
2256 \begin{itemize} |
2311 \begin{itemize} |
2257 |
2312 |
2258 \item Reading and writing IDNs via the command-line tool (see |
2313 \item Reading and writing IDNs via the command-line tool (see |
2259 sec.~\ref{sec:soeaccess}). |
2314 \autoref{sec:soeaccess}). |
2260 |
2315 |
2261 \item Storing configurations for arbitrary IDNs via the application interface |
2316 \item Storing configurations for arbitrary IDNs via the application interface |
2262 (see chap.~\ref{chap:api}, i.\,e.~\lstinline+ecrt_slave_config_idn()+). These |
2317 (see \autoref{chap:api}, i.\,e.~\lstinline+ecrt_slave_config_idn()+). These |
2263 configurations are written to the slave during configuration in PREOP state, |
2318 configurations are written to the slave during configuration in PREOP state, |
2264 before going to SAFEOP. |
2319 before going to SAFEOP. |
2265 |
2320 |
2266 \item The user-space library (see sec.~\ref{sec:userlib}), offers functions to |
2321 \item The user-space library (see \autoref{sec:userlib}), offers functions to |
2267 read/write IDNs in blocking mode (\lstinline+ecrt_master_read_idn()+, |
2322 read/write IDNs in blocking mode (\lstinline+ecrt_master_read_idn()+, |
2268 \lstinline+ecrt_master_write_idn()+). |
2323 \lstinline+ecrt_master_write_idn()+). |
2269 |
2324 |
2270 \end{itemize} |
2325 \end{itemize} |
2271 |
2326 |
2282 the master from userspace and allow a finer influence. It should be possible |
2337 the master from userspace and allow a finer influence. It should be possible |
2283 to view and to change special parameters at runtime. |
2338 to view and to change special parameters at runtime. |
2284 |
2339 |
2285 Bus visualization is another point: For development and debugging purposes it |
2340 Bus visualization is another point: For development and debugging purposes it |
2286 is necessary to show the connected slaves with a single command, for instance |
2341 is necessary to show the connected slaves with a single command, for instance |
2287 (see sec.~\ref{sec:tool}). |
2342 (see \autoref{sec:tool}). |
2288 |
2343 |
2289 The application interface has to be available in userspace, to allow userspace |
2344 The application interface has to be available in userspace, to allow userspace |
2290 programs to use EtherCAT master functionality. This was implemented via a |
2345 programs to use EtherCAT master functionality. This was implemented via a |
2291 character device and a userspace library (see sec.~\ref{sec:userlib}). |
2346 character device and a userspace library (see \autoref{sec:userlib}). |
2292 |
2347 |
2293 Another aspect is automatic startup and configuration. The master must be able |
2348 Another aspect is automatic startup and configuration. The master must be able |
2294 to automatically start up with a persistent configuration (see |
2349 to automatically start up with a persistent configuration (see |
2295 sec.~\ref{sec:system}). |
2350 \autoref{sec:system}). |
2296 |
2351 |
2297 A last thing is monitoring EtherCAT communication. For debugging purposes, |
2352 A last thing is monitoring EtherCAT communication. For debugging purposes, |
2298 there had to be a way to analyze EtherCAT datagrams. The best way would be |
2353 there had to be a way to analyze EtherCAT datagrams. The best way would be |
2299 with a popular network analyzer, like Wireshark \cite{wireshark} (the former |
2354 with a popular network analyzer, like Wireshark \cite{wireshark} or others |
2300 Ethereal) or others (see sec.~\ref{sec:debug}). |
2355 (see \autoref{sec:debug}). |
2301 |
2356 |
2302 This chapter covers all these points and introduces the interfaces and tools |
2357 This chapter covers all these points and introduces the interfaces and tools |
2303 to make all that possible. |
2358 to make all that possible. |
2304 |
2359 |
2305 %------------------------------------------------------------------------------ |
2360 %------------------------------------------------------------------------------ |
2574 |
2630 |
2575 \subsection{Implementation} |
2631 \subsection{Implementation} |
2576 \label{sec:userimp} |
2632 \label{sec:userimp} |
2577 |
2633 |
2578 Basically the kernel API was transferred into userspace via the master |
2634 Basically the kernel API was transferred into userspace via the master |
2579 character device (see chap.~\ref{chap:arch}, fig.~\ref{fig:arch} and |
2635 character device (see \autoref{chap:arch}, \autoref{fig:arch} and |
2580 sec.~\ref{sec:cdev}). |
2636 \autoref{sec:cdev}). |
2581 |
2637 |
2582 The function calls of the kernel API are mapped to the userspace via an |
2638 The function calls of the kernel API are mapped to the userspace via an |
2583 \lstinline+ioctl()+ interface. The userspace API functions share a set of |
2639 \lstinline+ioctl()+ interface. The userspace API functions share a set of |
2584 generic \lstinline+ioctl()+ calls. The kernel part of the interface calls the |
2640 generic \lstinline+ioctl()+ calls. The kernel part of the interface calls the |
2585 according API functions directly, what results in a minimum additional delay |
2641 according API functions directly, what results in a minimum additional delay |
2586 (see sec.~\ref{sec:usertiming}). |
2642 (see \autoref{sec:usertiming}). |
2587 |
2643 |
2588 For performance reasons, the actual domain process data (see |
2644 For performance reasons, the actual domain process data (see |
2589 sec.~\ref{sec:processdata}) are not copied between kernel and user memory on |
2645 \autoref{sec:processdata}) are not copied between kernel and user memory on |
2590 every access: Instead, the data are memory-mapped to the userspace |
2646 every access: Instead, the data are memory-mapped to the userspace |
2591 application. Once the master is configured and activated, the master module |
2647 application. Once the master is configured and activated, the master module |
2592 creates one process data memory area spanning all domains and maps it to |
2648 creates one process data memory area spanning all domains and maps it to |
2593 userspace, so that the application can directly access the process data. As a |
2649 userspace, so that the application can directly access the process data. As a |
2594 result, there is no additional delay when accessing process data from |
2650 result, there is no additional delay when accessing process data from |
2658 about \unit{1}{\micro\second} additional delay for each function, compared to |
2714 about \unit{1}{\micro\second} additional delay for each function, compared to |
2659 the kernel API. |
2715 the kernel API. |
2660 |
2716 |
2661 %------------------------------------------------------------------------------ |
2717 %------------------------------------------------------------------------------ |
2662 |
2718 |
|
2719 \section{RTDM Interface} |
|
2720 \label{sec:rtdm} |
|
2721 |
|
2722 When using the userspace interfaces of realtime extensions like Xenomai or |
|
2723 RTAI, the use of \textit{ioctl()} is not recommended, because it may disturb |
|
2724 realtime operation. To accomplish this, the Real-Time Device Model (RTDM) |
|
2725 \cite{rtdm} has been developed. The master module provides an RTDM interface |
|
2726 (see \autoref{fig:arch}) in addition to the normal character device, if the |
|
2727 master sources were configured with \lstinline+--enable-rtdm+ (see |
|
2728 \autoref{sec:installation}). |
|
2729 |
|
2730 To force an application to use the RTDM interface instead of the normal |
|
2731 character device, it has to be linked with the \textit{libethercat\_rtdm} |
|
2732 library instead of \textit{libethercat}. The use of the |
|
2733 \textit{libethercat\_rtdm} is transparent, so the EtherCAT header |
|
2734 \textit{ecrt.h} with the complete API can be used as usual. |
|
2735 |
|
2736 To make the example in \autoref{lst:linker-user} use the RTDM library, the |
|
2737 linker command has to be altered as follows: |
|
2738 |
|
2739 \begin{lstlisting} |
|
2740 gcc ethercat-with-rtdm.c -o ectest -I/opt/etherlab/include \ |
|
2741 -L/opt/etherlab/lib -lethercat_rtdm \ |
|
2742 -Wl,--rpath -Wl,/opt/etherlab/lib |
|
2743 \end{lstlisting} |
|
2744 |
|
2745 %------------------------------------------------------------------------------ |
|
2746 |
2663 \section{System Integration} |
2747 \section{System Integration} |
2664 \label{sec:system} |
2748 \label{sec:system} |
2665 |
2749 |
2666 To integrate the EtherCAT master as a service into a running system, it comes |
2750 To integrate the EtherCAT master as a service into a running system, it comes |
2667 with an init script and a sysconfig file, that are described below. |
2751 with an init script and a sysconfig file, that are described below. Modern |
|
2752 systems may be managed by systemd \cite{systemd}. Integration of the master |
|
2753 with systemd is described in \autoref{sec:systemd}. |
2668 |
2754 |
2669 \subsection{Init Script} |
2755 \subsection{Init Script} |
2670 \label{sec:init} |
2756 \label{sec:init} |
2671 \index{Init script} |
2757 \index{Init script} |
2672 |
2758 |
2673 The EtherCAT master init script conforms to the requirements of the ``Linux |
2759 The EtherCAT master init script conforms to the requirements of the ``Linux |
2674 Standard Base'' (LSB\index{LSB}, \cite{lsb}). The script is installed to |
2760 Standard Base'' (LSB\index{LSB}, \cite{lsb}). The script is installed to |
2675 \textit{etc/init.d/ethercat} below the installation prefix and has to be |
2761 \textit{etc/init.d/ethercat} below the installation prefix and has to be |
2676 copied (or better: linked) to the appropriate location (see |
2762 copied (or better: linked) to the appropriate location (see |
2677 sec.~\ref{sec:installation}), before the master can be inserted as a service. |
2763 \autoref{sec:installation}), before the master can be inserted as a service. |
2678 Please note, that the init script depends on the sysconfig file described |
2764 Please note, that the init script depends on the sysconfig file described |
2679 below. |
2765 below. |
2680 |
2766 |
2681 To provide service dependencies (i.\,e.\ which services have to be started |
2767 To provide service dependencies (i.\,e.\ which services have to be started |
2682 before others) inside the init script code, LSB defines a special comment |
2768 before others) inside the init script code, LSB defines a special comment |
2721 # `\textbf{/etc/init.d/ethercat restart}` |
2811 # `\textbf{/etc/init.d/ethercat restart}` |
2722 Shutting down EtherCAT master done |
2812 Shutting down EtherCAT master done |
2723 Starting EtherCAT master done |
2813 Starting EtherCAT master done |
2724 \end{lstlisting} |
2814 \end{lstlisting} |
2725 |
2815 |
|
2816 \subsection{Integration with systemd} |
|
2817 \label{sec:systemd} |
|
2818 \index{systemd} |
|
2819 |
|
2820 Distributions using \textit{systemd} instead of the SysV init system are using service files to describe how a service is to be maintained. \autoref{lst:service} lists the master's service file: |
|
2821 |
|
2822 \lstinputlisting[basicstyle=\ttfamily\footnotesize,caption=Service file, |
|
2823 label=lst:service]{../script/ethercat.service} |
|
2824 |
|
2825 The \textit{ethercatctl} command is used to load and unload the master and |
|
2826 network driver modules in a similar way to the former init script |
|
2827 (\autoref{sec:init}). Because it is installed into the \textit{sbin/} |
|
2828 directory, it can also be used separately: |
|
2829 |
|
2830 \begin{lstlisting}[gobble=2] |
|
2831 # `\textbf{ethercatctl start}` |
|
2832 \end{lstlisting} |
|
2833 |
|
2834 When using systemd and/or the \textit{ethercatctl} command, the master |
|
2835 configuration must be in \texttt{/etc/ethercat.conf} instead of |
|
2836 \texttt{/etc/sysconfig/ethercat}! The latter is ignored. The configuration |
|
2837 options are exactly the same. |
|
2838 |
2726 %------------------------------------------------------------------------------ |
2839 %------------------------------------------------------------------------------ |
2727 |
2840 |
2728 \section{Debug Interfaces} |
2841 \section{Debug Interfaces} |
2729 \label{sec:debug} |
2842 \label{sec:debug} |
2730 \index{Debug Interfaces} |
2843 \index{Debug Interfaces} |
2731 |
2844 |
2732 EtherCAT buses can always be monitored by inserting a switch between master |
2845 EtherCAT buses can always be monitored by inserting a switch between master |
2733 and slaves. This allows to connect another PC with a network monitor like |
2846 and slaves. This allows to connect another PC with a network monitor like |
2734 Wireshark~\cite{wireshark}, for example. It is also possible to listen to |
2847 Wireshark~\cite{wireshark}, for example. It is also possible to listen to |
2735 local network interfaces on the machine running the EtherCAT master directly. |
2848 local network interfaces on the machine running the EtherCAT master directly. |
2736 If the generic Ethernet driver (see sec.~\ref{sec:generic-driver}) is used, |
2849 If the generic Ethernet driver (see \autoref{sec:generic-driver}) is used, |
2737 the network monitor can directly listen on the network interface connected to |
2850 the network monitor can directly listen on the network interface connected to |
2738 the EtherCAT bus. |
2851 the EtherCAT bus. |
2739 |
2852 |
2740 When using native Ethernet drivers (see sec.~\ref{sec:native-drivers}), there |
2853 When using native Ethernet drivers (see \autoref{sec:native-drivers}), there |
2741 are no local network interfaces to listen to, because the Ethernet devices |
2854 are no local network interfaces to listen to, because the Ethernet devices |
2742 used for EtherCAT are not registered at the network stack. For that case, |
2855 used for EtherCAT are not registered at the network stack. For that case, |
2743 so-called ``debug interfaces'' are supported, which are virtual network |
2856 so-called ``debug interfaces'' are supported, which are virtual network |
2744 interfaces allowing to capture EtherCAT traffic with a network monitor (like |
2857 interfaces allowing to capture EtherCAT traffic with a network monitor (like |
2745 Wireshark or tcpdump) running on the master machine without using external |
2858 Wireshark or tcpdump) running on the master machine without using external |
2746 hardware. To use this functionality, the master sources have to be configured |
2859 hardware. To use this functionality, the master sources have to be configured |
2747 with the \lstinline+--enable-debug-if+ switch (see |
2860 with the \lstinline+--enable-debug-if+ switch (see |
2748 sec.~\ref{sec:installation}). |
2861 \autoref{sec:installation}). |
2749 |
2862 |
2750 Every EtherCAT master registers a read-only network interface per attached |
2863 Every EtherCAT master registers a read-only network interface per attached |
2751 physical Ethernet device. The network interfaces are named \textit{ecdbgmX} |
2864 physical Ethernet device. The network interfaces are named \textit{ecdbgmX} |
2752 for the main device, and \textit{ecdbgbX} for the backup device (for future |
2865 for the main device, and \textit{ecdbgbX} for the backup device, where X is |
2753 use), where X is the master index. The below listing shows a debug interface |
2866 the master index. The below listing shows a debug interface among some |
2754 among some standard network interfaces: |
2867 standard network interfaces: |
2755 |
2868 |
2756 \begin{lstlisting} |
2869 \begin{lstlisting} |
2757 # `\textbf{ip link}` |
2870 # `\textbf{ip link}` |
2758 1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue |
2871 1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue |
2759 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
2872 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
3090 The below commands have to be entered as \textit{root}: The first one will |
3216 The below commands have to be entered as \textit{root}: The first one will |
3091 install the EtherCAT header, init script, sysconfig file and the userspace |
3217 install the EtherCAT header, init script, sysconfig file and the userspace |
3092 tool to the prefix path. The second one will install the kernel modules to the |
3218 tool to the prefix path. The second one will install the kernel modules to the |
3093 kernel's modules directory. The final \lstinline+depmod+ call is necessary to |
3219 kernel's modules directory. The final \lstinline+depmod+ call is necessary to |
3094 include the kernel modules into the \textit{modules.dep} file to make it |
3220 include the kernel modules into the \textit{modules.dep} file to make it |
3095 available to the \lstinline+modprobe+ command, used in the init script. |
3221 available to the \lstinline+modprobe+ command, used in the init script. |
3096 |
3222 |
3097 \begin{lstlisting} |
3223 \begin{lstlisting} |
3098 # `\textbf{make install}` |
3224 # `\textbf{make install}` |
3099 # `\textbf{make modules\_install}` |
3225 # `\textbf{make modules\_install}` |
3100 # `\textbf{depmod}` |
|
3101 \end{lstlisting} |
3226 \end{lstlisting} |
3102 |
3227 |
3103 If the target kernel's modules directory is not under \textit{/lib/modules}, a |
3228 If the target kernel's modules directory is not under \textit{/lib/modules}, a |
3104 different destination directory can be specified with the \lstinline+DESTDIR+ |
3229 different destination directory can be specified with the \lstinline+DESTDIR+ |
3105 make variable. For example: |
3230 make variable. For example: |
3111 This command will install the compiled kernel modules to |
3236 This command will install the compiled kernel modules to |
3112 \textit{/vol/nfs/root/lib/modules}, prepended by the kernel release. |
3237 \textit{/vol/nfs/root/lib/modules}, prepended by the kernel release. |
3113 |
3238 |
3114 If the EtherCAT master shall be run as a service\footnote{Even if the EtherCAT |
3239 If the EtherCAT master shall be run as a service\footnote{Even if the EtherCAT |
3115 master shall not be loaded on system startup, the use of the init script is |
3240 master shall not be loaded on system startup, the use of the init script is |
3116 recommended for manual (un-)loading.} (see sec.~\ref{sec:system}), the init |
3241 recommended for manual (un-)loading.} (see \autoref{sec:system}), the init |
3117 script and the sysconfig file have to be copied (or linked) to the appropriate |
3242 script and the sysconfig file (or the systemd service file, respectively) have |
3118 locations. The below example is suitable for SUSE Linux. It may vary for other |
3243 to be copied (or linked) to the appropriate locations. The below example is |
3119 distributions. |
3244 suitable for SUSE Linux. It may vary for other distributions. |
3120 |
3245 |
3121 % FIXME relative ln -s? |
3246 % FIXME relative ln -s? |
3122 \begin{lstlisting} |
3247 \begin{lstlisting} |
3123 # `\textbf{cd /opt/etherlab}` |
3248 # `\textbf{cd /opt/etherlab}` |
3124 # `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` |
3249 # `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` |
3125 # `\textbf{ln -s etc/init.d/ethercat /etc/init.d/}` |
3250 # `\textbf{ln -s etc/init.d/ethercat /etc/init.d/}` |
3126 # `\textbf{insserv ethercat}` |
3251 # `\textbf{insserv ethercat}` |
3127 \end{lstlisting} |
3252 \end{lstlisting} |
3128 |
3253 |
3129 Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see |
3254 Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see |
3130 sec.~\ref{sec:sysconfig}) has to be customized. The minimal customization is |
3255 \autoref{sec:sysconfig}), or the configuration file |
3131 to set the \lstinline+MASTER0_DEVICE+ variable to the MAC address of the |
3256 \textit{/etc/ethercat.conf}, if using systemd, has to be customized. The |
3132 Ethernet device to use (or \lstinline+ff:ff:ff:ff:ff:ff+ to use the first |
3257 minimal customization is to set the \lstinline+MASTER0_DEVICE+ variable to the |
3133 device offered) and selecting the driver(s) to load via the |
3258 MAC address of the Ethernet device to use (or \lstinline+ff:ff:ff:ff:ff:ff+ to |
|
3259 use the first device offered) and selecting the driver(s) to load via the |
3134 \lstinline+DEVICE_MODULES+ variable. |
3260 \lstinline+DEVICE_MODULES+ variable. |
3135 |
3261 |
3136 After the basic configuration is done, the master can be started with the |
3262 After the basic configuration is done, the master can be started with the |
3137 below command: |
3263 below command: |
3138 |
3264 |
3139 \begin{lstlisting} |
3265 \begin{lstlisting} |
3140 # `\textbf{/etc/init.d/ethercat start}` |
3266 # `\textbf{/etc/init.d/ethercat start}` |
|
3267 \end{lstlisting} |
|
3268 |
|
3269 When using systemd, the following command can be used alternatively: |
|
3270 |
|
3271 \begin{lstlisting} |
|
3272 # `\textbf{ethercatctl start}` |
3141 \end{lstlisting} |
3273 \end{lstlisting} |
3142 |
3274 |
3143 At this time, the operation of the master can be observed by viewing the |
3275 At this time, the operation of the master can be observed by viewing the |
3144 Syslog\index{Syslog} messages, which should look like the ones below. If |
3276 Syslog\index{Syslog} messages, which should look like the ones below. If |
3145 EtherCAT slaves are connected to the master's EtherCAT device, the activity |
3277 EtherCAT slaves are connected to the master's EtherCAT device, the activity |
3237 \url{http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html}. October~15, |
3369 \url{http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html}. October~15, |
3238 2008. |
3370 2008. |
3239 |
3371 |
3240 \bibitem{lsb} Linux Standard Base. |
3372 \bibitem{lsb} Linux Standard Base. |
3241 \url{http://www.linuxfoundation.org/en/LSB}. August~9, 2006. |
3373 \url{http://www.linuxfoundation.org/en/LSB}. August~9, 2006. |
|
3374 |
|
3375 \bibitem{systemd} systemd System and Service Manager |
|
3376 \url{http://freedesktop.org/wiki/Software/systemd}. January~18, 2013. |
3242 |
3377 |
3243 \bibitem{wireshark} Wireshark. \url{http://www.wireshark.org}. 2008. |
3378 \bibitem{wireshark} Wireshark. \url{http://www.wireshark.org}. 2008. |
3244 |
3379 |
3245 \bibitem{automata} {\it Hopcroft, J.\,E.\ / Ullman, J.\,D.}: Introduction to |
3380 \bibitem{automata} {\it Hopcroft, J.\,E.\ / Ullman, J.\,D.}: Introduction to |
3246 Automata Theory, Languages and Computation. Adison-Wesley, Reading, |
3381 Automata Theory, Languages and Computation. Adison-Wesley, Reading, |