An and 1 112 Canoe Tutorial

25
CANoe Tutorial 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 Copyright © 2008 - Vector CANtech, Inc.CANtech, Inc. Contact Information: www.vector-cantech.com or ++1-248-449-9290 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

Transcript of An and 1 112 Canoe Tutorial

Page 1: An and 1 112 Canoe Tutorial

CANoe Tutorial

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 Copyright © 2008 - Vector CANtech, Inc.CANtech, Inc. Contact Information: www.vector-cantech.com or ++1-248-449-9290

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

Page 2: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 2

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.

2.0 First CANalyzer, Then CANoe Since CANalyzer is used as a portion of the foundation for CANoe, it is quite beneficial to learn the basic features and operation of CANalyzer first before learning CANoe. The Vector Application Note “Quick Introduction to CANalyzer” (see Section 8, "Additional Resources") is a helpful guide for those also beginning with CANalyzer.

3.0 Creating a CANoe Application In this step-by-step tutorial, we will develop a simple application to primarily teach the CANoe development process.

3.1 Create a New Directory 1) Before starting up CANoe, create a new directory called "new1" to contain the new configuration.

Consider locating this directory close to the CANoe application directory.

2) Start CANoe and use the main menu to go to File → New Configuration. A prompt appears to select a template. Choose the one that fits the situation, or if you are not sure, select the default template.

3) Go to File → Save Configuration As. Name the file "new1.cfg" using a path to the new directory name. Then click [OK].

4.0 CANoe Development – Six Step Process The creation of a new CANoe application involves six key steps.

1) Create a Database

2) Create Nodes

3) Associate the Database

4) Create Panels

5) Place the Panels into the CANoe Environment

6) Create Node Behavior

4.1 Create a Database

4.1.1 Create the Database File 1) On the CANoe toolbar, click the CANdb++ Editor button (the one with 4 interconnected red nodes) to

launch the integrated database tool.

2) In CANdb++ Editor, go to File → Create Database. A prompt appears to select a template. Choose the one that fits the situation, or if you are not sure, select the empty template. For this tutorial, we will select the empty template.

3) Save the file as a DBC file called "new1.dbc" in the directory just created.

Page 3: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 3

4.1.2 Define the Network If the empty template is selected, no additional network definitions need to be defined. However, if one of the other templates is selected, follow these steps to define the network properties (the properties list is different in each template):

1) Select 'Networks' from the tree view at the left.

2) Right-click on ‘new1’ and select Edit Network....

3) On the Attributes tab, set the attribute values for this network.

4.2 Create the Database Nodes 1) Select "Network Nodes" from the tree view on the left. Right click on it and select New. Name the first

node "AAA". Then, click [OK].

2) Again, point at 'Network Nodes' in the tree view at the left. Right-click on it and select New. Name the second node "BBB". Then, click [OK].

3) Save the database via File → Save.

4.3 Creating Database Messages 1) Select "Messages" in the tree view on the left, right-click on it, and select New.

2) Name the first message "aaaMsg".

3) Select CAN Standard (11 bit) in the Type: drop down menu and insert "1AA" as the message Identifier.

4) Set the DLC (Data Length Code) to 2, for 2 bytes of data in the message.

5) Select the Transmitters tab and click [Add] to add a transmitter to send our message. Select the network node "AAA" and then click [OK].

Now we need to put signals in our message.

4.3.1 Creating Database Message Content

4.3.1.1 Create an Input Switch – aaaMsg (switch_1A)

Signals are variables that occupy the data field space of a message. Our input switch signal will indicate whether it is on or off in our first message. To do this, proceed as follows:

1 In the CANdb++ Editor, select “Signals" in the tree view on the left. Right-click on it and select New.

2 For the signal Name, enter "switch_1A".

3 Enter "1" for Length (bit) of the message.

4 For Byte Order, select either "Intel" or "Motorola". (Depends on the micro being used)

