208
|
1 |
\documentclass[12pt,twoside]{article}
|
|
2 |
\usepackage[ascii]{inputenc}
|
|
3 |
\usepackage[T1]{fontenc}
|
|
4 |
\usepackage[french,english]{babel}
|
|
5 |
\usepackage{amsmath,amssymb,amsfonts,textcomp}
|
|
6 |
\usepackage{color}
|
|
7 |
\usepackage{calc}
|
|
8 |
\usepackage{longtable}
|
|
9 |
\usepackage{hyperref}
|
|
10 |
\usepackage{graphics}
|
|
11 |
\usepackage{graphicx}
|
|
12 |
\DeclareGraphicsExtensions{.jpg}
|
|
13 |
\DeclareGraphicsExtensions{.png}
|
|
14 |
\hypersetup{colorlinks=true, linkcolor=blue, filecolor=blue, pagecolor=blue, urlcolor=blue}
|
|
15 |
|
|
16 |
\newenvironment{changemargin}[2]{\begin{list}{}{%
|
|
17 |
\setlength{\topsep}{0pt}%
|
|
18 |
\setlength{\leftmargin}{0pt}%
|
|
19 |
\setlength{\rightmargin}{0pt}%
|
|
20 |
\setlength{\listparindent}{\parindent}%
|
|
21 |
\setlength{\itemindent}{\parindent}%
|
|
22 |
\setlength{\parsep}{0pt plus 1pt}%
|
|
23 |
\addtolength{\leftmargin}{#1}%
|
|
24 |
\addtolength{\rightmargin}{#2}%
|
|
25 |
}\item }{\end{list}}
|
|
26 |
|
|
27 |
|
|
28 |
%%%%\%%%%%%%% titre, auteurs, date, etc...%%%%%%%%%%%%%%%%%%
|
|
29 |
|
|
30 |
\title{\Huge Documentation}
|
|
31 |
\author{Edouard TISSERANT}
|
|
32 |
\date{\today}
|
|
33 |
|
|
34 |
% Text styles
|
|
35 |
\newcommand\textstyleTeletype[1]{\texttt{#1}}
|
|
36 |
% Outline numbering
|
|
37 |
\setcounter{secnumdepth}{5}
|
|
38 |
\renewcommand\thesection{\arabic{section} -}
|
|
39 |
\renewcommand\thesubsection{\arabic{section}.\arabic{subsection})}
|
|
40 |
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection})}
|
|
41 |
\renewcommand\theparagraph{\alph{paragraph})}
|
|
42 |
\renewcommand\thesubparagraph{\roman{subparagraph})}
|
|
43 |
% List styles
|
|
44 |
\newcommand\liststyleLi{%
|
|
45 |
\renewcommand\labelitemi{{--}}
|
|
46 |
\renewcommand\labelitemii{{--}}
|
|
47 |
\renewcommand\labelitemiii{{--}}
|
|
48 |
\renewcommand\labelitemiv{{--}}
|
|
49 |
}
|
|
50 |
\newcommand\liststyleLii{%
|
|
51 |
\renewcommand\labelitemi{{--}}
|
|
52 |
\renewcommand\labelitemii{{--}}
|
|
53 |
\renewcommand\labelitemiii{{--}}
|
|
54 |
\renewcommand\labelitemiv{{--}}
|
|
55 |
}
|
|
56 |
\newcommand\liststyleLiii{%
|
|
57 |
\renewcommand\labelitemi{{--}}
|
|
58 |
\renewcommand\labelitemii{{--}}
|
|
59 |
\renewcommand\labelitemiii{{--}}
|
|
60 |
\renewcommand\labelitemiv{{--}}
|
|
61 |
}
|
|
62 |
\newcommand\liststyleLiv{%
|
|
63 |
\renewcommand\labelitemi{{--}}
|
|
64 |
\renewcommand\labelitemii{{--}}
|
|
65 |
\renewcommand\labelitemiii{{--}}
|
|
66 |
\renewcommand\labelitemiv{{--}}
|
|
67 |
}
|
|
68 |
\newcommand\liststyleLv{%
|
|
69 |
\renewcommand\labelitemi{{--}}
|
|
70 |
\renewcommand\labelitemii{{--}}
|
|
71 |
\renewcommand\labelitemiii{{--}}
|
|
72 |
\renewcommand\labelitemiv{{--}}
|
|
73 |
}
|
|
74 |
\newcommand\liststyleLvi{%
|
|
75 |
\renewcommand\labelitemi{{--}}
|
|
76 |
\renewcommand\labelitemii{{--}}
|
|
77 |
\renewcommand\labelitemiii{{--}}
|
|
78 |
\renewcommand\labelitemiv{{--}}
|
|
79 |
}
|
|
80 |
\newcommand\liststyleLvii{%
|
|
81 |
\renewcommand\labelitemi{{--}}
|
|
82 |
\renewcommand\labelitemii{{--}}
|
|
83 |
\renewcommand\labelitemiii{{--}}
|
|
84 |
\renewcommand\labelitemiv{{--}}
|
|
85 |
}
|
|
86 |
\newcommand\liststyleLviii{%
|
|
87 |
\renewcommand\labelitemi{{--}}
|
|
88 |
\renewcommand\labelitemii{{--}}
|
|
89 |
\renewcommand\labelitemiii{{--}}
|
|
90 |
\renewcommand\labelitemiv{{--}}
|
|
91 |
}
|
|
92 |
\newcommand\liststyleLix{%
|
|
93 |
\renewcommand\labelitemi{{--}}
|
|
94 |
\renewcommand\labelitemii{{--}}
|
|
95 |
\renewcommand\labelitemiii{{--}}
|
|
96 |
\renewcommand\labelitemiv{{--}}
|
|
97 |
}
|
|
98 |
\newcommand\liststyleLx{%
|
|
99 |
\renewcommand\labelitemi{{--}}
|
|
100 |
\renewcommand\labelitemii{{--}}
|
|
101 |
\renewcommand\labelitemiii{{--}}
|
|
102 |
\renewcommand\labelitemiv{{--}}
|
|
103 |
}
|
|
104 |
\newcommand\liststyleLxi{%
|
|
105 |
\renewcommand\labelitemi{{--}}
|
|
106 |
\renewcommand\labelitemii{{--}}
|
|
107 |
\renewcommand\labelitemiii{{--}}
|
|
108 |
\renewcommand\labelitemiv{{--}}
|
|
109 |
}
|
|
110 |
\newcommand\liststyleLxii{%
|
|
111 |
\renewcommand\labelitemi{{--}}
|
|
112 |
\renewcommand\labelitemii{{--}}
|
|
113 |
\renewcommand\labelitemiii{{--}}
|
|
114 |
\renewcommand\labelitemiv{{--}}
|
|
115 |
}
|
|
116 |
\newcommand\liststyleLxiii{%
|
|
117 |
\renewcommand\labelitemi{{\textbullet}}
|
|
118 |
\renewcommand\labelitemii{{\textbullet}}
|
|
119 |
\renewcommand\labelitemiii{{\textbullet}}
|
|
120 |
\renewcommand\labelitemiv{{\textbullet}}
|
|
121 |
}
|
|
122 |
% Pages styles (master pages)
|
|
123 |
\makeatletter
|
|
124 |
\newcommand\ps@Standard{%
|
|
125 |
\renewcommand\@oddhead{}%
|
|
126 |
\renewcommand\@evenhead{}%
|
|
127 |
\renewcommand\@oddfoot{}%
|
|
128 |
\renewcommand\@evenfoot{\@oddfoot}%
|
|
129 |
\setlength\paperwidth{8.2673in}\setlength\paperheight{11.6925in}\setlength\voffset{-1in}\setlength\hoffset{-1in}\setlength\topmargin{0.1965in}\setlength\headheight{12pt}\setlength\headsep{0cm}\setlength\footskip{12pt+0.1965in}\setlength\textheight{11.6925in-0.1965in-0.7874in-0cm-12pt-0.1965in-12pt}\setlength\oddsidemargin{0.3937in}\setlength\textwidth{8.2673in-0.3937in-0.3937in}
|
|
130 |
\renewcommand\thepage{\arabic{page}}
|
|
131 |
\setlength{\skip\footins}{0.0398in}\renewcommand\footnoterule{\vspace*{-0.0071in}\noindent\textcolor{black}{\rule{0.25\columnwidth}{0.0071in}}\vspace*{0.0398in}}
|
|
132 |
}
|
|
133 |
\makeatother
|
|
134 |
\pagestyle{Standard}
|
|
135 |
\setlength\tabcolsep{1mm}
|
|
136 |
\renewcommand\arraystretch{1.3}
|
|
137 |
\begin{document}
|
|
138 |
{\centering\sffamily
|
|
139 |
CanFestival3. Version 3.0\newline
|
|
140 |
The CANOpen stack manual
|
|
141 |
\par}
|
|
142 |
|
|
143 |
\setcounter{tocdepth}{2}
|
|
144 |
\renewcommand\contentsname{Table of contents}
|
|
145 |
\tableofcontents
|
|
146 |
\section{Introduction}
|
|
147 |
This document describe the CANOpen layer.CanFestival is an OpenSource
|
|
148 |
(LGPL) CANOpen framework.
|
|
149 |
|
|
150 |
\subsection{The CanFestival project}
|
|
151 |
This project, initiated by Edouard TISSERANT in 2001, as grown thanks to
|
|
152 |
Francis DUPIN and other contributors.
|
|
153 |
|
|
154 |
Today, CanFestival focuses on providing an ANSI{}-C platform independent
|
|
155 |
CANOpen stack that can be implemented as master or slave nodes on PCs,
|
|
156 |
Real{}-time IPCs, and Microcontrollers.
|
|
157 |
|
|
158 |
CanFestival is a project supported by Lolitech.
|
|
159 |
|
|
160 |
\subsection{What is CANopen}
|
|
161 |
CANopen is a CAN based high level protocol. It defines some protocols to
|
|
162 |
:
|
|
163 |
|
|
164 |
\liststyleLi
|
|
165 |
\begin{enumerate}
|
|
166 |
\item Configure a CAN network.
|
|
167 |
\item Transmit data to a specific node or in broadcast.
|
|
168 |
\item Administrate the network. For example detecting a not responding
|
|
169 |
node.
|
|
170 |
\end{enumerate}
|
|
171 |
The documentation can be found in the Can in automation website :
|
|
172 |
|
|
173 |
\href{http://www.can-cia.de/canopen}{http://www.can{}-cia.de/canopen}
|
|
174 |
|
|
175 |
The most important document about CANopen is the normative CiA Draft
|
|
176 |
Standard 301, version 4.02. You can now download with no cost the
|
|
177 |
specification in Can in automation website.
|
|
178 |
|
|
179 |
To continue reading this document, let us assume that you have read some
|
|
180 |
papers introducing CANopen.
|
|
181 |
|
|
182 |
\section{CanFestival Features}
|
|
183 |
\subsection{Tools }
|
|
184 |
The CANopen library is coming with some tools :
|
|
185 |
|
|
186 |
\liststyleLii
|
|
187 |
\begin{enumerate}
|
|
188 |
\item Object Dictionary editor GUI. WxPython Model{}-View{}-Controler
|
|
189 |
based GUI, that help a lot in generating object dictionary source code
|
|
190 |
for each node.
|
|
191 |
\item A configure script, that let you chose compile time options such
|
|
192 |
as target CPU/HOST, CAN and TIMER drivers.\newline
|
|
193 |
This script have not been generated with autoconf, it have been made
|
|
194 |
keeping micro{}-controller target in mind.
|
|
195 |
\end{enumerate}
|
|
196 |
\subsection{Standard conformance}
|
|
197 |
\paragraph{Multi{}-Platform}
|
|
198 |
\liststyleLiii
|
|
199 |
\begin{enumerate}
|
|
200 |
\item Library source code is C{}-ANSI.
|
|
201 |
\item Driver and examples coding conventions merely depend on target
|
|
202 |
specific contributor/compiler.
|
|
203 |
\item Unix compatible interfaces and examples should compile and run on
|
|
204 |
any Unix system (tested on GNU/Linux and GNU/FreeBSD).
|
|
205 |
\end{enumerate}
|
|
206 |
\paragraph{CanOpen conformance}
|
|
207 |
{\bfseries\upshape
|
|
208 |
DS{}-301}
|
|
209 |
|
|
210 |
\liststyleLiv
|
|
211 |
\begin{enumerate}
|
|
212 |
\item Should conform to DS301. V.4.02 13 february 2002.
|
|
213 |
\item Master and Slave functionality implemented.
|
|
214 |
\item Sending SYNC implemented.
|
|
215 |
\item 1 SDO server per node. (update: more than one possible. To be more
|
|
216 |
tested)
|
|
217 |
\item Unlimited SDO client.
|
|
218 |
\item SDO transmission mode : normal, expedited download and upload.
|
|
219 |
\item Unlimited PDO receive.
|
|
220 |
\item Unlimited PDO transmit.
|
|
221 |
\item Object Data type implemented : 8, 16, 32 bits values, and fixed
|
|
222 |
length strings.
|
|
223 |
\item Slave state full implemented.
|
|
224 |
\item NMT to change slave{\textquotesingle}s state implemented.
|
|
225 |
\item PDO transmission mode : on request, every reception of 0 to n
|
|
226 |
SYNC, on event.
|
|
227 |
\item NMT Heartbeat implemented : A node can be either heartbeat
|
|
228 |
producer or receiver.
|
|
229 |
\item NMT NodeGuard implemented : Not fully implemented.
|
|
230 |
\item TIME (time Stamp) : Not implemented.
|
|
231 |
\item EMCY (emergency objects) : Not implemented.
|
|
232 |
\item PDO Mapping bit per bit implemented.
|
|
233 |
\end{enumerate}
|
|
234 |
{\bfseries\upshape
|
|
235 |
DS{}-302}
|
|
236 |
|
|
237 |
\liststyleLiv
|
|
238 |
\begin{enumerate}
|
|
239 |
\item Concise \ DFC : implemented.
|
|
240 |
\end{enumerate}
|
|
241 |
\section{How to start}
|
|
242 |
\subsection{Host requirements}
|
|
243 |
What you need on your development workstation.
|
|
244 |
|
|
245 |
\subsubsection{Object Dictionary Editor GUI}
|
|
246 |
\liststyleLv
|
|
247 |
\begin{enumerate}
|
|
248 |
\item Python, with
|
|
249 |
\item wxPyhon modules installed (at least version 2.6.3).
|
|
250 |
\item Gnosis xml tools. (Optional can also be installed locally to the
|
|
251 |
project automatically will the help of a Makefile. Please see
|
|
252 |
\hyperlink{a91UsingDictionaryEditorGUIoutline}{9.1) Using Dictionary
|
|
253 |
Editor GUI} )
|
|
254 |
\end{enumerate}
|
|
255 |
\subsubsection[\ Linux and Unix{}-likes]{\ Linux and Unix{}-likes}
|
|
256 |
\liststyleLv
|
|
257 |
\begin{enumerate}
|
|
258 |
\item Linux, FreeBSD, Cygwin or any Unix environment with GNU toolchain.
|
|
259 |
\item The GNU C compiler (gcc) or any other ANSI{}-C compiler for your
|
|
260 |
target platform.
|
|
261 |
\item Xpdf, and the official 301\_v04000201.pdf file in order to get GUI
|
|
262 |
context sensitive help. Download the ds301 at
|
|
263 |
\href{http://www.can-cia.org/downloads/ciaspecifications/?1390}{http://www.can{}-cia.org/downloads/ciaspecifications/?1390}.
|
|
264 |
\item GNU Make
|
|
265 |
\item Bash and sed
|
|
266 |
\end{enumerate}
|
|
267 |
\subsubsection{Windows (for native win32 target)}
|
|
268 |
\liststyleLv
|
|
269 |
\begin{enumerate}
|
|
270 |
\item Visual Studio Express 2005 or worst.
|
|
271 |
\item Microsoft platform SDK (requires Genuine Advantage)
|
|
272 |
\item Cygwin (for configuration only)
|
|
273 |
\end{enumerate}
|
|
274 |
\subsection{How to get CanFestival}
|
|
275 |
Please always use CVS, this is the best way to get the most reactive
|
|
276 |
support from the developer community :
|
|
277 |
|
|
278 |
cvs {}-d:pserver:anonymous@lolitech.dyndns.org:/canfestival
|
|
279 |
login\newline
|
|
280 |
(type return, without entering a password)
|
|
281 |
|
|
282 |
Then, enter : \newline
|
|
283 |
cvs {}-z3 {}-d:pserver:anonymous@lolitech.dyndns.org:/canfestival co
|
|
284 |
{}-P CanFestival{}-3
|
|
285 |
|
|
286 |
\section{Understanding Canfestival}
|
|
287 |
\subsection{CanFestival Project tree layout}
|
|
288 |
Simplified directory structure.
|
|
289 |
|
|
290 |
{\ttfamily\bfseries
|
|
291 |
./src ANSI{}-C source of CANOpen stack}
|
|
292 |
|
|
293 |
{\ttfamily\bfseries
|
|
294 |
\ /include Exportables Header files}
|
|
295 |
|
|
296 |
{\ttfamily\bfseries
|
|
297 |
./drivers Interfaces to specific platforms/HW}
|
|
298 |
|
|
299 |
{\ttfamily
|
|
300 |
./drivers/unix Linux and Cygwin OS interface}
|
|
301 |
|
|
302 |
{\ttfamily
|
|
303 |
./drivers/win32 Native Win32 OS interface}
|
|
304 |
|
|
305 |
{\ttfamily
|
|
306 |
./drivers/timers\_xeno Xenomai timers/threads (Linux only)}
|
|
307 |
|
|
308 |
{\ttfamily
|
|
309 |
./drivers/timers\_unix Posix timers/threads (Linux, Cygwin)}
|
|
310 |
|
|
311 |
{\ttfamily
|
|
312 |
./drivers/can\_peak\_linux PeakSystem CAN library interface}
|
|
313 |
|
|
314 |
{\ttfamily
|
|
315 |
./drivers/can\_peak\_win32 PeakSystem PCAN{}-Light interface}
|
|
316 |
|
|
317 |
{\ttfamily
|
|
318 |
./drivers/can\_uvccm\_win32 Acacetus{\textquotesingle}s RS232
|
|
319 |
``CAN{}-uVCCM'' interface}
|
|
320 |
|
|
321 |
{\ttfamily
|
|
322 |
./drivers/can\_virtual Fake CAN network (Linux, Cygwin)}
|
|
323 |
|
|
324 |
{\ttfamily
|
|
325 |
./drivers/hcs12 HCS12 full target interface}
|
|
326 |
|
|
327 |
{\ttfamily\bfseries
|
|
328 |
./examples Examples}
|
|
329 |
|
|
330 |
{\ttfamily
|
|
331 |
./examples/TestMasterSlave 2 nodes, NMT SYNC SDO PDO, win32+unix}
|
|
332 |
|
|
333 |
{\ttfamily
|
|
334 |
./examples/TestMasterMicroMod 1 node, control Peak I/O Module, unix}
|
|
335 |
|
|
336 |
{\ttfamily
|
|
337 |
./examples/gene\_SYNC\_HCS12 Just send periodic SYNC on HCS12}
|
|
338 |
|
|
339 |
{\ttfamily
|
|
340 |
./examples/win32test Ask some DS301 infos to a node (\textbf{win32)}}
|
|
341 |
|
|
342 |
{\ttfamily\bfseries
|
|
343 |
./objdictgen Object Dictionary editor GUI}
|
|
344 |
|
|
345 |
{\ttfamily
|
|
346 |
./objdictgen/config Pre{}-defined OD profiles}
|
|
347 |
|
|
348 |
{\ttfamily
|
|
349 |
./objdictgen/examples Some examples/test OD}
|
|
350 |
|
|
351 |
{\ttfamily\bfseries
|
|
352 |
./doc Project and CanOpen doc}
|
|
353 |
|
|
354 |
\subsection{Implement CanFestival in your application}
|
|
355 |
|
|
356 |
\begin{center}
|
|
357 |
\includegraphics[width=20cm]{Pictures/10000201000003F9000002CF880931E7.png}
|
|
358 |
\end{center}
|
|
359 |
|
|
360 |
\bigskip
|
|
361 |
|
|
362 |
\subsection{CanFestival CAN interfaces}
|
|
363 |
Because most CAN controllers and drivers implement FIFOs, CanFestival
|
|
364 |
consider sending message as a non bloking operation.
|
|
365 |
|
|
366 |
In order to prevent reentrent calls to the stack, messages reception is
|
|
367 |
implemented differently on {\textmu}C and OS.:
|
|
368 |
|
|
369 |
\liststyleLvi
|
|
370 |
\begin{enumerate}
|
|
371 |
\item {\textmu}C must provide interuption masking for timer and can
|
|
372 |
receive IT\newline
|
|
373 |
\begin{center}
|
211
|
374 |
\includegraphics[width=16cm]{Pictures/10000201000003CA0000016604E6A5EF.png}
|
208
|
375 |
\end{center}
|
|
376 |
\item OS must provide a receive thread, a timer thread and a mutex. CAN
|
|
377 |
reception is a bloking operation.\newline
|
|
378 |
\begin{center}
|
211
|
379 |
\includegraphics[width=16cm]{Pictures/10000201000003F9000002CF8B0CDAEA.png}
|
208
|
380 |
\end{center}
|
|
381 |
\end{enumerate}
|
|
382 |
\subsection{CanFestival events scheduling}
|
|
383 |
A CanOpen node must be able to take delayed actions.
|
|
384 |
|
|
385 |
As exemples, periodic sync emission, heartbeat production or SDO timeout
|
|
386 |
need to set some alarms that will be called later and do the job.
|
|
387 |
|
|
388 |
{\textmu}C generaly do not have enough free timers to handle all the
|
|
389 |
CanOpen needs directly. Moreover, CanFestival internal data may be
|
|
390 |
corrupt by reentrant calls.
|
|
391 |
|
|
392 |
CanFestival implement a micro{}-scheduler (timer.c). It uses only one
|
|
393 |
timer to mimic many timers. It manage an alarm table, and call alarms
|
|
394 |
at desired time.
|
|
395 |
|
|
396 |
\begin{center}
|
211
|
397 |
\includegraphics[width=13cm]{Pictures/100000000000022C000000DEDAD2140C.png}
|
208
|
398 |
\end{center}
|
|
399 |
|
|
400 |
Scheduler can handle short clock value ranges limitation found on some
|
|
401 |
{\textmu}C. As an example, value range for a 16bit clock counter with
|
|
402 |
4{\textmu}s tick is crossed within 0.26 seconds... Long alarms must be
|
|
403 |
segmented.
|
|
404 |
|
|
405 |
Chronogram illustrate a long alarm (A) and a short periodic alarm (B),
|
|
406 |
with a A value {\textgreater} clock range {\textgreater} B value.
|
|
407 |
Values t0...t8 are successive setTimer call parameter values. t1
|
|
408 |
illustrates an intermediate call to TimeDispatch, caused by a delay
|
|
409 |
longer than clock range. Because of long alarm segmentation, at the end
|
|
410 |
of t1, TimeDispatch call will not trig any alarm callback.
|
|
411 |
|
|
412 |
\begin{center}
|
211
|
413 |
\includegraphics[width=18cm]{Pictures/1000000000000396000000FFC42573DA.png}
|
208
|
414 |
\end{center}
|
|
415 |
|
|
416 |
\section{Linux Target}
|
|
417 |
Linux target is default configure target.
|
|
418 |
|
|
419 |
\subsection{Linux Compilation and installation}
|
|
420 |
Call ./configure {--}help to see all available compile time options.
|
|
421 |
|
|
422 |
After invoking ./configure with your platform specific switches, just
|
|
423 |
type make.
|
|
424 |
|
|
425 |
{\ttfamily
|
|
426 |
./configure [options]}
|
|
427 |
|
|
428 |
{\ttfamily
|
|
429 |
make}
|
|
430 |
|
|
431 |
{\ttfamily
|
|
432 |
\textstyleTeletype{make install}}
|
|
433 |
|
|
434 |
\subsubsection{Standard Linux node}
|
|
435 |
Configure switch:
|
|
436 |
|
|
437 |
{\ttfamily
|
|
438 |
{}-{}-timers=unix}
|
|
439 |
|
|
440 |
To do a CANopen node running on PC{}-Linux, you need :
|
|
441 |
|
|
442 |
\liststyleLvii
|
|
443 |
\begin{enumerate}
|
|
444 |
\item A working linux distribution
|
|
445 |
\item One or more Peak system PC CAN interface and the last Peak Linux
|
|
446 |
driver installed.
|
|
447 |
\end{enumerate}
|
|
448 |
\subsubsection{Real{}-Time Linux node}
|
|
449 |
Configure switch:
|
|
450 |
|
|
451 |
{\ttfamily
|
|
452 |
{}-{}-timers=xeno}
|
|
453 |
|
|
454 |
To do a CANopen node running on PC{}-Linux, you need :
|
|
455 |
|
|
456 |
\liststyleLviii
|
|
457 |
\begin{enumerate}
|
|
458 |
\item A working Linux distribution patched with XENOMAI 2.1 or greater.
|
|
459 |
\item One or more Peak system PC CAN interface and the last Peak Real
|
|
460 |
Time Linux driver installed.
|
|
461 |
\end{enumerate}
|
|
462 |
\subsubsection{CAN devices}
|
|
463 |
Curently supported CAN devices and corresponding configure switch:
|
|
464 |
|
|
465 |
\paragraph{Peak systems}
|
|
466 |
Configure switch:
|
|
467 |
|
|
468 |
{\ttfamily
|
|
469 |
{}-{}-can=peak\_linux}
|
|
470 |
|
|
471 |
PeakSystems CAN interface is automatically chosen as default CAN
|
|
472 |
interface if libpcan is present in the system.
|
|
473 |
|
|
474 |
Please download driver at
|
|
475 |
\href{http://www.peak-system.com/linux}{http://www.peak{}-system.com/linux}
|
|
476 |
and follow instructions in order to install driver on your system.
|
|
477 |
|
|
478 |
\paragraph{Socket{}-Can (http://socketcan.berlios.de)}
|
|
479 |
Configure switch:
|
|
480 |
|
|
481 |
{\ttfamily
|
|
482 |
{}-{}-can=socket}
|
|
483 |
|
|
484 |
\paragraph{LinCan}
|
|
485 |
Configure switch:
|
|
486 |
|
|
487 |
{\ttfamily
|
|
488 |
{}-{}-can=lincan}
|
|
489 |
|
|
490 |
\paragraph{Virtual CAN interfaces (for test/debug)}
|
|
491 |
Configure switch:
|
|
492 |
|
|
493 |
{\ttfamily
|
|
494 |
{}-{}-can=virtual}
|
|
495 |
|
|
496 |
Virtual CAN interface use Unix pipes to emulate a virtual CAN network.
|
|
497 |
Each message issued from a node is repeat to all other nodes. Currently
|
|
498 |
only works with nodes running in the same process, and does not support
|
|
499 |
work with Xenomai.
|
|
500 |
|
|
501 |
\subsection{Testing your CanFestival installation}
|
|
502 |
Sample provided in /example/TestMasterSlave is installed into your
|
|
503 |
system during installation.
|
|
504 |
|
|
505 |
{\ttfamily
|
|
506 |
TestMasterSlave}
|
|
507 |
|
|
508 |
Default can driver library is libcanfestival\_can\_virtual.so., which
|
|
509 |
will simply pass CAN messages through Unix pipes between Master and
|
|
510 |
Slave.
|
|
511 |
|
|
512 |
You may also want to specify different can interface and define some CAN
|
|
513 |
ports. An other example using Peak{\textquotesingle}s dual PCMCIA
|
|
514 |
(configure and install with {--}can=peak) :
|
|
515 |
|
|
516 |
{\ttfamily
|
|
517 |
TestMasterSlave {}-l libcanfestival\_can\_peak.so {}-s 40 {}-m 41}
|
|
518 |
|
|
519 |
\section{Windows Targets}
|
|
520 |
CanFestival can be compiled and run on Windows platform. It is possible
|
|
521 |
to use both Cygwin and win32 native runtime environment.
|
|
522 |
|
|
523 |
\subsection{Object Dictionary Editor GUI installation.}
|
|
524 |
Please refer to
|
|
525 |
\hyperlink{a821UsingDictionaryEditorGUIoutline}{8.2.1)Using Dictionary
|
|
526 |
Editor GUI}
|
|
527 |
|
|
528 |
\subsection{CYGWIN}
|
|
529 |
\subsubsection{Requirements}
|
|
530 |
Cygwin have to be installed with those packages :
|
|
531 |
|
|
532 |
\liststyleLix
|
|
533 |
\begin{enumerate}
|
|
534 |
\item gcc
|
|
535 |
\item unzip
|
|
536 |
\item wget
|
|
537 |
\item make
|
|
538 |
\end{enumerate}
|
|
539 |
Currently, the only supported CAN devices are PeakSystems ones, with
|
|
540 |
PcanLight driver and library.
|
|
541 |
|
|
542 |
Please download driver at
|
|
543 |
\href{http://www.peak-system.com/themen/download_gb.html}{http://www.peak{}-system.com/themen/download\_gb.html}
|
|
544 |
\ and follow instructions in order to install driver on your system.
|
|
545 |
|
|
546 |
Install Cygwin as required, and the driver for your Peak CAN device.
|
|
547 |
|
|
548 |
Open a Cygwin terminal, and follow those instructions:
|
|
549 |
|
|
550 |
\subsubsection{Cygwin configuration and compilation}
|
|
551 |
\paragraph{A single node with PcanLight and Peak CAN{}-USB adapter}
|
|
552 |
Download the PCAN{}-Light Zip file for your HW ( URL from download page
|
|
553 |
):
|
|
554 |
|
|
555 |
{\ttfamily
|
|
556 |
wget http://www.peak{}-system.com/files/usb.zip}
|
|
557 |
|
|
558 |
Extract its content into your cygwin home (it will create a ``Disk''
|
|
559 |
directory):
|
|
560 |
|
|
561 |
{\ttfamily
|
|
562 |
unzip usb.zip}
|
|
563 |
|
|
564 |
Configure CanFestival3 providing path to the desired PcanLight
|
|
565 |
implementation:
|
|
566 |
|
|
567 |
{\ttfamily
|
|
568 |
cd CanFestival{}-3}
|
|
569 |
|
|
570 |
{\ttfamily
|
|
571 |
export PCAN\_INCLUDE=\~{}/Disk/PCAN{}-Light/Api/}
|
|
572 |
|
|
573 |
{\ttfamily
|
|
574 |
export PCAN\_HEADER=Pcan\_usb.h}
|
|
575 |
|
|
576 |
{\ttfamily
|
|
577 |
export PCAN\_LIB=\~{}/Disk/PCAN{}-Light/Lib/Visual{\textbackslash}
|
|
578 |
C++/Pcan\_usb.lib}
|
|
579 |
|
|
580 |
{\ttfamily
|
|
581 |
./configure {}-{--}can=peak\_win32}
|
|
582 |
|
|
583 |
{\ttfamily
|
|
584 |
make}
|
|
585 |
|
|
586 |
In order to test, you have to use another CanFestival node, connect with
|
|
587 |
a CAN cable.
|
|
588 |
|
|
589 |
{\ttfamily
|
|
590 |
cp \~{}/Disk/PCAN{}-Light/Pcan\_usb.dll .}
|
|
591 |
|
|
592 |
{\ttfamily
|
|
593 |
./examples/TestMasterSlave/TestMasterSlave {\textbackslash}}
|
|
594 |
|
|
595 |
{\ttfamily
|
|
596 |
{}-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll
|
|
597 |
{\textbackslash}}
|
|
598 |
|
|
599 |
{\ttfamily
|
|
600 |
{}-S 500K {}-M none}
|
|
601 |
|
|
602 |
Then, on the other node :
|
|
603 |
|
|
604 |
{\ttfamily
|
|
605 |
./TestMasterSlave {}-l my\_driver.so {}-S none {}-M 500K}
|
|
606 |
|
|
607 |
Now messages are beeing exchanged between master and slave node.
|
|
608 |
|
|
609 |
\paragraph{Two nodes with PcanLight and Peak dual PCMCIA{}-CAN adapter}
|
|
610 |
Download the PCAN{}-Light Zip file for your HW ( URL from download page
|
|
611 |
):
|
|
612 |
|
|
613 |
{\ttfamily
|
|
614 |
wget http://www.peak{}-system.com/files/pccard.zip}
|
|
615 |
|
|
616 |
Extract its content into your cygwin home (it will create a ``Disk''
|
|
617 |
directory):
|
|
618 |
|
|
619 |
{\ttfamily
|
|
620 |
unzip pccard.zip}
|
|
621 |
|
|
622 |
The configure CanFestival3 providing path to the desired PcanLight
|
|
623 |
implementation:
|
|
624 |
|
|
625 |
{\ttfamily
|
|
626 |
export PCAN\_INCLUDE=\~{}/Disk/PCAN{}-Light/Api/\newline
|
|
627 |
export PCAN\_HEADER=Pcan\_pcc.h\newline
|
|
628 |
export PCAN\_LIB=\~{}/Disk/PCAN{}-Light/Lib/Visual{\textbackslash}
|
|
629 |
C++/Pcan\_pcc.lib\newline
|
|
630 |
export PCAN2\_HEADER=Pcan\_2pcc.\newline
|
|
631 |
export PCAN2\_LIB=\~{}/Disk/PCAN{}-Light/Lib/Visual{\textbackslash}
|
|
632 |
C++/Pcan\_2pcc.lib}
|
|
633 |
|
|
634 |
In order to test, just connect together both CAN ports of the PCMCIA
|
|
635 |
card. Don{\textquotesingle}t forget 120ohms terminator.
|
|
636 |
|
|
637 |
{\ttfamily
|
|
638 |
cp \~{}/Disk/PCAN{}-Light/Pcan\_pcc.dll .}
|
|
639 |
|
|
640 |
{\ttfamily
|
|
641 |
cp \~{}/Disk/PCAN{}-Light/Pcan\_2pcc.dll .}
|
|
642 |
|
|
643 |
{\ttfamily
|
|
644 |
./examples/TestMasterSlave/TestMasterSlave {\textbackslash}}
|
|
645 |
|
|
646 |
{\ttfamily
|
|
647 |
{}-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll}
|
|
648 |
|
|
649 |
Messages are then exchanged between master and slave node, both inside
|
|
650 |
TestMasterSlave{\textquotesingle}s process.
|
|
651 |
|
|
652 |
\subsection{Visual Studio C++}
|
|
653 |
\subsubsection{Requirements}
|
|
654 |
Minimal Cygwin installation is required at configuration time in order
|
|
655 |
to create specific header files (config.h and cancfg.h). Once this
|
|
656 |
files created, cygwin is not necessary any more.
|
|
657 |
|
|
658 |
Project and solution files have been created and tested with Visual
|
|
659 |
Studio Express 2005. Be sure to have installed Microsoft Platform SDK,
|
|
660 |
as recommended at the end of Visual Studio installation.
|
|
661 |
|
|
662 |
\subsubsection{Configuration with cygwin}
|
|
663 |
Follow instructions given at
|
|
664 |
\hyperlink{a422Cygwinconfigurationandcompilationoutline}{4.2.2)Cygwin
|
|
665 |
configuration and compilation}, but do neither call make nor do tests,
|
|
666 |
just do configuration steps. This will create headers files accordingly
|
|
667 |
to your configuration parameters, and the desired CAN hardware.
|
|
668 |
|
|
669 |
\subsubsection{Compilation with Visual Studio}
|
|
670 |
You can either load independents ``*.vcproj'' project files along your
|
|
671 |
own projects in your own solution or load the provided
|
|
672 |
``CanFestival{}-3.vc8.sln'' solution files directly.
|
|
673 |
|
|
674 |
Build CanFestival{}-3 project first.
|
|
675 |
|
|
676 |
\paragraph{PcanLight and the can\_peak\_win32 project.}
|
|
677 |
Chosen Pcan\_xxx.lib and eventually Pcan\_2xxx.lib files must be added
|
|
678 |
to can\_peak\_win32 \ \ project before build of the DLL.
|
|
679 |
|
|
680 |
\subsubsection{Testing}
|
|
681 |
Copy eventually needed dlls (ie : Pcan\_Nxxx.lib) into Release or Debug
|
|
682 |
directory, and run the test program:
|
|
683 |
|
|
684 |
{\ttfamily
|
|
685 |
TestMasterSlave.exe {}-l can\_peak\_win32.dll}
|
|
686 |
|
|
687 |
\section{Motorola HCS12}
|
|
688 |
The examples have been tested on a MC9S12DG255 mounted on a
|
|
689 |
Elektronikladen HCS12 T{}-board.
|
|
690 |
|
|
691 |
Beware that there are a few differences in the MSCAN module of the
|
|
692 |
68HC12 and HCS12 microcontroller. For a HC12, you must adapt the driver
|
|
693 |
that we provide for \ the HCS12.
|
|
694 |
|
|
695 |
For the difference MSCAN HC12/HCS12, see the Motorola application note
|
|
696 |
AN2011/D.
|
|
697 |
|
|
698 |
Configure switch:
|
|
699 |
|
|
700 |
{\ttfamily
|
|
701 |
{}-{}-target=hcs12}
|
|
702 |
|
|
703 |
To do a CANopen node running on a microncontroller Motorola MC9S12DP256,
|
|
704 |
you need :
|
|
705 |
|
|
706 |
\liststyleLx
|
|
707 |
\begin{enumerate}
|
|
708 |
\item The compiler GNU gcc for HC11, HC12, HCS12 : m6811{}-elf. \newline
|
|
709 |
Download the \textbf{release 3.1} at :
|
|
710 |
\ \href{http://m68hc11.serveftp.org/m68hc11_pkg_rpm.php}{http://m68hc11.serveftp.org/m68hc11\_pkg\_rpm.php}
|
|
711 |
|
|
712 |
\item A board with this chip. We are using the T{}-board from
|
|
713 |
Electronikladden.
|
|
714 |
\item At least about 40 kBytes of program memory.
|
|
715 |
\item A tool to flash the memory. (We are using the hight cost
|
|
716 |
Lauterbach debugger).
|
|
717 |
\end{enumerate}
|
|
718 |
\subsection{Running a HCS12 node}
|
|
719 |
\subsubsection{Compiling Canfestival:}
|
|
720 |
{\ttfamily
|
|
721 |
./configure {--}target=hcs12}
|
|
722 |
|
|
723 |
\subsubsection{Compiling and building an example}
|
|
724 |
Enter in the folder of an HCS12 example,
|
|
725 |
|
|
726 |
{\ttfamily
|
|
727 |
make all}
|
|
728 |
|
|
729 |
\subsubsection{Flashing the memory :}
|
|
730 |
Use your prefered loader ! If you are using a debugger Lauterbach, you
|
|
731 |
can load the bash file : trace32\_flash\_programmer.cmm. It loads
|
|
732 |
directly the elf file.
|
|
733 |
|
|
734 |
\subsubsection{Connecting to a serial RS232 console :}
|
|
735 |
Connect the portS(TxD0) of the HCS12 to a console configured at 19200
|
|
736 |
bauds 8N1, via a Max232 chip to adapt the electricals levels. On Linux,
|
|
737 |
you can use minicom. Connecting to a console is usefull to read the
|
|
738 |
messages, but not required.
|
|
739 |
|
|
740 |
\subsubsection{Connecting to the CAN network :}
|
|
741 |
Connect the port CAN0 (pin PM0, PM1) to the network via a CAN
|
|
742 |
controller. On our board, the CAN controler is a PCA82C250 chip.
|
|
743 |
|
|
744 |
\subsubsection{starting the node :}
|
|
745 |
Press the reset of your HCS12 board.
|
|
746 |
|
|
747 |
\section{Example and test program:}
|
|
748 |
The ``examples'' directory contains some test program you can use as
|
|
749 |
example for your own developments.
|
|
750 |
|
|
751 |
\subsection{TestMasterSlave}
|
|
752 |
{\ttfamily
|
|
753 |
**************************************************************}
|
|
754 |
|
|
755 |
{\ttfamily
|
|
756 |
* \ TestMasterSlave
|
|
757 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
758 |
|
|
759 |
{\ttfamily
|
|
760 |
*
|
|
761 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
762 |
|
|
763 |
{\ttfamily
|
|
764 |
* \ A simple example for PC. It does implement 2 CanOpen \ \ \ \ \ *}
|
|
765 |
|
|
766 |
{\ttfamily
|
|
767 |
* \ nodes in the same process. A master and a slave. Both \ \ \ \ *}
|
|
768 |
|
|
769 |
{\ttfamily
|
|
770 |
* \ communicate together, exchanging periodically NMT, SYNC, \ *}
|
|
771 |
|
|
772 |
{\ttfamily
|
|
773 |
* \ SDO and PDO. Master configure heartbeat producer time \ \ \ \ *}
|
|
774 |
|
|
775 |
{\ttfamily
|
|
776 |
* \ at 1000 ms for slave node{}-id 0x02 by concise DCF.
|
|
777 |
\ \ \ \ \ \ \ \ *}
|
|
778 |
|
|
779 |
{\ttfamily
|
|
780 |
*
|
|
781 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
782 |
|
|
783 |
{\ttfamily
|
|
784 |
* \ \ Usage:
|
|
785 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
786 |
|
|
787 |
{\ttfamily
|
|
788 |
* \ \ ./TestMasterSlave \ [OPTIONS]
|
|
789 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
790 |
|
|
791 |
{\ttfamily
|
|
792 |
*
|
|
793 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
794 |
|
|
795 |
{\ttfamily
|
|
796 |
* \ \ OPTIONS:
|
|
797 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
798 |
|
|
799 |
{\ttfamily
|
|
800 |
* \ \ \ \ {}-l : Can library
|
|
801 |
[{\textquotedbl}libcanfestival\_can\_virtual.so{\textquotedbl}]
|
|
802 |
\ \ \ \ *}
|
|
803 |
|
|
804 |
{\ttfamily
|
|
805 |
*
|
|
806 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
807 |
|
|
808 |
{\ttfamily
|
|
809 |
* \ \ \ Slave:
|
|
810 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
811 |
|
|
812 |
{\ttfamily
|
|
813 |
* \ \ \ \ {}-s : bus name [{\textquotedbl}0{\textquotedbl}]
|
|
814 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
815 |
|
|
816 |
{\ttfamily
|
|
817 |
* \ \ \ \ {}-S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) \ *}
|
|
818 |
|
|
819 |
{\ttfamily
|
|
820 |
*
|
|
821 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
822 |
|
|
823 |
{\ttfamily
|
|
824 |
* \ \ \ Master:
|
|
825 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
826 |
|
|
827 |
{\ttfamily
|
|
828 |
* \ \ \ \ {}-m : bus name [{\textquotedbl}1{\textquotedbl}]
|
|
829 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
830 |
|
|
831 |
{\ttfamily
|
|
832 |
* \ \ \ \ {}-M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) \ *}
|
|
833 |
|
|
834 |
{\ttfamily
|
|
835 |
*
|
|
836 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
837 |
|
|
838 |
{\ttfamily
|
|
839 |
**************************************************************}
|
|
840 |
|
|
841 |
|
|
842 |
\bigskip
|
|
843 |
|
|
844 |
{\sffamily
|
|
845 |
Notes for Concise DCF :}
|
|
846 |
|
|
847 |
|
|
848 |
\bigskip
|
|
849 |
|
|
850 |
{\sffamily
|
|
851 |
In this example, Master configure \ heartbeat producer time at 1000 ms
|
|
852 |
for slave node{}-id 0x02 by concise DCF according DS{}-302 profile. }
|
|
853 |
|
|
854 |
{\sffamily
|
|
855 |
}
|
|
856 |
|
|
857 |
{\sffamily
|
|
858 |
Index 0x1F22 , sub{}-index 0x00 of the master OD, correspond to the
|
|
859 |
number of entries. This equal to the maximum possible nodeId (127).
|
|
860 |
Each sub{}-index points to the Node{}-ID of the device, to which the
|
|
861 |
configuration belongs. }
|
|
862 |
|
|
863 |
|
|
864 |
\bigskip
|
|
865 |
|
|
866 |
{\sffamily
|
|
867 |
To add more parameters configurations to the slave, the value at
|
|
868 |
sub{}-index 0x02 must be a binary stream (little{}-endian) following
|
|
869 |
this structure :}
|
|
870 |
|
|
871 |
{\sffamily
|
|
872 |
}
|
|
873 |
|
|
874 |
{\sffamily
|
|
875 |
[ nb of entries / index parameter 1 / sub{}-index parameter 1 \ / size
|
|
876 |
data parameter 1 \ / data parameter 1 / index parameter n / ...]}
|
|
877 |
|
|
878 |
{\sffamily
|
|
879 |
\ \ \ \ \ \ (UNS32) \ \ \ \ \ \ \ \ \ \ \ \ (UNS16) (UNS8)
|
|
880 |
\ \ \ \ \ \ \ \ \ \ \ (UNS32) \ \ \ (DOMAIN)}
|
|
881 |
|
|
882 |
{\sffamily
|
|
883 |
}
|
|
884 |
|
|
885 |
{\sffamily
|
|
886 |
So the binary value stream to configure heartbeat producer time must be
|
|
887 |
: }
|
|
888 |
|
|
889 |
|
|
890 |
\bigskip
|
|
891 |
|
|
892 |
{\sffamily
|
|
893 |
0100000017100002000000e803}
|
|
894 |
|
|
895 |
|
|
896 |
\bigskip
|
|
897 |
|
|
898 |
{\sffamily
|
|
899 |
The slave node is configured just before the Master entering in
|
|
900 |
Pre\_operational state.}
|
|
901 |
|
|
902 |
\subsection{gene\_SYNC\_HCS12 :}
|
|
903 |
This is a simple CanOpen node that only send cyclic SYNC message. It
|
|
904 |
demonstrate implementation on HCS12 based board.
|
|
905 |
|
|
906 |
|
|
907 |
\bigskip
|
|
908 |
|
|
909 |
\subsection{TestMasterMicroMod }
|
|
910 |
{\ttfamily
|
|
911 |
**************************************************************}
|
|
912 |
|
|
913 |
{\ttfamily
|
|
914 |
* \ TestMasterMicroMod
|
|
915 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
916 |
|
|
917 |
{\ttfamily
|
|
918 |
*
|
|
919 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
920 |
|
|
921 |
{\ttfamily
|
|
922 |
* \ A simple example for PC.
|
|
923 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
924 |
|
|
925 |
{\ttfamily
|
|
926 |
* \ A CanOpen master that control a MicroMod module:
|
|
927 |
\ \ \ \ \ \ \ \ \ *}
|
|
928 |
|
|
929 |
{\ttfamily
|
|
930 |
* \ {}- setup module TPDO 1 transmit type
|
|
931 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
932 |
|
|
933 |
{\ttfamily
|
|
934 |
* \ {}- setup module RPDO 1 transmit type
|
|
935 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
936 |
|
|
937 |
{\ttfamily
|
|
938 |
* \ {}- setup module hearbeatbeat period
|
|
939 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
940 |
|
|
941 |
{\ttfamily
|
|
942 |
* \ {}- disable others TPDOs
|
|
943 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
944 |
|
|
945 |
{\ttfamily
|
|
946 |
* \ {}- set state to operational
|
|
947 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
948 |
|
|
949 |
{\ttfamily
|
|
950 |
* \ {}- send periodic SYNC
|
|
951 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
952 |
|
|
953 |
{\ttfamily
|
|
954 |
* \ {}- send periodic RPDO 1 to Micromod (digital output) \ \ \ \ \ \ *}
|
|
955 |
|
|
956 |
{\ttfamily
|
|
957 |
* \ {}- listen Micromod{\textquotesingle}s TPDO 1 (digital input)
|
|
958 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
959 |
|
|
960 |
{\ttfamily
|
|
961 |
* \ {}- Mapping RPDO 1 bit per bit (digital input)
|
|
962 |
\ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
963 |
|
|
964 |
{\ttfamily
|
|
965 |
*
|
|
966 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
967 |
|
|
968 |
{\ttfamily
|
|
969 |
* \ \ Usage:
|
|
970 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
971 |
|
|
972 |
{\ttfamily
|
|
973 |
* \ \ ./TestMasterMicroMod \ [OPTIONS]
|
|
974 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
975 |
|
|
976 |
{\ttfamily
|
|
977 |
*
|
|
978 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
979 |
|
|
980 |
{\ttfamily
|
|
981 |
* \ \ OPTIONS:
|
|
982 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
983 |
|
|
984 |
{\ttfamily
|
|
985 |
* \ \ \ \ {}-l : Can library
|
|
986 |
[{\textquotedbl}libcanfestival\_can\_virtual.so{\textquotedbl}]
|
|
987 |
\ \ \ \ *}
|
|
988 |
|
|
989 |
{\ttfamily
|
|
990 |
*
|
|
991 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
992 |
|
|
993 |
{\ttfamily
|
|
994 |
* \ \ \ Slave:
|
|
995 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
996 |
|
|
997 |
{\ttfamily
|
|
998 |
* \ \ \ \ {}-i : Slave Node id format [0x01 , 0x7F]
|
|
999 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1000 |
|
|
1001 |
{\ttfamily
|
|
1002 |
*
|
|
1003 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1004 |
|
|
1005 |
{\ttfamily
|
|
1006 |
* \ \ \ Master:
|
|
1007 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1008 |
|
|
1009 |
{\ttfamily
|
|
1010 |
* \ \ \ \ {}-m : bus name [{\textquotedbl}1{\textquotedbl}]
|
|
1011 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1012 |
|
|
1013 |
{\ttfamily
|
|
1014 |
* \ \ \ \ {}-M : 1M,500K,250K,125K,100K,50K,20K,10K
|
|
1015 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1016 |
|
|
1017 |
{\ttfamily
|
|
1018 |
*
|
|
1019 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *}
|
|
1020 |
|
|
1021 |
{\ttfamily
|
|
1022 |
**************************************************************}
|
|
1023 |
|
|
1024 |
\section{Developing a new node}
|
|
1025 |
Using provided examples as a base for your new node is generally a good
|
|
1026 |
idea. You can also use the provided *.od files as a base for your node
|
|
1027 |
object dictionary.
|
|
1028 |
|
|
1029 |
Creating a new CanOpen node implies to define the Object Dictionary of
|
|
1030 |
this node. For that, developer have to provide a C file. This C file
|
|
1031 |
contains the definition of all dictionary entries, and some kind of
|
|
1032 |
index table that helps the stack to access some entries directly.
|
|
1033 |
|
|
1034 |
\subsection{Using Dictionary Editor GUI}
|
|
1035 |
The Object Dictionary Editor is a WxPython based GUI that is used to
|
|
1036 |
create the C file needed to create a new CanOpen node.
|
|
1037 |
|
|
1038 |
\subsubsection{Installation and usage on Linux}
|
|
1039 |
You first have to download and install Gnosis XML modules. This is
|
|
1040 |
automated by a Makefile rule.
|
|
1041 |
|
|
1042 |
{\ttfamily
|
|
1043 |
cd objdictgen}
|
|
1044 |
|
|
1045 |
{\ttfamily
|
|
1046 |
make}
|
|
1047 |
|
|
1048 |
Now start the editor.
|
|
1049 |
|
|
1050 |
{\ttfamily
|
|
1051 |
python objdictedit.py [od files...]}
|
|
1052 |
|
|
1053 |
\subsubsection{Installation and usage on Windows}
|
|
1054 |
Install Python (at least version 2.4) and wxPython (at least version
|
|
1055 |
2.6.3.2).
|
|
1056 |
|
|
1057 |
Cygwin users can install Gnosis XML utils the same as Linux use. Just
|
|
1058 |
call make.
|
|
1059 |
|
|
1060 |
{\ttfamily
|
|
1061 |
cd objdictgen}
|
|
1062 |
|
|
1063 |
{\ttfamily
|
|
1064 |
make}
|
|
1065 |
|
|
1066 |
Others will have to download and intall Gnosis XML by hand :
|
|
1067 |
|
|
1068 |
{\ttfamily
|
|
1069 |
Gnosis Utils:}
|
|
1070 |
|
|
1071 |
{\ttfamily
|
|
1072 |
http://freshmeat.net/projects/gnosisxml/}
|
|
1073 |
|
|
1074 |
{\ttfamily
|
|
1075 |
http://www.gnosis.cx/download/Gnosis\_Utils.More/Gnosis\_Utils{}-1.2.1.win32{}-py24.exe}
|
|
1076 |
|
|
1077 |
{\ttfamily
|
|
1078 |
Get latest version.}
|
|
1079 |
|
|
1080 |
Download CanFestival archive and uncompress it. Use windows file
|
|
1081 |
explorer to go into CanFestival3{\textbackslash}objdicgten, and
|
|
1082 |
double{}-click on objdictedit.py.
|
|
1083 |
|
|
1084 |
\subsubsection{About}
|
|
1085 |
The Object Dictionary editor GUI is a python application that use the
|
|
1086 |
Model{}-View{}-Controller design pattern. It depends on WxPython to
|
|
1087 |
display view on any supported platform.
|
|
1088 |
|
|
1089 |
\begin{center}
|
211
|
1090 |
\includegraphics[width=7cm]{Pictures/10000201000001FC000001E5D65E8766.png}
|
208
|
1091 |
\end{center}
|
|
1092 |
|
|
1093 |
\subsubsection{Main view}
|
|
1094 |
Top list let you choose dictionary section, bottom left list is the
|
|
1095 |
selected index in that dictionary, and bottom right list are edited
|
|
1096 |
sub{}-indexes.
|
|
1097 |
|
|
1098 |
\begin{center}
|
211
|
1099 |
\includegraphics[width=14cm]{Pictures/10000201000003E7000001C7B0296577.png}
|
208
|
1100 |
\end{center}
|
|
1101 |
|
|
1102 |
\begin{center}
|
211
|
1103 |
\includegraphics[width=3cm]{Pictures/10000000000000B6000000DF1EDD1E73.png}
|
208
|
1104 |
\end{center}
|
|
1105 |
\begin{center}
|
211
|
1106 |
\includegraphics[width=3cm]{Pictures/10000000000000AC000000C9C3F53FA6.png}
|
208
|
1107 |
\end{center}
|
|
1108 |
\begin{center}
|
211
|
1109 |
\includegraphics[width=3cm]{Pictures/100000000000006D000000A31EC8CB54.png}
|
208
|
1110 |
\end{center}
|
|
1111 |
\begin{center}
|
211
|
1112 |
\includegraphics[width=3cm]{Pictures/10000000000000AA0000006014F74635.png}
|
208
|
1113 |
\end{center}
|
|
1114 |
|
|
1115 |
\subsubsection{New node}
|
|
1116 |
Edit your node name, ID and type. Choose your inherited specific
|
|
1117 |
profile.
|
|
1118 |
|
|
1119 |
\begin{center}
|
211
|
1120 |
\includegraphics[width=11cm]{Pictures/10000201000001CB0000015F4FC09B68.png}
|
208
|
1121 |
\end{center}
|
|
1122 |
|
|
1123 |
\subsubsection{Node info}
|
|
1124 |
Edit your node name, ID and type.
|
|
1125 |
|
|
1126 |
\begin{center}
|
211
|
1127 |
\includegraphics[width=7cm]{Pictures/10000201000001010000011DA724D25C.png}
|
208
|
1128 |
\end{center}
|
|
1129 |
|
|
1130 |
\subsubsection{Profile editor}
|
|
1131 |
Chose the used profile to edit.\newline
|
|
1132 |
\begin{center}
|
211
|
1133 |
\includegraphics[width=4cm]{Pictures/10000000000000AB000000C88F594413.png}
|
208
|
1134 |
\end{center}
|
|
1135 |
|
|
1136 |
Pick up optional chosen profile entries.\newline
|
|
1137 |
\begin{center}
|
211
|
1138 |
\includegraphics[width=11cm]{Pictures/10000201000002DE000001D82D89C224.png}
|
208
|
1139 |
\end{center}
|
|
1140 |
|
|
1141 |
\subsubsection{User types}
|
|
1142 |
Use User Types to implement value boundaries, and string lentgth\newline
|
|
1143 |
\begin{center}
|
211
|
1144 |
\includegraphics[width=11cm]{Pictures/10000201000001C40000010766961D7F.png}
|
208
|
1145 |
\end{center}
|
|
1146 |
|
|
1147 |
\subsubsection{Mapped variable}
|
|
1148 |
Add your own specific dictionary entries and associated mapped
|
|
1149 |
variables.\newline
|
|
1150 |
\begin{center}
|
211
|
1151 |
\includegraphics[width=11cm]{Pictures/10000201000001C4000000DD129D4661.png}
|
208
|
1152 |
\end{center}
|
|
1153 |
|
|
1154 |
\subsubsection{Integrated help}
|
|
1155 |
Using F1 key, you can get context sensitive help.\newline
|
|
1156 |
\begin{center}
|
|
1157 |
\includegraphics[width=15cm]{Pictures/10000201000002F30000020B23ED7F67.png}
|
|
1158 |
\end{center}
|
|
1159 |
|
|
1160 |
In order to do that, official 301\_v04000201.pdf file must be placed
|
|
1161 |
into doc/ directory, and xpdf must be present on your system.
|
|
1162 |
|
|
1163 |
F2 key open HTML CanFestival help.\newline
|
|
1164 |
\begin{center}
|
|
1165 |
\includegraphics[width=15cm]{Pictures/10000201000003440000025ACC3FD2F1.png}
|
|
1166 |
\end{center}
|
|
1167 |
|
|
1168 |
\subsection{Generating the object Dictionary}
|
|
1169 |
Once object dictionary has been edited and saved, you have to generate
|
|
1170 |
object dictionary C code for your CanFestival node.
|
|
1171 |
|
|
1172 |
\subsubsection{With GUI}
|
|
1173 |
Menu entry ``File/Build Dictionary''.
|
|
1174 |
|
|
1175 |
\begin{center}
|
211
|
1176 |
\includegraphics[width=4cm]{Pictures/10000201000000B7000000C66AF89CD5.png}
|
208
|
1177 |
\end{center}
|
|
1178 |
|
|
1179 |
Choose C file to create or overwrite. Header file will be also created
|
|
1180 |
with the same prefix as C file.
|
|
1181 |
|
|
1182 |
\subsubsection{With command line}
|
|
1183 |
{\ttfamily
|
|
1184 |
Usage of objdictgen.py :\newline
|
|
1185 |
python objdictgen.py XMLFilePath CfilePath}
|
|
1186 |
|
|
1187 |
\section{FAQ}
|
|
1188 |
\subsection{General}
|
|
1189 |
\subsubsection{Does the code compiles on Windows ?}
|
|
1190 |
Yes, with both Cygwin and Visual Studio C++.
|
|
1191 |
|
|
1192 |
Because CANopen layer is coded with C, put a compilation option /TC or
|
|
1193 |
/TP if you plan to mix C++ files. See the MSDN documentation about
|
|
1194 |
that.
|
|
1195 |
|
|
1196 |
\subsubsection{How to fit the library to an other microcontr\^oler ?}
|
|
1197 |
First, be sure that you have at least 40K bytes of program memory, and
|
|
1198 |
about 2k of RAM.
|
|
1199 |
|
|
1200 |
You have to create target specific interface to HW resources. Take model
|
|
1201 |
on bundled interfaces provided in drivers/ and create your own
|
|
1202 |
interface. You also have to update Makefile.in files for target
|
|
1203 |
specific cflags and options. Chose {--}targer= configure switch to
|
|
1204 |
compile your specific interface.
|
|
1205 |
|
|
1206 |
You are welcome to contribute{}-back your own interfaces ! Other
|
|
1207 |
Canfestival users will use it and provide feedback, tests and
|
|
1208 |
enhancements.
|
|
1209 |
|
|
1210 |
\subsubsection{Is CanFestival3 conform to DS301 v.4.02 ?}
|
|
1211 |
Thanks to Philippe Foureys (IUT of Valence), a slave node have been
|
|
1212 |
tested with the National Instrument CanOpen Conformance Test. It passed
|
|
1213 |
the test with success.
|
|
1214 |
|
|
1215 |
Some very small unconformity have been found in very unusual situations,
|
|
1216 |
for example in the SDO code response to wrong messages.
|
|
1217 |
|
|
1218 |
\subsection{LINUX}
|
|
1219 |
\subsubsection{How to use a Peaksystem CAN board ?}
|
|
1220 |
Just install peak driver and then compile and install Canfestival. Peak
|
|
1221 |
driver is detected at compile time.
|
|
1222 |
|
|
1223 |
\subsubsection{How to use an unsupported CAN board ?}
|
|
1224 |
You have to install the specific driver on your system, with necessary
|
|
1225 |
libs and headers.
|
|
1226 |
|
|
1227 |
Use can\_peak.c/h or can\_virtual.c/h as an example, and adapt it to
|
|
1228 |
your driver API.
|
|
1229 |
|
|
1230 |
Execute configure script and choose {}-{}-can=mydriver
|
|
1231 |
|
|
1232 |
\subsection{Win32}
|
|
1233 |
Compatibility:
|
|
1234 |
|
|
1235 |
\liststyleLxi
|
|
1236 |
\begin{enumerate}
|
|
1237 |
\item Code was compiled MS VisualStudio 2003.NET and VisualStudio
|
|
1238 |
2005.NET for WindowsXP \ with ANSI and UNICODE configurations and for
|
|
1239 |
WindowsCE 5.0.
|
|
1240 |
\item Some preliminary testing was done, but not enough to be used in
|
|
1241 |
mission critical projects.
|
|
1242 |
\end{enumerate}
|
|
1243 |
Additional Features:
|
|
1244 |
|
|
1245 |
\liststyleLxii
|
|
1246 |
\begin{enumerate}
|
|
1247 |
\item Non{}-integral integers support implementation UNS24, UNS40, UNS48
|
|
1248 |
etc.
|
|
1249 |
\item When enable debug output with DEBUG\_WAR\_CONSOLE\_ON or
|
|
1250 |
DEBUG\_ERR\_CONSOLE\_ON, you can navigate in CanFestival source code by
|
|
1251 |
double clicking at diagnostic lines in VisualStudio.NET 200X Debug
|
|
1252 |
Output Window.
|
|
1253 |
\end{enumerate}
|
|
1254 |
Custom size integral types such as INTEGER24, UNS40, INTEGER56 etc. have
|
|
1255 |
been defined as 64 bits integers. You will need to replace sizeof(TYPE)
|
|
1256 |
operators to sizeof\_TYPE definitions in generated code, i.e. replace
|
|
1257 |
sizeof(UNS40) with sizeof\_UNS40.
|
|
1258 |
|
|
1259 |
|
|
1260 |
\bigskip
|
|
1261 |
|
|
1262 |
\subsection{HCS12}
|
|
1263 |
\subsubsection{Which board are you using ?}
|
|
1264 |
A T{}-board from elektronikladen with a MC9S12DP256 or MC9S12DG256.
|
|
1265 |
|
|
1266 |
\subsubsection{Does the code compile with an other compiler than GNU gcc
|
|
1267 |
?}
|
|
1268 |
It is known to work with Metrowerks CodeWarrior. Here are some tips from
|
|
1269 |
Philippe Foureys. :
|
|
1270 |
|
|
1271 |
\paragraph{Interrupt functions}
|
|
1272 |
\subparagraph{Code for GCC:}
|
|
1273 |
{\ttfamily
|
|
1274 |
// prototype\newline
|
|
1275 |
void \_\_attribute\_\_((interrupt))timer3Hdl(void):\newline
|
|
1276 |
// function\newline
|
|
1277 |
void \_\_attribute\_\_((interrupt))timer3Hdl(void)\{...\}}
|
|
1278 |
|
|
1279 |
\subparagraph{Code for CodeWarrior}
|
|
1280 |
{\ttfamily
|
|
1281 |
// protoype\newline
|
|
1282 |
void interrupt timer3Hdl(void);\newline
|
|
1283 |
// function\newline
|
|
1284 |
pragma CODE\_SEG\_\_NEAR\_SEG\_NON\_BANKED\newline
|
|
1285 |
void interrupt timer3Hdl(void)\newline
|
|
1286 |
\{...\}\newline
|
|
1287 |
pragma CODE\_SEG\_DEFAULT}
|
|
1288 |
|
|
1289 |
\paragraph{Interrupt lock, unlock}
|
|
1290 |
\subparagraph{Code for GCC}
|
|
1291 |
{\ttfamily
|
|
1292 |
void unlock (void)\newline
|
|
1293 |
\{\newline
|
|
1294 |
\ \_\_asm\_\_
|
|
1295 |
\_\_volatile\_\_({\textquotedbl}cli{\textquotedbl});\newline
|
|
1296 |
\}\newline
|
|
1297 |
void lock (void)\newline
|
|
1298 |
\{\newline
|
|
1299 |
\ unsigned short mask;\newline
|
|
1300 |
\ \_\_asm\_\_
|
|
1301 |
\_\_volatile\_\_({\textquotedbl}tpa{\textbackslash}n{\textbackslash}tsei{\textquotedbl}:{\textquotedbl}=d{\textquotedbl}(mask));\newline
|
|
1302 |
\}}
|
|
1303 |
|
|
1304 |
\subparagraph{Code for CodeWarrior}
|
|
1305 |
{\ttfamily
|
|
1306 |
void unlock (void)\newline
|
|
1307 |
\{\newline
|
|
1308 |
\ \_\_asm({\textquotedbl}cli{\textquotedbl});\newline
|
|
1309 |
\}\newline
|
|
1310 |
void lock (void)\newline
|
|
1311 |
\{\newline
|
|
1312 |
\ unsigned short mask;\newline
|
|
1313 |
\ \_\_asm\newline
|
|
1314 |
\{\newline
|
|
1315 |
\ tpa:tsei:{\textquotedbl}=d{\textquotedbl}(mask);\newline
|
|
1316 |
\}\newline
|
|
1317 |
\}}
|
|
1318 |
|
|
1319 |
\paragraph{Initialize function}
|
|
1320 |
\subparagraph{Code for GCC}
|
|
1321 |
{\ttfamily
|
|
1322 |
void initCanHCS12 (void)\newline
|
|
1323 |
\{ \ \newline
|
|
1324 |
\ //Init the HCS12 microcontroler for CanOpen \newline
|
|
1325 |
\ initHCS12();\newline
|
|
1326 |
\ \ // Init the HCS12 \ CAN driver\newline
|
|
1327 |
\ const canBusInit bi0 = \{\newline
|
|
1328 |
\ \ \ 0, \ \ \ /* no low power \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */
|
|
1329 |
\newline
|
|
1330 |
\ \ \ 0, \ \ \ /* no time stamp
|
|
1331 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1332 |
\ \ \ 1, \ \ \ /* enable MSCAN
|
|
1333 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1334 |
\ \ \ 0, \ \ \ /* clock source : oscillator (In fact, it is not used)
|
|
1335 |
\ \ */\newline
|
|
1336 |
\ \ \ 0, \ \ \ /* no loop back
|
|
1337 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1338 |
\ \ \ 0, \ \ \ /* no listen only
|
|
1339 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1340 |
\ \ \ 0, \ \ \ /* no low pass filter for wk up */\newline
|
|
1341 |
\ CAN\_Baudrates[CAN\_BAUDRATE\_250K],\newline
|
|
1342 |
\ \ \ \{\newline
|
|
1343 |
\ \ \ \ \ 0x00, \ \ \ /* Filter on 16 bits.\newline
|
|
1344 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ See Motorola Block Guide V02.14 fig
|
|
1345 |
4{}-3 */\newline
|
|
1346 |
\ \ \ \ \ 0x00, 0xFF, /* filter 0 hight accept all msg
|
|
1347 |
\ \ \ \ \ */\newline
|
|
1348 |
\ \ \ \ \ 0x00, 0xFF, /* filter 0 low accept all msg
|
|
1349 |
\ \ \ \ \ \ \ */\newline
|
|
1350 |
\ \ \ \ \ 0x00, 0xFF, /* filter 1 hight filter all of \ msg
|
|
1351 |
\ */\newline
|
|
1352 |
\ \ \ \ \ 0x00, 0xFF, /* filter 1 low filter all of \ msg
|
|
1353 |
\ \ \ */\newline
|
|
1354 |
\ \ \ \ \ 0x00, 0xFF, /* filter 2 hight filter most of \ msg
|
|
1355 |
*/\newline
|
|
1356 |
\ \ \ \ \ 0x00, 0xFF, /* filter 2 low filter most of \ msg
|
|
1357 |
\ \ */\newline
|
|
1358 |
\ \ \ \ \ 0x00, 0xFF, /* filter 3 hight filter most of \ msg
|
|
1359 |
*/\newline
|
|
1360 |
\ \ \ \ \ 0x00, 0xFF, /* filter 3 low filter most of \ msg
|
|
1361 |
\ \ */\newline
|
|
1362 |
\ \ \ \}\newline
|
|
1363 |
\ \};}
|
|
1364 |
|
|
1365 |
\subparagraph{Code for CodeWarrior}
|
|
1366 |
{\ttfamily
|
|
1367 |
void initCanHCS12 (void)\newline
|
|
1368 |
\{ \ \newline
|
|
1369 |
\ //Init the HCS12 microcontroler for CanOpen \newline
|
|
1370 |
\ initHCS12();\newline
|
|
1371 |
\ \ // Init the HCS12 \ CAN driver\newline
|
|
1372 |
\ const canBusInit bi0 = \{\newline
|
|
1373 |
\ \ \ 0, \ \ \ /* no low power \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */
|
|
1374 |
\newline
|
|
1375 |
\ \ \ 0, \ \ \ /* no time stamp
|
|
1376 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1377 |
\ \ \ 1, \ \ \ /* enable MSCAN
|
|
1378 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1379 |
\ \ \ 0, \ \ \ /* clock source : oscillator (In fact, it is not used)
|
|
1380 |
\ \ */\newline
|
|
1381 |
\ \ \ 0, \ \ \ /* no loop back
|
|
1382 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1383 |
\ \ \ 0, \ \ \ /* no listen only
|
|
1384 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ */\newline
|
|
1385 |
\ \ \ 0, \ \ \ /* no low pass filter for wk up */\newline
|
|
1386 |
\ \ \ \{\newline
|
|
1387 |
\ \ \ \ 1, /* clksrc */\newline
|
|
1388 |
\ \ \ \ 3, /* brp \ \ \ */\newline
|
|
1389 |
\ \ \ \ 0, /* sjw \ \ \ */\newline
|
|
1390 |
\ \ \ \ 0, /* samp \ \ */\newline
|
|
1391 |
\ \ \ \ 1, /* tseg2 \ */\newline
|
|
1392 |
\ \ \ \ 12,/* tseg1 \ */\newline
|
|
1393 |
\ \ \ \},\newline
|
|
1394 |
\ \ \ \{\newline
|
|
1395 |
\ \ \ \ \ 0x00, \ \ \ /* Filter on 16 bits.\newline
|
|
1396 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ See Motorola Block Guide V02.14 fig
|
|
1397 |
4{}-3 */\newline
|
|
1398 |
\ \ \ \ \ 0x00, 0xFF, /* filter 0 hight accept all msg
|
|
1399 |
\ \ \ \ \ */\newline
|
|
1400 |
\ \ \ \ \ 0x00, 0xFF, /* filter 0 low accept all msg
|
|
1401 |
\ \ \ \ \ \ \ */\newline
|
|
1402 |
\ \ \ \ \ 0x00, 0xFF, /* filter 1 hight filter all of \ msg
|
|
1403 |
\ */\newline
|
|
1404 |
\ \ \ \ \ 0x00, 0xFF, /* filter 1 low filter all of \ msg
|
|
1405 |
\ \ \ */\newline
|
|
1406 |
\ \ \ \ \ 0x00, 0xFF, /* filter 2 hight filter most of \ msg
|
|
1407 |
*/\newline
|
|
1408 |
\ \ \ \ \ 0x00, 0xFF, /* filter 2 low filter most of \ msg
|
|
1409 |
\ \ */\newline
|
|
1410 |
\ \ \ \ \ 0x00, 0xFF, /* filter 3 hight filter most of \ msg
|
|
1411 |
*/\newline
|
|
1412 |
\ \ \ \ \ 0x00, 0xFF, /* filter 3 low filter most of \ msg
|
|
1413 |
\ \ */\newline
|
|
1414 |
\ \ \ \}\newline
|
|
1415 |
\ \};}
|
|
1416 |
|
|
1417 |
\subsubsection{Who to use warnings and errors messages ?}
|
|
1418 |
\paragraph{Warnings messages}
|
|
1419 |
\begin{longtable}[c]{|p{0.8476598in}|p{0.7761598in}|p{1.0268599in}|p{-0.026640158in}|p{1.0386599in}|p{1.2247599in}|p{1.1761599in}|}
|
|
1420 |
\hline
|
|
1421 |
{\bfseries
|
|
1422 |
DEBUG\_WAR\_CONSOLE \_ON}
|
|
1423 |
&
|
|
1424 |
{\bfseries
|
|
1425 |
DEBUG \_CAN}
|
|
1426 |
&
|
|
1427 |
{\bfseries
|
|
1428 |
PrintMsg{}-WarTo{}-Console}
|
|
1429 |
&
|
|
1430 |
|
|
1431 |
\bigskip
|
|
1432 |
&
|
|
1433 |
{\bfseries
|
|
1434 |
Printing long message on console }
|
|
1435 |
&
|
|
1436 |
\textbf{Printing short message on console.} (number and value only)
|
|
1437 |
&
|
|
1438 |
\textbf{Sending number and value in a PDO}., only if the node is a
|
|
1439 |
slave, in operational state.
|
|
1440 |
\\\hline
|
|
1441 |
\endhead
|
|
1442 |
DEF
|
|
1443 |
&
|
|
1444 |
DEF
|
|
1445 |
&
|
|
1446 |
1
|
|
1447 |
&
|
|
1448 |
|
|
1449 |
\bigskip
|
|
1450 |
&
|
|
1451 |
|
|
1452 |
\bigskip
|
|
1453 |
&
|
|
1454 |
yes
|
|
1455 |
&
|
|
1456 |
|
|
1457 |
\bigskip
|
|
1458 |
\\\hline
|
|
1459 |
DEF
|
|
1460 |
&
|
|
1461 |
DEF
|
|
1462 |
&
|
|
1463 |
0
|
|
1464 |
&
|
|
1465 |
|
|
1466 |
\bigskip
|
|
1467 |
&
|
|
1468 |
yes
|
|
1469 |
&
|
|
1470 |
|
|
1471 |
\bigskip
|
|
1472 |
&
|
|
1473 |
|
|
1474 |
\bigskip
|
|
1475 |
\\\hline
|
|
1476 |
DEF
|
|
1477 |
&
|
|
1478 |
UNDEF
|
|
1479 |
&
|
|
1480 |
1
|
|
1481 |
&
|
|
1482 |
|
|
1483 |
\bigskip
|
|
1484 |
&
|
|
1485 |
|
|
1486 |
\bigskip
|
|
1487 |
&
|
|
1488 |
|
|
1489 |
\bigskip
|
|
1490 |
&
|
|
1491 |
|
|
1492 |
\bigskip
|
|
1493 |
\\\hline
|
|
1494 |
DEF
|
|
1495 |
&
|
|
1496 |
UNDEF
|
|
1497 |
&
|
|
1498 |
0
|
|
1499 |
&
|
|
1500 |
|
|
1501 |
\bigskip
|
|
1502 |
&
|
|
1503 |
|
|
1504 |
\bigskip
|
|
1505 |
&
|
|
1506 |
|
|
1507 |
\bigskip
|
|
1508 |
&
|
|
1509 |
|
|
1510 |
\bigskip
|
|
1511 |
\\\hline
|
|
1512 |
UNDEF
|
|
1513 |
&
|
|
1514 |
X
|
|
1515 |
&
|
|
1516 |
X
|
|
1517 |
&
|
|
1518 |
|
|
1519 |
\bigskip
|
|
1520 |
&
|
|
1521 |
|
|
1522 |
\bigskip
|
|
1523 |
&
|
|
1524 |
|
|
1525 |
\bigskip
|
|
1526 |
&
|
|
1527 |
|
|
1528 |
\bigskip
|
|
1529 |
\\\hline
|
|
1530 |
\end{longtable}
|
|
1531 |
|
|
1532 |
\bigskip
|
|
1533 |
|
|
1534 |
\paragraph{Errors messages}
|
|
1535 |
\begin{longtable}[c]{|p{0.8476598in}|p{0.7351598in}|p{0.6511598in}|p{0.7865598in}|p{-0.026640158in}|p{0.8087598in}|p{0.9955599in}|p{1.1858599in}|}
|
|
1536 |
\hline
|
|
1537 |
{\bfseries
|
|
1538 |
DEBUG\_ERR\_CONSOLE \_ON}
|
|
1539 |
&
|
|
1540 |
{\bfseries
|
|
1541 |
DEBUG \_CAN}
|
|
1542 |
&
|
|
1543 |
{\bfseries
|
|
1544 |
PDO \_ERROR }
|
|
1545 |
&
|
|
1546 |
{\bfseries
|
|
1547 |
PrintMsg{}-ErrTo{}-Console}
|
|
1548 |
&
|
|
1549 |
|
|
1550 |
\bigskip
|
|
1551 |
&
|
|
1552 |
{\bfseries
|
|
1553 |
Printing long message on console}
|
|
1554 |
&
|
|
1555 |
\textbf{Printing short message on console.} (number and value only)
|
|
1556 |
&
|
|
1557 |
\textbf{Sending number and value in a PDO}., only if the node is a
|
|
1558 |
slave, in operational state.
|
|
1559 |
\\\hline
|
|
1560 |
\endhead
|
|
1561 |
DEF
|
|
1562 |
&
|
|
1563 |
DEF
|
|
1564 |
&
|
|
1565 |
X
|
|
1566 |
&
|
|
1567 |
1
|
|
1568 |
&
|
|
1569 |
|
|
1570 |
\bigskip
|
|
1571 |
&
|
|
1572 |
|
|
1573 |
\bigskip
|
|
1574 |
&
|
|
1575 |
yes
|
|
1576 |
&
|
|
1577 |
yes
|
|
1578 |
\\\hline
|
|
1579 |
DEF
|
|
1580 |
&
|
|
1581 |
DEF
|
|
1582 |
&
|
|
1583 |
X
|
|
1584 |
&
|
|
1585 |
0
|
|
1586 |
&
|
|
1587 |
|
|
1588 |
\bigskip
|
|
1589 |
&
|
|
1590 |
yes
|
|
1591 |
&
|
|
1592 |
|
|
1593 |
\bigskip
|
|
1594 |
&
|
|
1595 |
yes
|
|
1596 |
\\\hline
|
|
1597 |
DEF
|
|
1598 |
&
|
|
1599 |
UNDEF
|
|
1600 |
&
|
|
1601 |
X
|
|
1602 |
&
|
|
1603 |
1
|
|
1604 |
&
|
|
1605 |
|
|
1606 |
\bigskip
|
|
1607 |
&
|
|
1608 |
|
|
1609 |
\bigskip
|
|
1610 |
&
|
|
1611 |
|
|
1612 |
\bigskip
|
|
1613 |
&
|
|
1614 |
yes
|
|
1615 |
\\\hline
|
|
1616 |
DEF
|
|
1617 |
&
|
|
1618 |
UNDEF
|
|
1619 |
&
|
|
1620 |
X
|
|
1621 |
&
|
|
1622 |
0
|
|
1623 |
&
|
|
1624 |
|
|
1625 |
\bigskip
|
|
1626 |
&
|
|
1627 |
|
|
1628 |
\bigskip
|
|
1629 |
&
|
|
1630 |
|
|
1631 |
\bigskip
|
|
1632 |
&
|
|
1633 |
yes
|
|
1634 |
\\\hline
|
|
1635 |
UNDEF
|
|
1636 |
&
|
|
1637 |
X
|
|
1638 |
&
|
|
1639 |
DEF
|
|
1640 |
&
|
|
1641 |
X
|
|
1642 |
&
|
|
1643 |
|
|
1644 |
\bigskip
|
|
1645 |
&
|
|
1646 |
|
|
1647 |
\bigskip
|
|
1648 |
&
|
|
1649 |
|
|
1650 |
\bigskip
|
|
1651 |
&
|
|
1652 |
yes
|
|
1653 |
\\\hline
|
|
1654 |
UNDEF
|
|
1655 |
&
|
|
1656 |
X
|
|
1657 |
&
|
|
1658 |
UNDEF
|
|
1659 |
&
|
|
1660 |
X
|
|
1661 |
&
|
|
1662 |
|
|
1663 |
\bigskip
|
|
1664 |
&
|
|
1665 |
|
|
1666 |
\bigskip
|
|
1667 |
&
|
|
1668 |
|
|
1669 |
\bigskip
|
|
1670 |
&
|
|
1671 |
|
|
1672 |
\bigskip
|
|
1673 |
\\\hline
|
|
1674 |
\end{longtable}
|
|
1675 |
|
|
1676 |
\bigskip
|
|
1677 |
|
|
1678 |
\subsubsection{Does the code works in banked memory ?}
|
|
1679 |
No. Today it seems that the port of gcc is bogged for using the banked
|
|
1680 |
memory. So, unfortunately, we are limited to 48 Kbytes of memory code.
|
|
1681 |
|
|
1682 |
\subsubsection{What GCC version are you using ?}
|
|
1683 |
We are using the stable RPM release 2.2 :
|
|
1684 |
|
|
1685 |
\liststyleLxiii
|
|
1686 |
\begin{enumerate}
|
|
1687 |
\item GNU Gcc 3.0.4. Build 20030501
|
|
1688 |
\item Newlib 1.10.0 Build 20030421
|
|
1689 |
\item GNU Binutils 2.12.1 Build 20030427
|
|
1690 |
\end{enumerate}
|
|
1691 |
\section{Documentation resources}
|
|
1692 |
\paragraph{CIA : Can in Automation}
|
|
1693 |
Many documentation on CANopen.
|
|
1694 |
|
|
1695 |
\href{http://www.can-cia.de/}{http://www.can{}-cia.de}
|
|
1696 |
|
|
1697 |
\paragraph{Resources and training in CANopen}
|
|
1698 |
\href{http://www.esacademy.com/}{http://www.esacademy.com}
|
|
1699 |
|
|
1700 |
\paragraph{Elektronikladen HCS12 T{}-board}
|
|
1701 |
\href{http://www.elektronikladen.de/en_hcs12tb.html}{http://www.elektronikladen.de/en\_hcs12tb.html}
|
|
1702 |
|
|
1703 |
\paragraph{Gnu gcc compiler for HC12}
|
|
1704 |
\href{http://m68hc11.serveftp.org/m68hc11_port.php}{http://m68hc11.serveftp.org/m68hc11\_port.php}
|
|
1705 |
|
|
1706 |
\paragraph{Motorola documentation on HC12}
|
|
1707 |
\href{http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MC9S12DP256}{http://www.freescale.com/webapp/sps/site/prod\_summary.jsp?code=MC9S12DP256}
|
|
1708 |
|
|
1709 |
\paragraph{Lauterbach debugger for HC12}
|
|
1710 |
\href{http://www.lauterbach.com/}{http://www.lauterbach.com}
|
|
1711 |
|
|
1712 |
\paragraph{Python language}
|
|
1713 |
\href{http://www.python.org/}{http://www.python.org}
|
|
1714 |
|
|
1715 |
\clearpage\section{About the project}
|
|
1716 |
\subsection{Contributors }
|
|
1717 |
\begin{center}
|
211
|
1718 |
\includegraphics[width=10cm]{Pictures/1000020100000258000000832C6FFAB4.png}
|
208
|
1719 |
\end{center}
|
|
1720 |
|
|
1721 |
Unit\'e mixte de recherche INRETS{}-LCPC
|
|
1722 |
|
|
1723 |
sur les Interractions V\'ehicule{}-Infrastructure{}-Conducteur
|
|
1724 |
|
|
1725 |
14, route de la mini\`ere
|
|
1726 |
|
|
1727 |
78000 Versailles
|
|
1728 |
|
|
1729 |
FRANCE
|
|
1730 |
|
|
1731 |
Tel : +33 1 40 43 29 01
|
|
1732 |
|
|
1733 |
\href{http://www.inrets.fr/ur/livic}{http://www.inrets.fr/ur/livic}
|
|
1734 |
|
|
1735 |
\textbf{Contributors :} Francis DUPIN
|
|
1736 |
|
|
1737 |
Camille BOSSARD
|
|
1738 |
|
|
1739 |
Laurent ROMIEUX
|
|
1740 |
|
|
1741 |
|
|
1742 |
\bigskip
|
|
1743 |
|
|
1744 |
\begin{center}
|
211
|
1745 |
\includegraphics[width=10cm]{Pictures/100002010000013A0000004A96B0C1FF.png}
|
208
|
1746 |
\end{center}
|
|
1747 |
|
|
1748 |
LOLITECH
|
|
1749 |
|
|
1750 |
204, rue du Haut du Pin
|
|
1751 |
|
|
1752 |
88470 Saint{}-Michel sur Meurthe
|
|
1753 |
|
|
1754 |
FRANCE
|
|
1755 |
|
|
1756 |
Tel : +33 3 29 52 95 67
|
|
1757 |
|
|
1758 |
\href{http://www.lolitech.fr/}{http://www.lolitech.fr}
|
|
1759 |
|
|
1760 |
{\bfseries
|
|
1761 |
Contributors : \textmd{Edouard TISSERANT (Original author)}}
|
|
1762 |
|
|
1763 |
{\mdseries
|
|
1764 |
Laurent BESSARD}
|
|
1765 |
|
|
1766 |
|
|
1767 |
\bigskip
|
|
1768 |
|
|
1769 |
Many thanks to the other contributors for their great work:
|
|
1770 |
|
|
1771 |
\textmd{ }Raphael ZULLIGER
|
|
1772 |
|
|
1773 |
\textmd{ }David DUMINY (st\'e A6R)
|
|
1774 |
|
|
1775 |
\textmd{ }Zakaria BELAMRI
|
|
1776 |
|
|
1777 |
\subsection{Getting support}
|
|
1778 |
Send your feedback and bug reports to
|
|
1779 |
\href{mailto:canfestival-devel@lists.sourceforge.net}{canfestival{}-devel@lists.sourceforge.net}.
|
|
1780 |
|
|
1781 |
For commercial support, \ training and specific integration and
|
|
1782 |
developments, please ask LOLITECH (see contributors).
|
|
1783 |
|
|
1784 |
\subsection{Contributing}
|
|
1785 |
You are free to contribute your specific interfaces back to the project.
|
|
1786 |
This way, you can hope to get support from CanFestival users community.
|
|
1787 |
|
|
1788 |
Please send your patch to
|
|
1789 |
\href{mailto:canfestival-devel@lists.sourceforge.net}{canfestival{}-devel@lists.sourceforge.net}.
|
|
1790 |
|
|
1791 |
Feel free to create some new predefined DS{}-4xx profiles (*.prf) in
|
|
1792 |
objdictgen/config, as much as possible respectful to the official
|
|
1793 |
specifications.
|
|
1794 |
|
|
1795 |
\subsection{License}
|
|
1796 |
All the project is licensed with LGPL. This mean you can link
|
|
1797 |
CanFestival with any code without being obliged to publish it.
|
|
1798 |
|
|
1799 |
{\ttfamily
|
|
1800 |
\#This file is part of CanFestival, a library implementing CanOpen
|
|
1801 |
Stack. \newline
|
|
1802 |
\# \newline
|
|
1803 |
\#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
|
|
1804 |
\newline
|
|
1805 |
\# \newline
|
|
1806 |
\#See COPYING file for copyrights details. \newline
|
|
1807 |
\# \newline
|
|
1808 |
\#This library is free software; you can redistribute it and/or \newline
|
|
1809 |
\#modify it under the terms of the GNU Lesser General Public \newline
|
|
1810 |
\#License as published by the Free Software Foundation; either \newline
|
|
1811 |
\#version 2.1 of the License, or (at your option) any later version.
|
|
1812 |
\newline
|
|
1813 |
\# \newline
|
|
1814 |
\#This library is distributed in the hope that it will be useful,
|
|
1815 |
\newline
|
|
1816 |
\#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
1817 |
\newline
|
|
1818 |
\#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \ See the GNU
|
|
1819 |
\newline
|
|
1820 |
\#Lesser General Public License for more details. \newline
|
|
1821 |
\# \newline
|
|
1822 |
\#You should have received a copy of the GNU Lesser General Public
|
|
1823 |
\newline
|
|
1824 |
\#License along with this library; if not, write to the Free Software
|
|
1825 |
\newline
|
|
1826 |
\#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
1827 |
\ 02111{}-1307 \ USA }
|
|
1828 |
|
|
1829 |
|
|
1830 |
\bigskip
|
|
1831 |
\end{document}
|