Table of Contents

Workflow: Sensor Data Mapping

This workflow covers mapping external sensor data (dynamometer, smart tool holder, accelerometer) to simulation toolpaths so that simulation steps can index real-world measurement data.

flowchart TD
    Prepare["Prepare sensor CSV data"]
    Configure["Configure time mapping"]
    Simulate["Run simulation"]
    Map["Map data to simulation steps"]
    View["View mapped results"]

    Prepare --> Configure --> Simulate --> Map --> View

Overview

Data mapping associates external sensor measurements with simulated machining steps. After mapping, each step can reference real-world force, torque, and acceleration data for:

Depending on data volume and application, mapping is either one-to-one (each step maps to one data point) or one-to-many (each step maps to multiple data points from high-sampling-rate sensors).


1. Prepare Sensor CSV Data

Sensor Data Format

The CSV file must have a header row with ActualTime and sensor channels:

Source Headers Aliases
Dynamometer Fx, Fy, Fz Workpiece.Fx, Workpiece.Fy, Workpiece.Fz
Smart tool holder Mx, My, Mz Holder.Mx, Holder.My, Holder.Mz
Accelerometer Ax, Ay, Az
ActualTime,Mx,My,Mz
18:23:54.703,-0.02923,0.10733,0.00409
18:23:54.704,0.04155,-0.04457,0.00448
...

The time format is <hours>:<minutes>:<seconds>.<fractional seconds>. Additional fields (e.g., CH1, CH2) may be included and will be available after mapping.

Controller Data Format (for Two-Layer Mapping)

The controller CSV must contain at least FileNo, LineNo, and ActualTime:

FileNo,LineNo,ActualTime,MC.X,MC.Y,MC.Z,...
1,6,00:00:00.030,0,0,0.37,...

2. Configure Time Mapping

Strategy A: One-to-One Mapping (MapSingleByCsvFile)

MapSingleByCsvFile reads a CSV file and uses time interpolation to map each data point to one simulation step.

PlayNcFile("NC/file1.nc");
MapSingleByCsvFile("Data/sensor.csv");

Strategy B: One-to-One via PlayCsvFile

PlayCsvFile can drive the simulation directly from CSV data, where each row becomes one step. Custom fields in the CSV are automatically available on each step.

PlayCsvFile("Data/controller.csv");

Strategy C: One-to-Many Global Mapping (MapSeriesByCsvFile)

For high-sampling-rate data, first establish ActualTime via one-to-one mapping, then map the series:

PlayNcFile("NC/file1.nc");
MapSingleByCsvFile("Data/controller.csv");  // establishes ActualTime
MapSeriesByCsvFile("Data/sensor.csv");       // maps high-rate series

Strategy D: One-to-Many Local Mapping (Anchor-Based)

For mapping sensor data to specific NC path segments using anchors.

Step 1 — Specify input data and time ranges:

ClearTimeMappingData();
AddTimeDataByFile("lineA", "Mapping/sensor1.csv", "18:25:51.7100", "18:26:12.9910");
AddTimeDataByFile("lineB", "Mapping/sensor1.csv", "18:26:30.5750", "18:27:12.2880");

Step 2 — Specify NC path anchors (embedded in NC code):

X13. F20 ;@LineSelection("lineA", FirstTouch, ShiftTime_s(2), LineEnd, ShiftDistance_mm(-1));
X25. F10 ;@LineSelection("lineB", FirstTouch, null, LastTouch, null);

For range mapping across multiple NC lines, use BeginSelection / EndSelection:

;@BeginSelection("region1", LineBegin, null);
...
;@EndSelection("region1", LineEnd, null);

Anchor Flags:

Flag Description
LineBegin Motion start point of the line
LineEnd Motion end point of the line
FirstTouch First contact with the workpiece
LastTouch Last contact with the workpiece

Offset Options:

Offset Description
null No offset
ShiftTime_s(<seconds>) Time-based offset (positive = forward)
ShiftDistance_mm(<mm>) Distance-based offset (positive = forward)
Note

For FANUC controllers that do not support ; as a comment character, enclose the script command in a comment block:

X13. F20 (;@LineSelection("lineA", FirstTouch, null, LineEnd, null);)

Map on Selection End

EnableMapOnSelectionEnd controls automatic mapping when a selection ends (default: true):

EnableMapOnSelectionEnd = true;  // EndSelection triggers Map automatically

Clearing Mapping Data

Mapping data persists across player resets. To clear:

ClearTimeMappingData();

3. Run Simulation

PlayNcFile("NC/file1.nc");
Note

Why interpret NC code instead of playing CSV directly? The system NC interpreter produces more accurate simulation paths than direct controller CSV playback, which has limited sampling resolution that distorts tool paths.


4. Map Data

After simulation, apply the mapping strategy chosen in step 2. For the two-layer chained approach:

// Chain 1: Controller data → simulation steps (via FileNo/LineNo → ActualTime)
MapSingleByCsvFile("Data/controller.csv");

// Chain 2: Sensor data → simulation steps (via ActualTime → sensor readings)
MapSeriesByCsvFile("Data/sensor.csv");

The chaining works because:

  • Simulation steps and controller data share FileNo/LineNo anchors
  • Controller data and sensor data share ActualTime anchors
  • After chaining, simulation steps can index sensor data
Tip

Due to machine acceleration/deceleration, simulation time and actual time diverge over longer durations. Anchor-based linear projection corrects for this drift.


5. View Mapped Results

After mapping, sensor data is available on each step. Use the UI to:

  • View color gradient maps on the workpiece geometry
  • Inspect time-series charts
  • Click-to-track specific data channels

Export mapped results:

WriteStepFiles("Output/[NcName].step.csv");
WriteShotFiles("Output/[NcName].shot.csv", 1);

Complete Two-Layer Mapping Example

// Configure resolution
MachiningResolution_mm = 0.125;
EnablePhysics = true;

// Clear any previous mapping data
ClearTimeMappingData();

// Run simulation using NC interpreter for accurate paths
PlayNcFile("NC/machining.nc");

// Map controller data (contains FileNo, LineNo, ActualTime)
MapSingleByCsvFile("Data/controller.csv");

// Map high-rate sensor data (contains ActualTime and force/torque)
MapSeriesByCsvFile("Data/sensor.csv");

// Export results
WriteStepFiles("Output/[NcName].step.csv");

See Also