5 Select "unsigned" for the Value Type.

6 Make sure to set "Minimum" to 0 and "Maximum" to 1.

7 Now, switch to the Messages tab and click the [Add] button. Select our message (the only one there) and click [OK]. Click [OK] to exit the dialog.

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.

Page 4: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 4

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:

Figure 1 – Signal "switch_1" in the CANdb++ Editor

4.3.1.2 Create another Input Switch – aaaMsg (switch_2A)

Making a second switch using the first switch as a template is quite easy.

1) Select "switch_1A" in the tree view at the left or right, right-click on it, and select Copy.

2) Right-click in the right window and select Paste.

3) The signal switch_1A_Copy_1 appears in the tree view at the left and in the right window under "switch_1A". Double-click on it.

4) A dialog box for switch_1A_Copy_1 opens.

Page 5: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 5

5) In the Name box, change "switch_1A_Copy_1" to "switch_2A".

6) Go to the Messages tab and click the [Add] button to add the 'aaaMsg (0x1AA)' message.

7) Click [Apply], then [OK] to finish.

4.3.1.3 Create an Output Indicator – aaaMsg (Indicator_A) Now, we are ready to create another type of signal in our message.

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:

Page 6: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 6

Figure 2 – Message "aaaMsg" in the Database Editor

4.3.1.4 Create Another Message – By Duplication

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.

1) Right click on “Indicator_A” and select Copy.

2) Select (highlight) Signals, right click and select Paste.

Page 7: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 7

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.

Figure 3 – Messages "aaaMsg" and "bbbMsg" in the Database Editor

4.3.1.5 Create Database Environment Variables for Node AAA

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".

Page 8: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 8

6) Go to the Control units tab and click [Add].

7) Select control unit "AAA" and click [OK].

8) Click [Apply] and then click [OK] to finish.

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.

Figure 4 – Environment Variable "aaaSwitch_1" Listed in the Database Editor To add a second environment variable,

1) Expand "Environment Variables" in the tree view at the left. Select the "aaaSwitch_1A" variable, right click on it, and select Copy. Then, right click on Environment Variables and select Paste.

2) Select "aaaSwitch_1A_Copy_1", right click on it, and select Edit Environment Variable.

3) Change the variable name to "aaaSwitch_2A".

4) Since we are essentially making a copy of the first variable, all of the other values remain the same and are automatically correct. Click [OK].

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.

Page 9: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 9

6) The other values remain the same. Click [OK].

4.3.1.6 Create Database Variables for Node BBB

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, double-click each copy and follow the steps below:

5) Delete the "_Copy_1" ending and change each variable name from its "aaa" prefix to "bbb" and its “A” to “B”

6) Go to the Control Units tab, select AAA, and click [Remove].

7) Click [Add] and select the ECU BBB.

8) Click [Apply], then [OK] to finish.

9) Now, save the database by going to File Save.

Figure 5 – The Six Environment 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.

Page 10: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 10

Figure 6 – Three Environment Variables For Node BBB

4.4 Associate the Database

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.

4.5 Add Nodes to the Network

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:

Page 11: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 11

Figure 7 – CANoe Simulation Setup with Two New Nodes

We have now created two new nodes with assigned file names, but without any software inside them.

4.6 Create Panels 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.

4.6.1 Creating a New Panel 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.

4.6.1.1 Panel Designer

1) To open the Panel Designer, click on the icon with a blue meter on the main toolbar of CANoe, or simply go to the File menu.

Page 12: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 12

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.

Figure 8 – The CANoe Panel Designer

4.6.1.1.1 Adding a Panel Switch, Push Button, and Indicator Switch 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:

Page 13: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 13

Figure 9 – Rocker Switch Image

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.

Figure 10 – Push Button and Indicator Switch Image For the push button switch,

1) Under Layout Size, if the above image is used, set the width to 31 and height to 27.

