UPT Programming Tool : CAN-Simulator

 

At the time of this writing (2018-10-30), the 'CAN Message Generator' / Bus-Simulator was in a very early stage of development...
... and the documentation was almost non-existing.

Contents

  1. CAN Message Generator / Bus-Simulator
    1. Introduction
    2. The option 'Inject values into simulation'
    3. The option 'Send on real CAN bus'
    4. CAN signal definition table

  2. Hints about the CAN Message Generator useage (for advanced users)

1.1 Introduction: CAN Message Generator / Bus-Simulator

Nothing is real and nothing to write home about.
  (misheard lyrics from 'Strawberry Fields', The Beatles)


If you have access to the 'real' CAN-Bus, e.g. vehicle with a functional motor control unit close enough to the development PC (for a CAN bus cable), you don't need the CAN message generator / simulator described in this document. The simulation will not spot errors like misconfigured CAN bus (baudrate, sampling point, terminators, ..), problems with adapter cables, etc. So if you can, take a (test-)drive through the fields, and 'write home' if the display misbehaves.

But sometimes, when confronted with the task of developing an application for the programmable display, you may face the problem that no suitable test environment (like a motor control unit) is available. As far as the CAN bus is concerned, your display application already contains all that the programming tool needs to know for 'simulating' the signals that in a real-world application would be received via CAN.
The CAN message generator can do the opposite: Using the information that you have imported from a CAN database, it can assemble CAN messages that it can play "into the display simulator".
If the PC is connected to a suitable CAN bus interface, it can even send those messages to a real hardware.
The fastest way to simulate all CAN-signals used in your application is to extract their definition from the application itself (because the 'UPT display variable' definitions contain all the simulator needs to know for assembling such messages):
  1. Open the CAN Simulator window: From the tool's main menu, select Tools .. CAN Message Generator / Bus-Simulator
  2. There: Add signal .. Copy ALL signals from UPT display variables
  3. Check option Inject values into simulation, and if you promise to be careful, Send on 'real' CAN bus
  4. Click into the table on the signal you want to 'simulate' (or send), to select the row
  5. Use the vertical slider (that is now connected to the selected signal) to modify the value
The above method is only the fastest / easiest way to simulate a single signal. To modify multiple values simultaneously, enter a stimulus (numeric expression) in the column titled 'Expression'. The display interpreter will periodically evaluate this expression, and use the result as new 'physical' value. More on this in a future chapter.


1.2 The option 'Inject values into simulation'

By default, the option Inject values into simulation is set. This causes the signal values modified via slider or stimulus (numeric expression) will enter the simulation within the programming tool, as a replacement for CAN messages received from the CAN-Bus.
In many cases, this option is already sufficient to test and develop an application on the PC ("run it inside the PC"). Unlike option 'Send on real CAN bus', it doesn't affect any external devices connected to the PC. Furthermore, it can be used without a CAN-bus interface on the PC.


1.3 The option 'Send on real CAN bus'

The option Send on real CAN bus should only be used if the PC (with the programming tool) is directly conntected to the MKT View (or similar DUT, 'device under test') with a suitable CAN-bus interface, and no other active CAN nodes are connected to the same network. In this case, the programming tool sends those messages, which the DUT expects to receive from a vehicle's control unit or similar. If both (CAN-simulator and vehicle) were connected simulaneously, this would cause severe collisions on the bus which must be avoided under any circumstance. If multiple nodes send CAN frames with the same message identifiers, there will be unresolvable conflicts during the bus arbitration phase, which sooner or later may cause one of the sending nodes to enter 'Bus-Off' state, i.e. it stops sending. You don't want to experience this in a vehicle while driving !
See also: Recording and playing back messages via 'CAN-Snooper',
                Playing back recorded CAN-traffic in the simulator,
                The PC's CAN bus interface.


1.4 CAN signal definition table

As mentioned in the introduction, signal definitions for the CAN simulator are usually extracted from the application's variable definitions, or from the CAN database (if still available).
Alternatively, signal definitions can also be entered manually in a definition table. Some of the colums in this table (listed below) have the same meaning as described in the manual about display variables connected to CAN signals.
Details about the "CAN-(Message-)ID", "position of the least significant bit", "Intel / Motorola byte order", etc can be found in the document linked above.

Name
Usually copied from the variable definitions table (first column).

Expression
Optional 'Stimulus'. If present (non-empty string), this numeric expression will be periodically evaluated by the display-interpreter (interval adjustable on the right side). The result will be copied into the "Current Value", from where it can be mapped into a CAN message.
A double click into an empty cell in this column generates an expression for a low-frequency sinewave. Each signal will have a slightly different frequency, and the amplitude will be scaled for the signal's MinValue and MaxValue. Thus, with very little effort, the simulator can generate ever-channing "dummy values" for the currently loaded application.

Current Value
The signal's current physical value. Can be modified via vertical slider on the right side, or by entering a suitable stimulus under 'Expression'.

TX cycle (ms)
Transmit cycle for this signal in milliseconds.
Without a cycle (0 ms), a signal will be transmitted immediately after being modified via slider or stimulus, i.e. "event-driven", which can cause an large bus load if many values are modified at the same time.
Via menu item More ... / Set transmit intervals for all signals, you can activate the periodic transmission of all signals contained in the table with just two mouse-clicks. For all signals that don't have a transmit-cycle yet, the time (in milliseconds) will be copied from the edit field in the right half of the window.

Message ID
Hexadecimal CAN message identifier with prefix '0x'. Three digits for "standard-IDs" (11 Bit), eight digits for "extended IDs" (29 bit).

Bus
Reserved for systems with two or even more physical CAN interfaces. Currently not supported for the simulation inside the programming tool (yet).

LSB pos
Position of the signal's least significant bit within the CAN data field (0..63 for "classic" CAN).

Num bits
Number of data bits occupied by the 'raw' CAN signal (within the CAN data field, max. 64 bits for "classic" CAN).

Byte order
For historic reasons, 'M'="Motorola" or 'I'="Intel" ... the old annoyance also known as 'Endianness'.

Data Type
U=unsigned integer, S=signed integer, F=single precision float, D=double precision float.
Type of the 'raw' value, inside the CAN data field (usually integer, float is very rare because wasteful).

Factor
Multiplier for converting the 'raw' CAN value into the physical 'display' value.

Offset
Will be added when converting the 'raw' CAN value into the physical 'display' value:
  Physical value (e.g. Oil Pressure in Bar) = raw_value * Factor + Offset

MinValue, MaxValue
Possible range for the physical value. In the CAN-simulator, used to scale the 'vertical slider' position into a new physical value: Top = maximum, bottom = minimum.



Signal definitions table for the CAN simulator

The content of the definition table shown above can also be exported as a CSV file. To export the table, select More .. Save definitions as file. In the same menu, definitions can also be imported (Load definitions from file). If the exported file with signal definitions still exists during the next session, it will automatically be loaded when opening the CAN simulator window. The CSV file has almost the same structure as the visible table.


2. Hints about the CAN Message Generator useage (for advanced users)

  ... This chapter has not been translated yet.
    If possible, use the german original,
    or an automatic translation of the online version.