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.
Click here to download the project: https://github.com/DanlawMxTeam/Samples/raw/master/CANTxDrv.rar
Applies to: •MxSuite 3.41.14 or later Other Requirements: •The user should have an understanding of MxSuite Scenarios, TestCases, and Transforms. |
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 •Use a CAN Receive Driver to read the Signals from the bus and transmit them to a TestCase 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 User-Defined 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: 1.Create a new Custom Harness project. 2.Select Simulation->Edit Harness from the main menu to start MxTransIt. 3.In MxTransIt, drag the following Transforms from the Toolbox to the Editor window: •Pulse Train •Multiply/Divide •Sine Wave •Scale & Offset •CAN Transmit Driver •CAN Receive Driver 4.In the Properties of the Pulse Train a.Set the Duty Cycle to .5 and the frequency to 4. b.Set the Enable on Start property to True. 5.On the Multiply/Divide Transform, set the initial value of the In2 port to 50. 6.Use the Edit Ports command to change the name of the outport on the Multiply Divide Transform to PWMMult. See Editing Ports. 7.In the Sine Wave Transform's properties, set the both the Frequency and the Update Interval to 0.1. 8.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. 9.In the CAN Transmit Driver Transform, click 10.Select ECUNode1 and ECUNode2. These are the nodes that transmit the signals we are putting on the bus. 11.Click OK. The signals become ports on the Transform. 12.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. 13.In the CAN Transmit Driver Transform, click 14.Select ECUNode1 and ECUNode2. These are the nodes that transmit the Signals this Transform receives from the bus. 15.Click OK. The signals become ports on the CAN Receive Transform. 16.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. 17.Connect the ports on the transforms so your MxTransIt Harness looks similar to this: 18.Export the CAN_A, PWMMult, SineWave100, CyclicMsg·Toggle, and SpontMsg·VehSpeed ports. 19.Select File->Save from the main menu, and return to MxVDev. 20.Create a new TestCase. Set the Test Resolution to 10ms and the Test Duration to 10,000 ms (10 seconds). 21.Add the following Signals to the TestCase: •Standard Response Signals: oPWMMult oSineWave100 •CAN message-based Signals: oCyclicMsg·Toggle oSpontMsg·VehSpeed 22.Add the TestCase to the predefined Default Scenario. 23.Remove the Tick TestCase from the Scenario. Leave the predefined Init TestCase. The Scenario should look like this: 24.Remove the SUT Init Signal from the Init TestCase. 25.Run the test. 26.Adjust the Signals' Display Settings to make the results easy-to-read. The TestCase should look similar to this:
27.Use the Accept Results icon ( 28.Use the Virtual Bus Monitor to view the signals on the bus. |