documentation/ethercat_doc.tex
branchstable-1.4
changeset 1664 0fd56b9fbd38
parent 1663 d1adfbdfa2a2
child 1665 c2dae2d88d31
equal deleted inserted replaced
1663:d1adfbdfa2a2 1664:0fd56b9fbd38
   388 
   388 
   389 \end{description}
   389 \end{description}
   390 
   390 
   391 %------------------------------------------------------------------------------
   391 %------------------------------------------------------------------------------
   392 
   392 
   393 \section{General Behavior} % FIXME
   393 \section{General Behavior}
   394 \index{Master behavior}
   394 \index{Master behavior}
   395 
   395 
   396 \ldots
   396 \ldots
   397 
   397 
   398 %   Behavior (Scanning) TODO
   398 % TODO Behavior (Scanning)
   399 
   399 
   400 %------------------------------------------------------------------------------
   400 %------------------------------------------------------------------------------
   401 
   401 
   402 \section{Master Module}
   402 \section{Master Module}
   403 \label{sec:mastermod}
   403 \label{sec:mastermod}
   551 
   551 
   552 \chapter{Application Interface}
   552 \chapter{Application Interface}
   553 \label{chap:api}
   553 \label{chap:api}
   554 \index{Application interface}
   554 \index{Application interface}
   555 
   555 
   556 %   Interface version
   556 % TODO
   557 %   Master Requesting and Releasing
   557 %
   558 %   Master Locking
   558 % Interface version
   559 %   Configuring Pdo assignment and mapping
   559 % Master Requesting and Releasing
   560 %   Domains (memory)
   560 % Master Locking
   561 %   Pdo entry registration
   561 % Configuring Pdo assignment and mapping
   562 %   Sdo configuration
   562 % Domains (memory)
   563 %   Sdo access
   563 % Pdo entry registration
       
   564 % Sdo configuration
       
   565 % Sdo access
   564 
   566 
   565 The application interface provides functions and data structures for
   567 The application interface provides functions and data structures for
   566 applications to access an EtherCAT master. The complete documentation of the
   568 applications to access an EtherCAT master. The complete documentation of the
   567 interface is included as Doxygen~\cite{doxygen} comments in the header file
   569 interface is included as Doxygen~\cite{doxygen} comments in the header file
   568 \textit{include/ecrt.h}. It can either be read directly from the file
   570 \textit{include/ecrt.h}. It can either be read directly from the file
   690 To enter cyclic operation mode, the master has to be ``activated'' to
   692 To enter cyclic operation mode, the master has to be ``activated'' to
   691 calculate the process data image and apply the bus configuration for the first
   693 calculate the process data image and apply the bus configuration for the first
   692 time. After activation, the application is in charge to send and receive
   694 time. After activation, the application is in charge to send and receive
   693 frames.
   695 frames.
   694 
   696 
   695 % TODO PDOS endianess
   697 % TODO
   696 % TODO Datagram injection
   698 %
       
   699 % PDO endianess
       
   700 % Datagram injection
   697 
   701 
   698 %------------------------------------------------------------------------------
   702 %------------------------------------------------------------------------------
   699 
   703 
   700 \section{Concurrent Master Access}
   704 \section{Concurrent Master Access}
   701 \label{sec:concurr}
   705 \label{sec:concurr}
   816 
   820 
   817 \item[\usebox\boxopen] This function is called when network communication has
   821 \item[\usebox\boxopen] This function is called when network communication has
   818 to be started, for example after a command \lstinline+ip link set ethX up+
   822 to be started, for example after a command \lstinline+ip link set ethX up+
   819 from userspace. Frame reception has to be enabled by the driver.
   823 from userspace. Frame reception has to be enabled by the driver.
   820 
   824 
   821 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the device,
   825 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the
   822 i.~e.  make the hardware stop receiving frames.
   826 device, i.~e. make the hardware stop receiving frames.
   823 
   827 
   824 \item[\usebox\boxxmit] This function is called for each frame that has to be
   828 \item[\usebox\boxxmit] This function is called for each frame that has to be
   825 transmitted. The network stack passes the frame as a pointer to an
   829 transmitted. The network stack passes the frame as a pointer to an
   826 \lstinline+sk_buff+ structure (``socket buffer''\index{Socket buffer}, see
   830 \lstinline+sk_buff+ structure (``socket buffer''\index{Socket buffer}, see
   827 below), which has to be freed after sending.
   831 below), which has to be freed after sending.
   999 
  1003 
  1000 The documentation of the device interface can be found in the header file or
  1004 The documentation of the device interface can be found in the header file or
  1001 in the appropriate module of the interface documentation (see
  1005 in the appropriate module of the interface documentation (see
  1002 sec.~\ref{sec:gendoc} for generation instructions).
  1006 sec.~\ref{sec:gendoc} for generation instructions).
  1003 
  1007 
  1004 \ldots % FIXME general description of the device interface
  1008 % TODO general description of the device interface
  1005 
  1009 
  1006 %------------------------------------------------------------------------------
  1010 %------------------------------------------------------------------------------
  1007 
  1011 
  1008 \section{Patching Network Drivers}
  1012 \section{Patching Network Drivers}
  1009 \label{sec:patching}
  1013 \label{sec:patching}
  1872 \index{CoE}
  1876 \index{CoE}
  1873 
  1877 
  1874 The CANopen-over-EtherCAT protocol \cite[sec.~5.6]{alspec} is used to
  1878 The CANopen-over-EtherCAT protocol \cite[sec.~5.6]{alspec} is used to
  1875 configure slaves and exchange data objects on application level.
  1879 configure slaves and exchange data objects on application level.
  1876 
  1880 
  1877 % FIXME
  1881 % TODO
  1878 %
  1882 %
  1879 % Download / Upload
  1883 % Download / Upload
  1880 % Expedited / Normal
  1884 % Expedited / Normal
  1881 % Segmenting
  1885 % Segmenting
  1882 % Sdo Info Services
  1886 % Sdo Info Services
  1973 %------------------------------------------------------------------------------
  1977 %------------------------------------------------------------------------------
  1974 
  1978 
  1975 \section{Command-line Tool}
  1979 \section{Command-line Tool}
  1976 \label{sec:tool}
  1980 \label{sec:tool}
  1977 
  1981 
  1978 % --master
  1982 % TODO --master
  1979 
  1983 
  1980 \subsection{Character Devices}
  1984 \subsection{Character Devices}
  1981 \label{sec:cdev}
  1985 \label{sec:cdev}
  1982 
  1986 
  1983 Each master instance will get a character device as a userspace interface.
  1987 Each master instance will get a character device as a userspace interface.
  2315 
  2319 
  2316 \subsection{Bus Cycle Measuring}
  2320 \subsection{Bus Cycle Measuring}
  2317 \label{sec:timing-bus}
  2321 \label{sec:timing-bus}
  2318 \index{Bus cycle}
  2322 \index{Bus cycle}
  2319 
  2323 
  2320 For measuring the time, a frame is ``on the wire'', two timestamps
  2324 For measuring the time, a frame is ``on the wire'', two timestamps must be
  2321 must be be taken:
  2325 taken:
  2322 
  2326 
  2323 \begin{enumerate}
  2327 \begin{enumerate}
  2324 \item The time, the Ethernet hardware begins with physically sending
  2328 
  2325   the frame.
  2329 \item The time, the Ethernet hardware begins with physically sending the
  2326 \item The time, the frame is completely received by the Ethernet
  2330 frame.
  2327   hardware.
  2331 
       
  2332 \item The time, the frame is completely received by the Ethernet hardware.
       
  2333 
  2328 \end{enumerate}
  2334 \end{enumerate}
  2329 
  2335 
  2330 Both times are difficult to determine. The first reason is, that the
  2336 Both times are difficult to determine. The first reason is, that the
  2331 interrupts are disabled and the master is not notified, when a frame
  2337 interrupts are disabled and the master is not notified, when a frame is sent
  2332 is sent or received (polling would distort the results). The second
  2338 or received (polling would distort the results). The second reason is, that
  2333 reason is, that even with interrupts enabled, the time from the event
  2339 even with interrupts enabled, the time from the event to the notification is
  2334 to the notification is unknown. Therefore the only way to confidently
  2340 unknown. Therefore the only way to confidently determine the bus cycle time is
  2335 determine the bus cycle time is an electrical measuring.
  2341 an electrical measuring.
  2336 
  2342 
  2337 Anyway, the bus cycle time is an important factor when designing realtime
  2343 Anyway, the bus cycle time is an important factor when designing realtime
  2338 code, because it limits the maximum frequency for the cyclic task of the
  2344 code, because it limits the maximum frequency for the cyclic task of the
  2339 application.  In practice, these timing parameters are highly dependent on the
  2345 application.  In practice, these timing parameters are highly dependent on the
  2340 hardware and often a trial and error method must be used to determine the
  2346 hardware and often a trial and error method must be used to determine the
  2341 limits of the system.
  2347 limits of the system.
  2342 
  2348 
  2343 The central question is: What happens, if the cycle frequency is too high? The
  2349 The central question is: What happens, if the cycle frequency is too high? The
  2344 answer is, that the EtherCAT frames that have been sent at the end of the cycle
  2350 answer is, that the EtherCAT frames that have been sent at the end of the
  2345 are not yet received, when the next cycle starts.  First this is noticed by
  2351 cycle are not yet received, when the next cycle starts.  First this is noticed
  2346 \textit{ecrt\_domain\_process()}, because the working counter of the process
  2352 by \textit{ecrt\_domain\_process()}, because the working counter of the
  2347 data datagrams were not increased. The function will notify the user via
  2353 process data datagrams were not increased. The function will notify the user
  2348 Syslog\footnote{To limit Syslog output, a mechanism has been implemented, that
  2354 via Syslog\footnote{To limit Syslog output, a mechanism has been implemented,
  2349 outputs a summarized notification at maximum once a second.}. In this case, the
  2355 that outputs a summarized notification at maximum once a second.}. In this
  2350 process data keeps being the same as in the last cycle, because it is not
  2356 case, the process data keeps being the same as in the last cycle, because it
  2351 erased by the domain. When the domain datagrams are queued again, the master
  2357 is not erased by the domain. When the domain datagrams are queued again, the
  2352 notices, that they are already queued (and marked as sent). The master will
  2358 master notices, that they are already queued (and marked as sent). The master
  2353 mark them as unsent again and output a warning, that datagrams were
  2359 will mark them as unsent again and output a warning, that datagrams were
  2354 ``skipped''.
  2360 ``skipped''.
  2355 
  2361 
  2356 On the mentioned \unit{2.0}{\giga\hertz} system, the possible cycle frequency
  2362 On the mentioned \unit{2.0}{\giga\hertz} system, the possible cycle frequency
  2357 can be up to \unit{25}{\kilo\hertz} without skipped frames. This value can
  2363 can be up to \unit{25}{\kilo\hertz} without skipped frames. This value can
  2358 surely be increased by choosing faster hardware. Especially the RealTek network
  2364 surely be increased by choosing faster hardware. Especially the RealTek
  2359 hardware could be replaced by a faster one. Besides, implementing a dedicated
  2365 network hardware could be replaced by a faster one. Besides, implementing a
  2360 ISR for EtherCAT devices would also contribute to increasing the latency. These
  2366 dedicated ISR for EtherCAT devices would also contribute to increasing the
  2361 are two points on the author's to-do list.
  2367 latency. These are two points on the author's to-do list.
  2362 
  2368 
  2363 %------------------------------------------------------------------------------
  2369 %------------------------------------------------------------------------------
  2364 
  2370 
  2365 \chapter{Installation}
  2371 \chapter{Installation}
  2366 \label{sec:installation}
  2372 \label{sec:installation}
  2497 to set the \lstinline+MASTER0_DEVICE+ variable to the MAC address of the
  2503 to set the \lstinline+MASTER0_DEVICE+ variable to the MAC address of the
  2498 Ethernet device to use (or \lstinline+ff:ff:ff:ff:ff:ff+ to use the first
  2504 Ethernet device to use (or \lstinline+ff:ff:ff:ff:ff:ff+ to use the first
  2499 device offered) and selecting the driver(s) to load via the
  2505 device offered) and selecting the driver(s) to load via the
  2500 \lstinline+DEVICE_MODULES+ variable.
  2506 \lstinline+DEVICE_MODULES+ variable.
  2501 
  2507 
  2502 After the basic configuration is done, the master can be started with
  2508 After the basic configuration is done, the master can be started with the
  2503 the below command:
  2509 below command:
  2504 
  2510 
  2505 \begin{lstlisting}
  2511 \begin{lstlisting}
  2506 # `\textbf{/etc/init.d/ethercat start}`
  2512 # `\textbf{/etc/init.d/ethercat start}`
  2507 \end{lstlisting}
  2513 \end{lstlisting}
  2508 
  2514