Adding Custom Sensor Data to PCAN Trace Files Guide

Brian Holt2 min read
Data AcquisitionOther ManufacturerTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The PCAN-Basic driver trace function records real CAN traffic in a .trc file, but it cannot inject application-generated “ghost” CAN messages into that trace. Custom sensor data such as GPS position, speed, or distance therefore requires either a real CAN transmission or an application-owned trace writer.

Separate PCAN logging from CAN tracing

PCAN_LOG_TEXT passed to CAN_SetValue inserts custom text into the PCAN-Basic log. It does not add a CAN frame to the trace enabled through TPCANParameter.PCAN_TRACE_STATUS. Use the log function only when a separate text log satisfies the requirement.

Select a supported data path

Method Trace result Constraint
Transmit sensor data with an unused CAN ID The transmitted frame appears in the normal CAN trace. This writes to the physical bus and is unsuitable when the application must remain read-only.
Write the TRC file in the application Real and virtual records can be assembled in a PCAN-compatible file. The application must generate records that conform to the selected TRC format.
Write XML or another custom format The application controls the complete data model. The resulting file is not the required TRC input for the stated PCAN tool workflow.

Choose the TRC format version

Use TRC file format version 1.1 for the single-channel standard format. Use version 1.3 when separate channels are required—for example, real CAN traffic on channel 1 and virtual sensor records on channels 2 or 3. Obtain the official trace-file description before implementing the writer; no specification URL is present in the available evidence.

Implement and verify an application-owned tracer

  1. Decide whether the output is single-channel or multichannel, then select version 1.1 or 1.3 accordingly.
  2. Capture the real CAN records and encode the additional sensor values as virtual records without transmitting them onto the physical bus.
  3. Generate the complete TRC file according to the official format description.
  4. Open the result in the required PCAN trace tool and confirm that the real CAN records, virtual identifiers, channel assignments, and sensor payloads are displayed as intended.
  5. If interchange is required, use the available file-conversion workflow to convert or split trace files, including conversions to or from ASC and CSV.

FAQ

Can PCAN-Basic insert a virtual CAN message into a TRC file?

No. The built-in trace function cannot add a “ghost” CAN message; create the complete TRC file in the application or transmit a real frame on the bus.

Does PCAN_LOG_TEXT add custom data to the trace file?

No. PCAN_LOG_TEXT adds text to the PCAN-Basic log, not to the .trc file produced by the trace function.

Which TRC version supports separate real and virtual channels?

Use format version 1.3 for multichannel output. Use version 1.1 when a single-channel standard file is sufficient.

Back to blog