Professional Documents
Culture Documents
Version 2.0
2008-07-25
Application Note AN-AND-1-112
Restrictions Public Document
Abstract This is a step-by-step tutorial to introduce the basic process of developing a simple CANoe application.
Used as a guide, the beginning user will get up the curve quickly. In addition to the tutorial, a short set of
helpful CANoe topics is also presented.
Table of Contents
1.0 Overview ..........................................................................................................................................................2
2.0 First CANalyzer, Then CANoe.........................................................................................................................2
3.0 Creating a CANoe Application .........................................................................................................................2
3.1 Create a New Directory .................................................................................................................................2
4.0 CANoe Development – Six Step Process........................................................................................................2
4.1 Create a Database ........................................................................................................................................2
4.1.1 Create the Database File............................................................................................................................2
4.1.2 Define the Network .....................................................................................................................................3
4.2 Create the Database Nodes..........................................................................................................................3
4.3 Creating Database Messages.......................................................................................................................3
4.3.1 Creating Database Message Content.........................................................................................................3
4.3.1.1 Create an Input Switch – aaaMsg (switch_1A) ........................................................................................3
4.3.1.2 Create another Input Switch – aaaMsg (switch_2A)................................................................................4
4.3.1.3 Create an Output Indicator – aaaMsg (Indicator_A) ................................................................................5
4.3.1.4 Create Another Message – By Duplication ..............................................................................................6
4.3.1.5 Create Database Environment Variables for Node AAA .........................................................................7
4.3.1.6 Create Database Variables for Node BBB...............................................................................................9
4.4 Associate the Database ..............................................................................................................................10
4.5 Add Nodes to the Network ..........................................................................................................................10
4.6 Create Panels..............................................................................................................................................11
4.6.1 Creating a New Panel...............................................................................................................................11
4.6.1.1 Panel Designer.......................................................................................................................................11
4.6.1.1.1 Adding a Panel Switch, Push Button, and Indicator Switch ..............................................................12
4.6.1.1.2 Creating a Second Panel Using the First Panel as a Template........................................................15
4.6.1.2 Panel Editor............................................................................................................................................16
4.6.1.2.1 Adding a Panel Switch ......................................................................................................................16
4.6.1.2.2 Adding a Push Button Switch to the Panel .......................................................................................16
4.6.1.2.3 Adding an Output Indicator ...............................................................................................................17
4.6.1.2.4 Creating a Second Panel Using the First Panel as a Template........................................................18
4.7 Place the Panels into the CANoe Environment ..........................................................................................19
4.8 Create Node Behavior.................................................................................................................................19
4.8.1 Programming Node AAA Behavior ...........................................................................................................20
4.8.2 Creating an Empty Function For Node BBB.............................................................................................21
4.8.3 Programming Node BBB Behavior ...........................................................................................................23
5.0 Conclusion .....................................................................................................................................................24
6.0 Overview of Interrelated CANoe Files ...........................................................................................................24
7.0 Compatibility with Other Source Code Editors ..............................................................................................25
8.0 Additional Resources .....................................................................................................................................25
9.0 Contacts .........................................................................................................................................................25
1
Copyright © 2008 - Vector CANtech, Inc.CANtech, Inc.
Contact Information: www.vector-cantech.com or ++1-248-449-9290
CANoe Tutorial
1.0 Overview
This application note is a step-by-step tutorial to introduce the basic process of developing a simple CANoe
application. Used as a guide, the focus is to help the beginning user get up the curve quickly. In addition to the
tutorial, a short set of helpful CANoe topics is also presented.
Next, we want our Boolean 0 and 1 to represent the switch being either "on" or "off". To do this,
1) Select View → Value Tables.
2) Right-click anywhere on the empty page and select New.
3) Name the value table, e.g., "Switch_Positions". (The name cannot contain spaces!)
4) Switch to the Value Descriptions tab and click the [Add] button.
5) For the value "0x0" which appears, click on "Description for the value '0x0'". Replace it with the word
"Off". Then, hit [Enter].
6) Click the [Add] button again. This time replace "Description for the value '0x1'" with the word "On".
Then, hit [Enter].
7) Click [OK] to exit the dialog. The value table "Switch_Positions" now appears in the window.
8) Go back to the Overall View window.
9) Select the “Signals”. On the right side, right-click on "switch_1A" and select Edit signal.
10) On the Definition tab, expand the Value Table drop down list and select Switch_Positions. Selecting
a value table here associates the values so that "0" is "Off" and "1" is "On".
11) Click [Apply], then [OK] to finish.
Our signal should now look like this in the CANdb++ Editor:
1) Select Signals in the tree view at the left, right-click on it, and select New.
2) For the signal Name, enter "Indicator_A".
3) Enter “1” for the Length (bit) of the signal.
4) Select "unsigned" for the Value Type.
5) Expand the Value Table drop-down menu and select Switch_Positions.
6) Click [Apply], then [OK] to finish.
7) Select "aaaMsg (0x1AA)" from the tree view at the left, right-click on it, and select Edit Message....
8) Go to the Signals tab and click [Add].
9) Select our new "Indicator_A" signal and click [OK].
10) Click [Apply], then click [OK] to finish.
We will now change where the signal starts in the message.
1) While the message is still selected in the tree view, select the signal "Indicator_A" in the right window.
Right-click on the blue line and select Edit mapped Signal....
2) For Startbit (bit), change the value from "2" to "8".
3) Click [Apply], then [OK] to finish.
The start bit will now be "8" in the blue line for this signal.
Our message "aaaMsg" should now look like this in the Overall View:
Creating a second message using the first message as a template is quite easy.
1) Select the message "aaaMsg" either in the tree view at the left or right, right-click on it, and select
Copy.
2) Select Messages in the tree view, right-click on it, and select Paste.
3) Double-click on the message "aaaMsg_Copy_1".
4) Change the message name from "aaaMsg" to "bbbMsg".
5) Change the message Identifier from "0x1AA" to "0x2BB".
6) Select the Transmitter tab and click [Add].
7) In the window that pops up, select the transmitter "BBB".
8) Select the Signals tab and remove each signal associated to it by selecting the signal and click
[Remove…].
9) Click on [Apply] and click [OK].
10) The question: "Shall Node BBB remain as sender of the message?" will appear. Click [Yes].
Next, we will create unique signals for this message by duplicating the three signals we have previously made.
Note: Unique signals are used to easily define signals associated to a message.
3) The signal Indicator_A_Copy_1 appears under the Signals list in the tree view at the left. Double click
on it.
4) Rename the signal to “Indicator_B” and click [Ok].
5) Repeat steps 1-4 to make “switch_1B” and “switch_2B”.
6) Assign theses signals to the message “bbbMessage”. Right click on “bbbMsg” and select Edit
Message….
7) Select the Signals tab and click [Add…]. Add the new signals.
8) Click Apply and OK.
9) Select “bbbMessage” in the tree view at the left.
10) Change the start bit of “switch_1B” to “0”, “switch_2B” to “1”, and “Indicator_B” to “8”.
We now have two unique messages defined (shown in Figure 3) that use the same internal message data
structure.
1) Select "Environment variables" in the tree view at the left, right-click on it, and select New.
2) Name the environment variable "aaaSwitch_1A".
3) Expand the Access drop-down list and select Read for read-only access to the variable.
4) Expand the Value Table drop-down list and select Switch_Positions.
5) Change Maximum value to "0x1".
The new environment variable now appears in the Overall View. To see all the entries, expand "ECUs" in the
tree view at the left, expand "AAA", right-click on "Environment variables and select List.
To add the next environment variable, repeat the first two steps above:
1) Again, select "aaaSwitch_1A", right-click on it, and select Copy.
2) Right-click on Environment Variables and select Paste.
3) Select “aaaSwitch_1A_Copy_1”, right-click on it, and select Edit Environment Variable.
4) Change the variable name from "aaaSwitch_1A_Copy_1" to "aaaIndicator_A".
5) Change the Access from Read to Write.
1) Select Environment Variables in the tree view at the left to display them on the right.
2) Click on each one while holding down the <Shift> key to select all three.
3) Right click in the highlighted area and select Copy.
4) Right click in the white space below and select Paste. Copies of the three environment variables, each
ending in "_Copy_1", will appear under the three original variables.
Now expand "BBB" under "ECUs" in the tree view at the left and then expand "Environment variables". The
three new variables will be seen, associated with ECU BBB.
1) Go to CANoe and select the menu command Window → Simulation Setup to make sure the
Simulation Setup window can be seen, if necessary.
2) Expand the tree list to the right and select Databases. Right-click on it and select Add.
3) Associate the “new1.dbc” database file.
1) In the left half of the window, click on the connection lines to the left of the PC Board called "Bus CAN".
Right-click on it and select Insert network node. A new node will appear on the network with the
default name "ECU 1".
2) Right-click on this new node and select Configuration….
3) Expand the CANdb Name drop down list and select the node name "new1::AAA". Click [Ok]. The node
name should change from “ECU 1” to “AAA”. The new node will appear in the tree list to the right.
Add the second node “BBB” in the same manner.
The Simulation Setup window should now look like it does in Figure 7:
We have now created two new nodes with assigned file names, but without any software inside them.
Designing nodes that use graphic control panels is a major feature of CANoe. These panels can be a data
source or sink for system-level or node-level I/O. The values of discrete and continuous environment variables
can be changed interactively on these panels during the simulation. Signal values can also be changed since
Version 5.0 of CANoe.
Overlapping control and display elements can all be placed anywhere on the panel. Each panel control element
must have an environment variable or signal from the database assigned to it. We will focus only on
environment variables in this tutorial.
Panels are saved in CANoe panel file format (default extension .xvp or .cnp) and can then be loaded in the
simulation system.
There are two tools available to create graphic control panels, Panel Designer and Panel Editor. Each tool may
be used as a separate application program; however, it is recommended to open them from CANoe so that the
database definitions carry over. CANoe Version 7.0 or later is required to use the Panel Designer. If CANoe
Version 7.0 or later is not available, or the Panel Editor is preferred, skip to Section 4.6.1.2.
2) On the menu bar of Panel Designer, select File → Save Panel As.
3) Using the extension .xvp and the path to the new directory, name the file "aaa.xvp". Click [Save]. “aaa”
will be the title of the Panel when displayed in CANoe.
To add a panel switch, push button and indicator switch, the steps are exactly the same for each switch. The
following steps show how to add a panel switch.
1) On the top-right side, there should be a Toolbox section. Scroll down the list of Vector Standard
Controls and double click on “Switch”. A box with a dashed border should appear in the middle gray
box.
2) On the bottom right side, the properties of this switch should be displayed in the Properties section.
3) To select an image to use for this switch, scroll down the Properties section. Under the Settings section,
click on (highlight) Image. Next, click on the button to the right of “Choose Image…” and select the
image to use.
In our example, the following image will be used:
Note: Only one switch is placed on the panel. This figure only illustrates that there are three switch states.
4) Still in the Properties section, scroll upwards from Settings. Under Layout Æ Size, set the width and
height of the image. If the above picture is used, then set the width to 35 and height to 50. Otherwise,
the width should be the size of one switch state.
5) Set the State Count to 2 and the Switch Values to ‘0’ for State 1 and ‘1’ for State 2.
6) Under the Symbol section, scroll down and set the symbol filter to Environment Variable. Next, click
on Symbol, and then click on the button to the right of the white box.
7) A window should appear with the list of environment variables. Expand the Environment variable list,
and select “aaaSwitch_1A”, then click [OK].
Note: The environment variable can also be assigned by dragging it from the Symbol Explorer on the left to the
switch box. In the Symbol Explorer, expand the drop down list under Filtered by: and select
“Environment Variables”. The list of environment variables should now be displayed on the left.
Expand the “Environment variables” list, click and drag “aaaSwitch_1A” into the switch.
8) Under the Toolbox section (upper right), scroll down the list and select “Static Text”. A box with the word
“Description” should appear in the middle gray box. Move the text box to the side of the newly created
switch.
9) Under the text box’s properties, double-click on “Description” found under Font Æ Text and replace it
with “aaaSwitch_1A”.
Note: Standard controls may also be added to a panel by dragging them from the Toolbox and dropping them
onto the panel. The above method, however, provides the user with a greater selection variety
of images. For example, in this case (a switch), dragging and dropping doesn’t work, because
the picture of our multi-stage switch isn’t in the Toolbox.
When adding the pushbutton and indicator switch, the above steps will be followed except for a few minor
changes to go along with the tutorial. The illustration below shows the three states of the pushbutton and of the
indicator switch used in this case.
4) Under Layout Æ Size, if the above image is used, set the width to 75 and height to 23.
5) Under Settings Æ Display Only, change it to “True”.
6) Assign the environment variable “aaaIndicator_A” to the switch.
7) Add a static text and replace “Description” with “aaaIndicator_A”.
Now finally,
1) Click the gray box; white sizing boxes should appear at the right and bottom. Point the cursor at the
bottom-right corner white box. The cursor should change into a line with two arrowheads Click and drag
the corner to make the panel bigger or smaller.
2) Then, save the newly created panel by going to File Æ Save Panel….
3) On the Panel Designer main toolbar, click on the icon with the blue meter and the ‘+’ sign. This will add
the panel to the configuration file opened in CANoe.
In CANoe, the panel should have appeared with the window title of “aaa”. It should look like this:
Finally,
1) Point the cursor at the bottom right corner of the black line. The cursor should change into a line with
two arrowheads. Click and drag the corner to make the panel bigger or smaller.
2) Then, save the newly created panel by going to File Æ Save….
At this point, we have finished our panel design using Panel Editor, as shown below in Figure 12.
Next, we move back into the CANoe application to get our new panels interconnected.
1) In CANoe, select the menu command Configuration → Panel Configuration.
2) Click the [Add…] button.
3) Locate the panel files aaa.cnp and bbb.cnp in the new directory. Using the <Shift> key, click both
panels and open them.
4) Expand the drop down list next to Window type for newly configured panels and select “Standard
Window”. This will create a new window outside of CANoe for each panel. (“MDI Window” will display
the panels inside the CANoe program environment.)
5) Click [OK].
Both panels should now appear on the screen. (It is possible that they may be behind the main CANoe window.)
1) If necessary, adjust the position of both panels and the main CANoe window to allow each window to
be viewed.
2) Using the main menu, select File → Save Configuration.
Note: Panel files can be created in CANoe with either the Panel Designer or the Panel Editor, and both types of
files (*.xvp and *.cnp) can be stored together in the same folder. Both can be opened with the
Panel Configuration dialog, so that both may appear and be used at the same time. Panels
should already have been added to the configuration if the blue meter with the ‘+’ was pressed
in Panel Designer. In this tutorial, we will only use the panels created in Panel Designer.
Next, we use the CAPL programming language feature of CANoe to give behavior to our two nodes.
A CAPL program is usually developed in the CAPL Browser. The Browser window is subdivided into three
distinctive areas, or panes. The left pane contains a tree view of all important elements for which a CAPL
program can be written. The area on the upper right is where global variables will be placed for the CAPL
program, and the area below it is where the actual source code for each event procedure is written.
We will begin by associating one of the panel switches on the “aaa” panel to transmit a message onto the CAN
network.
1) In the Simulation Setup window of CANoe, click on the pencil icon located on the lower left corner of
the “AAA” network node to open the CAPL Browser.
2) An Open dialog window will appear, asking for the CAPL program to be given a name. Type in
“AAA.can” and save the file in the “new1” directory. Then, click on Open.
3) In the upper right pane (Global Variable Definitions) of the CAPL Browser, enter the following code:
variables {
message aaaMsg aMsg; // this is the only line that needs to be to typed in
}
4) In the tree view at the left, right click on "Environment" (Environment Variable) and select New. An
empty procedure for the environment variable appears in the bottom right window.
5) Right click on the highlighted “<newEnvVar>” and select Environment variable from CANdb....
6) Select the variable "aaaSwitch_1A" from the list and click [OK].
7) Enter the following code:
on envVar aaaSwitch_1A{
output(aMsg);
}
8) On the toolbar, click the "Compile" icon (a single arrow pointing down onto a stack of papers) or select
Compiler → Compile. (If a compile error is shown, then double click on the listed error line to get to the
line in the program causing the problem.)
9) On the bottom window, make sure the last line says “Compiled …”. If not compiled successfully, make
sure the code is entered exactly as shown in Steps 3 and 7.
10) On the upper menu, go to File → Save to save the CAPL program. Then, close the CAPL Browser.
In order for CANoe to be able to simulate the network, every node must have a program associated with it. We
will make an empty program for Node BBB.
1) In the Simulation Setup window of CANoe, click on the pencil icon located on the lower left corner of the
“BBB” network node to open the CAPL Browser.
2) An Open dialog window will appear asking for the CAPL program to be given a name. Type in
“BBB.can” and save the file in the “new1” directory. Then, click on Open.
3) Select Compiler → Compile
4) On the upper menu, go to File → Save to save the empty CAPL program. Then, close the CAPL
Browser.
Next, let's move the switch press information into the message.
1) Using the menu, go to Window → Simulation Setup. Click the pencil icon of node “AAA” to edit the
CAPL program.
2) Expand "Environment" in the tree view at the left and select "aaaSwitch_1A".
3) In the lower right window, where the code is, change the program source code to read as follows:
on envVar aaaSwitch_1A
{
aMsg.switch_1A = getValue(this);
output(aMsg);
}
4) On the toolbar, click the "Compile" icon (a single arrow pointing down onto a stack of papers) or select
Compiler → Compile. (If a compile error is shown, then double click on the listed error line to get to the
line in the program causing the problem.)
5) On the bottom window, make sure the last line says “Compiled …”. If not compiled successfully, make
sure the code is entered exactly as shown in Steps 3 and 7.
6) On the upper menu, go to File → Save to save the CAPL program. Then, close the CAPL Browser.
Our compiled and finished program should now look like this in the CAPL Browser:
We will now read the message transmitted by the AAA node and move the switch press of Node AAA into the
indicator on Node BBB.
1) In CANoe, go to Window → Simulation Setup.
2) In the Simulation Setup window of CANoe, click on the pencil icon located on the lower left corner of the
“BBB” network node to open the CAPL Browser.
3) In the Global Variables section (upper right) enter the following:
variables {
message bbbMsg bMsg;
}
4) Right click on "CAN Messages" in the tree view at the left and select New.
5) In the code window at the lower right, replace the string "<newMessage>" with "aaaMsg" so it reads "on
message aaaMsg" (meaning "on receiving message "aaaMsg" we will do the following:")
6) Enter the following code:
on message aaaMsg
{
putValue (bbbIndicator_B, this.switch_1A);
bMsg.Indicator_B = this.switch_1A;
output (bMsg);
}
7) On the toolbar, click the "Compile" icon (a single arrow pointing down onto a stack of papers) or select
Compiler → Compile. (If a compile error is shown, then double-click on the listed error line to get to the
line in the program causing the problem.)
8) On the bottom window, make sure the last line says “Compiled …”. If not compiled successfully, make
sure the code is entered exactly as shown in Steps 3 and 7.
9) On the upper menu, go to File → Save to save the CAPL program. Then, close the CAPL Browser.
Let's check the behavior of both network nodes. In CANoe, run the simulation again. This time, the Trace
window will display two messages – each transmitted by a node.
5.0 Conclusion
We now have a working model of a network with two nodes. Continue to work on this network if desired by
adding new behavior, such as:
• Use bbbSwitch_1A of the bbb panel to toggle the indicator on the aaa panel.
• Experiment with other types of controls in the Panel Editor (radio buttons, track bars, edit fields, etc.)
• Add and disable nodes in the Simulation Setup window.
Using the example demo files that have been included with CANoe also helps the user learn more about
CANoe.
CANoe files that are text-based may be modified using any suitable text editor, as long as the basic file
structure and the file’s special formatting characters are not changed.
There may be an advantage in using a suitable text editor on occasion. For example, globally changing a
variable name in the Configuration File, the Database File, and all associated CAPL Program Files is much
quicker using an editor which features “search and replace” on multiple files.
9.0 Contacts
Vector France SAS Vector Japan Co. Ltd. Vector Korea IT Inc.
168 Boulevard Camélinat Seafort Square Center Bld. 18F Daerung Post Tower III, 508
92240 Malakoff 2-3-12, Higashi-shinagawa, 182-4 Guro-dong, Guro-gu
France Shinagawa-ku Seoul, 152-790
Tel: +33 (0)1 42 31 40 00 Tokyo 140-0002, Republic of Korea
Fax: +33 (0)1 42 31 40 09 Japan Tel.: +82-2-2028-0600
Email: information@vector-france.fr Tel:+81 03(5769)7800 Fax: +82-2-2028-0604
Fax: +81 03(5769)6975 Email: info@vector-korea.com
Email: info@vector-japan.co.jp