2) Assign the environment variable “aaaSwitch_2A” to the switch.

3) Add a static text and replace “Description” with “aaaSwitch_2A”. For the indicator switch,

Page 14: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 14

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.

Page 15: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 15

In CANoe, the panel should have appeared with the window title of “aaa”. It should look like this:

Figure 11 – "aaa" Panel

4.6.1.1.2 Creating a Second Panel Using the First Panel as a Template

Making a second panel using the first panel as a template is quite simple.

1) If the Panel Designer is still running, make sure all the changes have been saved to the first panel before the second panel is created. If not, start the Panel Designer application and open the first panel, "aaa.xvp".

2) Go to File → Save Panel As.

3) Save the panel as "bbb.xvp" in the “new1” directory. Click [Save].

4) On the left side, Symbol Explorer should be open. Expand the drop down list under Filtered by: and select “Environment Variables”. The list of environment variables should now be displayed on the left.

5) Expand the “Environment variables” list, click and drag “bbbSwitch_1B” into the rocker switch. This should assign the environment variable to the rocker switch.

6) Change the static text from “aaaSwitch_1A” to “bbbSwitch_1B”.

7) Click and drag “bbbSwitch_2B” into the push button. This should assign the environment variable to the push button.

8) Change the static text from “aaaSwitch_2A” to “bbbSwitch_2B”.

9) Click and drag “bbbIndicator_B” into the indicator button. This should assign the environment variable to the indicator button.

10) Change the static text from “aaaIndicator_A” to “bbbIndicator_B”.

11) Now, save the panel by going to File → Save Panel.

12) On the main toolbar, again click on the icon with the blue meter and the ‘+’ sign. This will add the panel to the configuration file opened in CANoe.

13) Exit the Panel Designer.

Page 16: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 16

4.6.1.2 Panel Editor

1) To open the Panel Editor, select File Open Panel Editor.

2) On the menu bar of the Panel Editor, go to Options → Window setting.., which opens the Window size, name, colors, and fonts dialog. All we will do here for now is to give the panel a name. For the panel name, use "aaaPanel". Click [OK].

3) On the menu bar, select File → Save As. Using the extension .cnp and the path to the “new1” directory, name the file "aaa.cnp". Click [OK].

4.6.1.2.1 Adding a Panel Switch

1) Click the switch icon on the toolbars (looks like a light switch with a red dot at the bottom of the switch) or select the menu item Elements → Switch. As the pointer enters the panel design area (within the white box) it changes to a rectangle with a cross at the upper left corner. Click anywhere in the panel design area to place the switch.

2) Right click on the switch and select Configure.

3) Give the element any name.

4) In the Symbol section of the Configure Switch window, expand the drop down list and select “EnvVar”. Then, scroll through the list of environment variables and select "aaaSwitch_1A" to establish a link between the graphic element and the environment variable in the associated database. Click [OK].

5) Click the text icon on the toolbar – a white square with a capital T in it – and click anywhere within the panel design area to place a text box. Move the text box to the right of the switch.

6) Right-click on the text box and select Configure. Give the element any name desired. In the Text section, replace “Static Text” with “aaaSwitch_1A”. Click [OK].

7) Stretch the text box by clicking on any of the side lines of the box and dragging it to an appropriately large size so all of the text is visible.

4.6.1.2.2 Adding a Push Button Switch to the Panel

1) Click the push button icon on the toolbar (an elevated gray square), or select the menu item Elements → Push button. Click anywhere within the panel design area to place the push button and move the push button so that it is under the first switch.

2) Right click on the push button and select Configure.

3) Give the element any name.

4) In the Text section of the dialog, replace "Button" with "Sw2".

5) In the Symbol section of the Configure Switch window, expand the drop down list and select “EnvVar”. Then, scroll through the list of environment variables and select "aaaSwitch_2A" to establish a link between the graphic element and the environment variable in the associated database. Click [OK].

6) Click the text icon on the toolbar – a square with a capital T in it – and move the mouse over the panel design area. As the pointer enters the panel design area it changes to a rectangle with a cross at the upper left corner.

7) Click anywhere within the panel design area to place the text box. Move the text box to the right of the push button.

8) Right-click on the text box and select Configure. Give the element any name desired. In the Text section, replace “Static Text” with “aaaSwitch_2A”. Click [OK].

9) Stretch the text box by clicking on any of the side lines of the box and dragging it to an appropriately large size so all of the text is visible.

Page 17: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 17

4.6.1.2.3 Adding an Output Indicator

1) Click the bitmap switch icon on the toolbar (has 0, I, II vertically on its right side), or select the menu item Elements → Bitmap Switch/Indicator.

2) Click anywhere within the panel design area to place the indicator. Move this element under the push button.

3) Right click on the indicator and select Configure.

4) Give the element any name.

5) Under the State Processing section, select 2 states and set the Switch Value to ‘1’.

6) Under the Symbol section, expand the drop down list and select “EnvVar”. Then, scroll through the list of environment variables and select “aaaIndicator_A” to establish a link between the graphic element and the environment variable in the associated database. Click [OK].

7) Click the text box icon on the toolbar – a white square with a capital T in it – and move the mouse over the panel design area. As the pointer enters the panel design area it changes to a rectangle with a cross at the upper left corner.

8) Click anywhere within the panel design area to place the text box. Move the text box to the right of the push button.

9) Right click on the text box and select Configure. Give the element any name desired. In the Text section, replace “Static Text” with “aaaIndicator_A”. Click [OK].

10) Stretch the text box by clicking on any of the side lines of the box and dragging it to an appropriately large size so all of the text is visible.

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.

Page 18: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 18

Figure 12 – The Designed Panel

4.6.1.2.4 Creating a Second Panel Using the First Panel as a Template

Making a second panel using the first panel as a template is quite simple.

14) If the Panel Editor is still running, make sure all the changes have been saved to the first panel before the second panel is created. If not, start the Panel Editor application and open the first panel, "aaa.cnp".

15) Go to File → Save As.

16) Again maintaining the extension .cnp and the path to the “new1” directory, name the file "bbb.cnp". Click [Save].

17) Go to Options → Window setting.... Change the panel name to "bbbPanel". Click [OK].

18) Double click on the rocker switch and change the environment variable name from "aaaSwitch_1A" to "bbbSwitch_1B". Click [OK].

19) Double click on the pushbutton switch and change the environment variable name from "aaaSwitch_2A" to "bbbSwitch_2B". Click [OK].

20) Double click on the indicator and change the environment variable name from "aaaIndicator_A" to "bbbIndicator_B". Click [OK].

21) Select and then double click on the "aaaSwitch_1A" text box and change the name in the Text section from "aaaSwitch_1A" to "bbbSwitch_1B". Click [OK].

22) Select and then double click on the "aaaSwitch_2A" text box and change the name in the Text section from "aaaSwitch_2A" to "bbbSwitch_2B". Click [OK].

23) Select and then double click on the "aaaIndicator_A" text box and change the name in the Text section from "aaaIndicator_A" to "bbbIndicator_B". Click [OK].

Page 19: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 19

24) Now, save the panel by going to File → Save.

25) Exit the Panel Editor.

4.7 Place the Panels into the CANoe Environment 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.

4.8 Create Node Behavior 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.

Page 20: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 20

Figure 13 – The CAPL Browser

4.8.1 Programming Node AAA Behavior 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:

Page 21: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 21

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.

4.8.2 Creating an Empty Function For Node BBB 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.

Now, let's test what we have done so far.

1) In the main CANoe application, make sure the panels are open.

2) Make sure the Trace Window can be seen (menu command Window → Trace). Click on the [Start] button (the "lightning bolt" icon) on the CANoe toolbar.

