📄 corps.tex
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%% Fichier : corps.tex%%%%%%%%%%%%%%%%%%%%%%%%%%%\chapter{Introduction}%\clearemptydoublepage % Pour commencer sur une page impaire\newpage % Simple saut de page\section*{Introduction}%***********************\addcontentsline{toc}{section}{Introduction} % Pour affichage dans la table des mati鑢es This document describe the CANOpen layer.\section{What is CANopen}CANopen is a CAN based highter layer protocol. It defines some protocols to\begin{itemize}\item Configure a CAN network.\item Transmit data to a specific node or in broadcast.\item Administrate the network. For example detecting a not responding node.\end{itemize} The documentation can be found in the \emph{Can in automation} website :\\ \href{http://www.can-cia.de/canopen}{http://www.can-cia.de/canopen}.The most important document about CANopen is the normative \emph{CiA Draft Standard 301, version 4.02}.You can now download with no cost the specification in \emph{Can in automation} website.To continue reading this document, let us assume that you have read some papers introducing CANopen.\section{Our CANopen layer specification}\begin{itemize}\item Should be conform to the latest DS301. V.4.02 13 february 2002.\item Source code in C-ANSI.\item Master and Slave functionality implemented.\item Sending SYNC implemented.\item 1 SDO server per node.\item Unlimited SDO client.\item SDO transmission mode : normal, expedited download and upload.\item Unlimited PDO receive.\item Unlimited PDO transmit.\item Object Data type implemented : unsigned 8, unsigned 16, unsigned 32 bits.\item Slave state full implemented.\item NMT to change slave's state implemented.\item PDO transmission mode : on request, every reception of 0 to n SYNC, on event.\item NMT Heartbeat implemented : A node can monitor the heartbeats received from others nodes.\item NMT NodeGuard implemented.\item TIME (time Stamp) : Not implemented.\item EMCY (emergency objects) : Not implemented.\item The CANopen layer can manage only one CAN port.\end{itemize}\section{How to start}\subsection{Tools}The CANopen library is comming with some tools :\begin{itemize}\item Arbracan : The Linux Driver for the Adlink 7841 CAN-PCIboard. By Edouard Tisserand. It is working only on Linux kernel 2.4.\item the code to use a PCI or USB to CAN Peak system board. But we donot provide the driver (free download). It is working on Linux kernel2.4 and 2.6. It should work also on Windows while the peaksystemdriver has the same api for both systems.\item The code to make a master or slave node running on PC-Linux.compiled with the C GNU compiler.\item The code to make a master or slave node on a microcontroller Motorola MC9S12DP256 (HC12 family),compiled with the C GNU compiler.\item XML tools and php script to help the development. See below.\end {itemize}\subsection{To do a Linux node}To do a CANopen node running on PC-Linux, you need :\begin{itemize}\item At least one board Adlink 7841 CAN-PCI or a Peak system board.\item A linux distribution working on a Personal Computer, with akernel 2.4 if you wants to use the Adlink board, or 2.4 to 2.6 for aPeak system board.\item A Java runtime (optional but highly recommended).\item The PHP scripting language (optional but highly recommended).\end {itemize}\subsection{To do a Motorola HC12 node}To do a CANopen node running on a microncontroller Motorola MC9S12DP256 you need :\begin{itemize}\item A board with this chip. We are using the T-board from Electronikladden. At least about 40 kBytes of program memory.\item The compiler GNU gcc.\item A Java runtime (optional but highly recommended).\item The PHP scripting language (optional but highly recommended).\item A tool to flash the memory. (We are using the hight cost Lauterbach debugger).\end {itemize}\subsection {Running the examples}In \emph{CanOpen/} are 4 examples : \emph{AppliMaster\_Linux, AppliSlave\_Linux, AppliMaster\_HC12, AppliSlave\_HC12}.\\Usage : Connect only one master to one slave. Always start the slave first.\paragraph {What do the examples}The slave node is waiting a nodeguard from the master.The master is sending the nodeguard, and waiting for the response.Then, it sends some SDO to write on the slave dictionary to configure it :\begin{itemize}\item Whose mapped data to put in each PDO receive and transmit.\item Defines the transmission mode for the PDO transmit.\item Gives a COBID to each PDO. It is this operation which defines which PDO a nodeis sending or receiving from/to others nodes. It is a logical linking.\item Defines what are the heartbeats to receive from others nodes and the timeout values.\item Defines at what frequency the node must send its heartbeat.\end{itemize} After that, the master puts the slave in operational mode.The node is then sending every second the time in a PDO sent when receivinga SYNC, and a PDO with the minute value when it changes, by a PDO ent \emph{on event}.Every minutes the slave simulates an error, and sends to the master the errorCode andvalue in a PDO. Then, the master reset the error by a PDO.If a node is disconnected, by a reset for example, the other node complains because itdoes not receive any heartbeat.\subsubsection {Running a Linux node}\label{linuxnode}By default the project is compiling for a board PeakSystem.To change this, edit CanOpen/includeMakefileLinux and put INTERFACE=ADLINK\_7841\_ARBRACAN\paragraph {Installing the PCI-CAN or USB-CAN PeakSystem driver :}\begin {itemize}\item Download the driver at \href{http://www.peak-system.com/linux}{http://www.peak-system.com/linux}\item install it : \begin{verbatim}# uncompresstar xvzf peak-linux-driver.3.21.tar.gzcd peak-linux-driver-3.21#Read the Peak intallation document.su rootmake cleanmakemake installmodprobe pcan# Test :cd test./receivetest -f=/dev/pcan0 # connect the board to generator of can message.# If it does not receive the message, put a 120 ohm resistor in thenetwork.\end{verbatim}\end {itemize}\paragraph {Installing the PCI-CAN driver for Adlink 7841. (Linux 2.4only) :}\begin {itemize}\item Edit CanOpen/MakefileLinux and uncomment the lines concerningArbracan.\item Edit CanOpen/includeMakefileLinux and put INTERFACE=ADLINK\_7841\_ARBRACAN\item Compile CanFestival2. (See below)\item load Arbracan module :\begin{verbatim}cd CanOpen/ArbraCan/loadersu root./arbracan_250kbps start\end{verbatim}\end {itemize}\paragraph {compiling CanFestival2 : }\label{compileLinux}\begin{verbatim}cd CanOpenmake -f MakefileLinux depend clean all\end{verbatim}\paragraph {Connecting the nodes : }Connect the two ports of the board.One Can port is for the master node, the other is for a slave node.\paragraph {Starting the slave node : }Open a new console and type :\begin{verbatim}cd CanOpen/AppliSlave_LinuxappliSlave\end{verbatim}\paragraph {Starting the master node : }Open a new console and type :\begin{verbatim}cd CanOpen/AppliMaster_LinuxappliMaster\end{verbatim}\subsubsection {Running a HC12 node}\paragraph {compiling : }\begin{verbatim}cd CanOpenmake -f MakefileHC12 depend clean all\end{verbatim}It will compile all the CANopen code for HC12.\paragraph {flashing the memory : }Use your prefered loader ! If you are using a debugger Lauterbach, you can loadthe bash file : \emph{trace32\_flash\_programmer.cmm}.It loads directly the elf file.\paragraph {Connecting to a serial RS232 console : }Connect the portS(TxD0) of the HC12 to a console configuredat 19200 bauds 8N1, via a Max232 chip to adapt the electricals levels. On Linux, you can use \emph{minicom}.Connecting to a console is usefull to read the messages, but not required.\paragraph {Connecting to the CAN network : }Connect the port CAN0 (pin PM0, PM1) to the network via a CAN controller. On our board, the CAN controler is a PCA82C250 chip.\paragraph {starting the node : }Press the reset of your HC12 board.\subsubsection{Examples configuration tested}We have tested the library with a 3 nodes network :\begin{itemize}\item A master example.\item A slave example.\item A receive only node : CanAnalizer for IXXAT.\end{itemize} The configurations tested : \begin{itemize}\item AppliMaster\_Linux connected to AppliSlave\_Linux\item AppliMaster\_HC12 connected to AppliSlave\_Linux\item AppliMaster\_Linux connected to AppliSlave\_HC12\end{itemize} AppliMaster\_HC12 connected to AppliSlave\_HC12 have not been tested,but should work.\section {Developping a new node}The simplest way is to copy and rename one of the examples \emph{Applixxx}, and modify it.All your application must be done in this directory. If you wants to move the directoryoutside of \emph{CanOpen/}, you must modify the makefiles.\subsection {How is organised the CANopen library}\paragraph{CanOpen/CanOpenMain} Contains the .c files. They are target processor independant files.The only changes to do on theses filesis commenting or uncommenting the \#define at the top of the files to add or remove the debuggingcode.\paragraph{CanOpen/include}Contains the .h files.\begin{itemize}\item \emph{CanOpen/include/*.h} : target processor independant.\item \emph{CanOpen/include/linux} : Important definitions to fit the library to Linux. Edit the files \emph{applicfg.h} and \emph{timerhw.h}\item \emph{CanOpen/include/hc12} : Important definitions to fit the library to HCS12. Edit the files \emph{applicfg.h} and \emph{timerhw.h} \end{itemize} \paragraph{CanOpen/CanOpenDriverLinux}Contains the Linux CANopen driver for Linux. Need a PCI-CAN Adlink board. Should not be modified.\paragraph{CanOpen/CanOpenDriverLinuxPeak}Contains the Linux CANopen driver for Linux. Need a PCI-CAN or USB-CANPeakSystem board. Should not be modified.\paragraph{CanOpen/CanOpenDriverLinux}Contains the Linux CANopen driver for Linux. Should not be modified.\paragraph{CanOpen/CanOpenDriverHC12}Contains the CANopen driver part for HC12. Should not be modified. Ituses the port CAN0 (pin PM0 and PM1).\paragraph{CanOpen/Your\_application}The directory where you put your files.\\\emph{objdict.c} : It is a very important file, which contains the descritpion of the CANopen object dictionary of your node. It is difficult to adapt it by hand to your application, so we have developped some tools to generate it.\paragraph{Computing the object Dictionary : objdict.c}\begin{enumerate}\item Go to \emph{CanOpen/XML\_TOOLS/jaxe} and launch \emph{run\_objdict.sh}\\It loads Jaxe, with a XML-schema grammar for the description of an object dictionary.\\Jaxe is a XML editor in GPL licence that we are re-distributing. It needs a Java virtual machine.Edit with Jaxe your description save your file as \emph{objdict.xml}.Jaxe computes also the file \emph{objdict.html}, which is a human readable version of \emph{objdict.xml}.\item Loads then in your web browser the file \emph{makeobjetdict.php}. Of course, you have installed before a webserver with PHP oryou have a command line PHP version with Saxe support.\emph{makeobjetdict.php} reads the file \emph{objdict.xml} and compute \emph{objdict.c}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -