The CANTxDrvSample project demonstrates how to use the CAN Transmit Driver transform to simulate two nodes on a CAN bus from within the Test Harness. Each node transmits a signal onto the bus: One signal is spontaneous; the other is periodic. The steps below describe how to recreate the sample project.
Suppose we want to simulate the CAN messages transmitted by a certain node. We want signal values available in the harness to be transmitted within the CAN messages of the node we are simulating. In this example below we:
•Drop an instance of the CAN Transmit Driver in the Harness
•Set its DBC file property and select the nodes we want to simulate.
•Generate two signals: a Pulse Train and a Sine wave
•Use the Multiply/Divide transform and Scale/Offset to modify the signals
•Connect the modified Pulse Train signal to the CyclicMsg·Toggle CAN signal
•Connect the modified Sine Wave signal the SpontMsg·VehSpeed CAN Signal
The CyclicMsg·Toggle signal is then transmitted on bus CAN_A, as a periodic signal. The SpontMsg·VehSpeed signal is transmitted as a spontaneous signal thus simulating another node on the same bus. The rules for transmitting periodic and spontaneous signals are defined in the DBC file, which is associated with the CAN Transmit Driver in its Properties, and with the CAN_A bus in Network Configuration.
This simple example can be extended to a full comprehensive node simulation by replacing the Signal Generator with a SIL-Easy or other customizable transform. The node simulation can be made to respond to CAN traffic by using the CAN Receive Driver in a similar way.
These steps describe how to recreate the sample project:
2.In MxVDev, create a CAN bus using Network Configuration. Use the CANTXDrvSample.dbc as the CAN Database file. This file is provided as part of the CANTxDrvSample project.
3.Select ECUNode1 and ECUNode2 in the Receive From column:
4.Name the bus CAN_A.
5.Select Simulation->Edit Harness from the main menu to start MxTransIt.
6.In MxTransIt, drag the following Transforms from the Toolbox to the Editor window:
•Scale & Offset
•CAN Transmit Driver
7.In the Properties of the Pulse Train, set the Duty Cycle to .5 and the frequency to 4.
8.On the Multiply/Divide Transform, set the initial value of the In2 port to 50.
10.In the Sine Wave Transform's Properties, set the both the Frequency and the Update Interval to 0.1.
11.Configure the Scale and Offset Transform:
a.Set the both the Offset property and the Scale property to 50.
b.Use the Edit Ports command to change the name of the outport to SineWave100 and set the Max to 100.
c.Set the Min property on the Input port to -1.
12.In the CAN Transmit Driver transform, click in the CAN Database property to display the CAN Bus Configuration form. Attach to the same DBC file used in Step 2.
13.Select ECUNode1 and ECUNode2. These are the nodes that transmit the signals we are putting on the bus.
14.Click OK. The signals become ports on the transform.
15.Change the Name of the CAN bus to match the name of the bus defined in Network Configuration. In this example we use CAN_A.
16.Connect the ports on the transforms so your MxTransIt Harness looks similar to this:
17.Export the CAN_A, PWMMult, and SineWave100 ports.
18.Select File->Save from the main menu, and return to MxVDev.
19.Create a new TestCase. Set the Test Resolution to 10ms and the Test Duration to 10,000 ms (10 seconds).
20.Add the following Signals to the TestCase:
•Standard Response Signals:
•CAN message-based Signals:
21.Add the TestCase to the predefined Default Scenario.
22.Remove the Tick TestCase from the Scenario. Leave the predefined Init TestCase. The Scenario should look like this:
23.Remove the SUT Init Signal from the Init TestCase.
24.Run the test.
25.Adjust the Signals' Display Settings to make the results easy-to-read. The TestCase should look similar to this:
|The SineWave100 and PWMMult graphs show the input into the CAN Transmit Driver transform. SpontMsg·VehSpeed and CyclicMsg·Toggle are message-based signals. Their graphs show the signals on the CAN bus.|
26.Use the Accept Results icon () so the test passes.
27.Use the Virtual Bus Monitor to view the signals on the bus.