3) On the “aaa” Panel window, right- or left-click on the rocker switch ("aaaSwitch_1A").

4) A message with a new time stamp is displayed in the Trace Window every time the switch is clicked, which indicates that the CAN message, aaaMsg, is being transmitted onto the CAN bus.

5) To stop the simulation, click on the [Stop] button (the “stop sign” icon) on the CANoe toolbar. The simulation must be in the stopped state before any changes to the setup can be made.

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); }

Page 22: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 22

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:

Figure 6 – Adding Node Behavior with CAPL Now, let's check the result.

1) In the main CANoe application, make sure the Trace Window can be seen. Click on the [Start] button (the “lightning bolt” icon).

2) In the “aaa” Panel window, right- or left-click on the rocker switch ("aaaSwitch_1").

3) The time stamp of the message can be seen in the Trace Window, followed by columns for the channel, ID, message name. The next two columns are Dir TX (Direction: transmit) and DLC (Data Length Code), which is 2 bytes of data. The last column shows the actual data.

4) Click on the plus sign (+) to the left to expand the message and see its signals on the next three rows.

5) Click the switch on the panel several times. The "switch_1" signal will change from "On" to "Off" and "On" again, and the time stamp can also be seen each time when this is done.

The Trace Window should now look like this:

Page 23: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 23

Figure 7 – Trace Window with "aaaMsg" Message

4.8.3 Programming Node BBB Behavior 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.

Page 24: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 24

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.

Figure 8 – Trace Window with Both Messages

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.

6.0 Overview of Interrelated CANoe Files CANoe uses a collection of interrelated files for each user configuration.

For each CANoe configuration there is a single Configuration File typically associated with a single Database File. For each user-defined node a Program File is used, and for every panel there is a Panel File, as can be seen in Table 1.

CANoe File Type Suffix Text Format Number of Files

Configuration File .cfg Yes 1

Database File .dbc Yes Typically 1

Program File (CAPL) .can Yes 1 for each user-defined node

Panel File .xvp Yes 1 for each user-defined panel

Table 1 – Primary CANoe File Types

Page 25: An and 1 112 Canoe Tutorial

CANoe Tutorial

Application Note AN-AND-1-112 25

7.0 Compatibility with Other Source Code Editors 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.

8.0 Additional Resources The following material may provide further useful information.

VECTOR APPLICATION NOTES AN-AND-1-110 Quick Introduction to CANalyzer

AN-AND-1-113 A Quick Introduction to CAPL

AN-AND-1-117 CANoe/CANalyzer as a COM Server

9.0 Contacts Vector Informatik GmbH Ingersheimer Straße 24 70499 Stuttgart Germany Tel.: +49 711-80670-0 Fax: +49 711-80670-111 Email: [email protected]

Vector CANtech, Inc. 39500 Orchard Hill Pl., Ste 550 Novi, MI 48375 Tel: (248) 449-9290 Fax: (248) 449-9704 Email: [email protected]

VecScan AB Theres Svenssons Gata 9 41755 Göteborg Sweden Tel: +46 (0) 31 764 76 00 Fax: +46 (0) 31 764 76 19 Email: [email protected]

Vector France SAS 168 Boulevard Camélinat 92240 Malakoff France Tel: +33 (0)1 42 31 40 00 Fax: +33 (0)1 42 31 40 09 Email: [email protected]

Vector Japan Co. Ltd. Seafort Square Center Bld. 18F 2-3-12, Higashi-shinagawa, Shinagawa-ku Tokyo 140-0002, Japan Tel:+81 03(5769)7800 Fax: +81 03(5769)6975 Email: [email protected]

Vector Korea IT Inc. Daerung Post Tower III, 508 182-4 Guro-dong, Guro-gu Seoul, 152-790 Republic of Korea Tel.: +82-2-2028-0600 Fax: +82-2-2028-0604 Email: [email protected]