]> rtime.felk.cvut.cz Git - ert_linux_web.git/blob - can_bus/index.html
0fa76b9e287b5b3d137c9fe96a832050af8229c6
[ert_linux_web.git] / can_bus / index.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2    "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5   <title>[[!meta title="Simulink Blocks for CAN bus Support under Linux."]]</title>
6   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7   <link><style type="text/css">
8     #main_content {max-width: 70em}
9   </style>
10 </head>
11 <body>
12
13 <div id="main_content" style="max-width: 60em;">
14
15 <p>
16 The toolbox provides basic blocks for sending and receiving
17 CAN messages for <a href="http://lintarget.sourceforge.net/">ERT Linux</a>
18 Simulink target when mainlined
19 <a href="http://elinux.org/CAN_Bus#SocketCAN_Supported_Controllers">socket based CAN bus</a>
20 support is used. The <b>cantransmit</b> and <b>canreceive</b> blocks
21 support directly encapsulation and conversion to the Simulink signals for basic
22 data types: <tt>uint8</tt>, <tt>uint16</tt> and <tt>uint32</tt>.
23 The standard Simulink defined <tt>CAN MESSAGE TYPE</tt> can be used
24 when more complex structure of CAN message sending and receiption
25 is required. The signal of <tt>CAN MESSAGE TYPE</tt> can be connected
26 to <b>CAN Pack</b> and <b>CAN Unpack</b> blocks which encode or retrieve multiple
27 signals to/from CAN message. The CAN Pack and CAN Unpack blocks
28 are provided by <tt>canmsglib</tt> which is part of standard Simulink
29 distribution.
30 </p>
31
32 <p>
33 The code generation requires to include <b>CAN Setup</b> into diagram
34 to work correctly. This block is used to setup baudrate for each CAN
35 channel in the embedded environment but this option is ignored
36 in the actual setup block implementation on Linux. The baudrate
37 can be selected by system administrator from commandline
38 <pre>
39 ip link set can0 down
40 ip link set can0 type can bitrate 1000000 
41 ip link set can0 down
42 </pre>
43 or on Debian based systems <tt>/etc/network/interfaces</tt>
44 configuration file can be used to setup CAN interface baudrate
45 at system startup
46 <pre>
47 allow-hotplug can0
48 iface can0 can static
49     bitrate 1000000
50 </pre>
51 The later setup works automatic even with CAN-USB converter hotplug.
52 </p>
53
54 <p>
55 The projects includes blocks library <b>socketcan_lib.slx</b>, simple
56 example of provided blocks use <b>cantransmit_ert.slx</b> and more
57 complex model <b>canopen_2j_arm_ert.slx</b> which demonstrates
58 use of the block to send PDO messages to two stepper motors
59 controlled robotic arm. This simple CAN library does not
60 provide CANopen support yet so initial motors SDO parameters
61 setup is solved by <b>canopen_2j_arm_setup</b> setup shell
62 script which invokes <tt>cansend</tt> command.
63 The variant of the model (<b>canopen_2j_arm_rpi.slx</b>) with
64 build parameters preset for crosscompilation to Raspberry Pi
65 is provided as well.
66 The CAN-USB converter from 8devices has been used in this case. 
67 </p>
68
69 <h2 id="links">Links</h2>
70 <dl>
71   <dt>Linux CAN bus toolbox repository</dt>
72     <dd><a href="http://rtime.felk.cvut.cz/gitweb/socketcan-simulink.git" target="_blank">http://rtime.felk.cvut.cz/gitweb/socketcan-simulink.git</a>
73     <br><tt>git clone git://rtime.felk.cvut.cz/socketcan-simulink.git</tt> 
74     </dd>
75 </dl>
76
77 </div>
78
79 </body>
80
81 </html>