389 lines
18 KiB
HTML
389 lines
18 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>Workflow: Milling Force Parameter Training | HiAPI-C# 2025 </title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="title" content="Workflow: Milling Force Parameter Training | HiAPI-C# 2025 ">
|
||
|
||
|
||
<link rel="icon" href="../img/HiAPI.favicon.ico">
|
||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||
<link rel="stylesheet" href="../public/main.css">
|
||
<meta name="docfx:navrel" content="../toc.html">
|
||
<meta name="docfx:tocrel" content="toc.html">
|
||
|
||
<meta name="docfx:rel" content="../">
|
||
|
||
|
||
|
||
<meta name="loc:inThisArticle" content="In this article">
|
||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||
<meta name="loc:tocFilter" content="Filter by title">
|
||
<meta name="loc:nextArticle" content="Next">
|
||
<meta name="loc:prevArticle" content="Previous">
|
||
<meta name="loc:themeLight" content="Light">
|
||
<meta name="loc:themeDark" content="Dark">
|
||
<meta name="loc:themeAuto" content="Auto">
|
||
<meta name="loc:changeTheme" content="Change theme">
|
||
<meta name="loc:copy" content="Copy">
|
||
<meta name="loc:downloadPdf" content="Download PDF">
|
||
|
||
<script type="module" src="./../public/docfx.min.js"></script>
|
||
|
||
<script>
|
||
const theme = localStorage.getItem('theme') || 'auto'
|
||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||
</script>
|
||
|
||
</head>
|
||
|
||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
||
<header class="bg-body border-bottom">
|
||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||
<div class="container-xxl flex-nowrap">
|
||
<a class="navbar-brand" href="../index.html">
|
||
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
|
||
|
||
</a>
|
||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||
<i class="bi bi-three-dots"></i>
|
||
</button>
|
||
<div class="collapse navbar-collapse" id="navpanel">
|
||
<div id="navbar">
|
||
<form class="search" role="search" id="search">
|
||
<i class="bi bi-search"></i>
|
||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
</header>
|
||
|
||
<main class="container-xxl">
|
||
<div class="toc-offcanvas">
|
||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||
<div class="offcanvas-header">
|
||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||
</div>
|
||
<div class="offcanvas-body">
|
||
<nav class="toc" id="toc"></nav>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="content">
|
||
<div class="actionbar">
|
||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||
<i class="bi bi-list"></i>
|
||
</button>
|
||
|
||
<nav id="breadcrumb"></nav>
|
||
</div>
|
||
|
||
<article data-uid="Workflow-ForceTraining">
|
||
<h1 id="workflow-milling-force-parameter-training">Workflow: Milling Force Parameter Training</h1>
|
||
|
||
<p>This workflow covers the end-to-end process of training milling force coefficients from sensor data, including data mapping, coefficient training, quality evaluation, and application of the trained parameters.</p>
|
||
<p>Milling coefficients are essential parameters for calculating milling forces. Training derives these coefficients from experimental sensor data (dynamometer or smart tool holder) mapped to simulated toolpaths.</p>
|
||
<pre><code class="lang-mermaid">flowchart TD
|
||
Prereq["Prerequisites<br>(sensor data, project setup)"]
|
||
Resolution["Configure resolution & enable physics"]
|
||
Mapping["Configure data mapping"]
|
||
Simulate["Run simulation with NC file"]
|
||
Export["Export simulation data<br>(WriteShotFiles, WriteStepFiles)"]
|
||
Map["Map sensor data to simulation"]
|
||
Train["Train milling parameters"]
|
||
Evaluate["Evaluate training quality"]
|
||
Apply["Load trained parameters"]
|
||
|
||
Prereq --> Resolution --> Mapping --> Simulate --> Export
|
||
Simulate --> Map --> Train --> Evaluate --> Apply
|
||
</code></pre>
|
||
<h2 id="1-prerequisites">1. Prerequisites</h2>
|
||
<p>Before training you need:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Item</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>HiNC project</strong></td>
|
||
<td>Machine tool, workpiece, fixture, tool house configured</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>NC file</strong></td>
|
||
<td>The NC program used during the physical cutting experiment</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Sensor data CSV</strong></td>
|
||
<td>Time-stamped force/torque data from a dynamometer or smart tool holder</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>Controller data CSV</strong> (optional)</td>
|
||
<td>Machine controller log with <code>FileNo</code>, <code>LineNo</code>, <code>ActualTime</code> for two-layer mapping</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h3 id="sensor-data-file-format">Sensor Data File Format</h3>
|
||
<p>The CSV must contain a header row with <code>ActualTime</code> and at least one force/torque channel:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Source</th>
|
||
<th>Headers</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Dynamometer</td>
|
||
<td><code>Fx</code> (or <code>Workpiece.Fx</code>), <code>Fy</code>, <code>Fz</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Smart tool holder</td>
|
||
<td><code>Mx</code> (or <code>Holder.Mx</code>), <code>My</code>, <code>Mz</code></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Accelerometer (optional)</td>
|
||
<td><code>Ax</code>, <code>Ay</code>, <code>Az</code></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<pre><code class="lang-csv">ActualTime,CH1,CH2,Mx,My,Mz
|
||
18:23:54.703,-0.00398,-0.00034,-0.02923,0.10733,0.00409
|
||
18:23:54.704,-0.00194,0.00285,0.04155,-0.04457,0.00448
|
||
...
|
||
</code></pre>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p>Keep the completed training project archived. When the HiNC training algorithm is updated, you can re-run training from the same project.</p>
|
||
</div>
|
||
<hr>
|
||
<h2 id="2-configure-resolution-and-enable-physics">2. Configure Resolution and Enable Physics</h2>
|
||
<h3 id="resolution">Resolution</h3>
|
||
<p>Use a finer resolution than normal operation for training accuracy:</p>
|
||
<pre><code class="lang-csharp">MachiningResolution_mm = 0.0625; // half or less of production resolution
|
||
MachiningMotionResolution = FeedPerTooth;
|
||
</code></pre>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p>Training resolution should be ≤ 0.5× the production resolution for better accuracy.</p>
|
||
</div>
|
||
<h3 id="enable-physics">Enable Physics</h3>
|
||
<p><a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_EnablePhysics">EnablePhysics</a> must be enabled for force calculation:</p>
|
||
<pre><code class="lang-csharp">EnablePhysics = true;
|
||
</code></pre>
|
||
<h3 id="milling-force-cycle-division">Milling Force Cycle Division</h3>
|
||
<p>Set the number of angular divisions per revolution before training. Higher values yield more accurate phase alignment:</p>
|
||
<pre><code class="lang-csharp">MillingForceCycleDivisionNum = 360;
|
||
</code></pre>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p>This must be set <strong>before</strong> executing <code>TrainMillingPara</code>. A larger value produces a more accurate <code>AngleOffset</code> result and better milling coefficients.</p>
|
||
</div>
|
||
<hr>
|
||
<h2 id="3-configure-data-mapping">3. Configure Data Mapping</h2>
|
||
<p>Depending on your data, choose one of the mapping strategies below.</p>
|
||
<h3 id="31-local-mapping-anchor-based">3.1 Local Mapping (Anchor-Based)</h3>
|
||
<p>For mapping sensor data to specific NC path segments:</p>
|
||
<p><strong>Step A — Specify input data:</strong></p>
|
||
<pre><code class="lang-csharp">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");
|
||
</code></pre>
|
||
<p><strong>Step B — Specify NC paths</strong> (embedded in NC code comments):</p>
|
||
<pre><code>X13. F20 ;@LineSelection("lineA", FirstTouch, ShiftTime_s(2), LineEnd, ShiftDistance_mm(-1));
|
||
X25. F10 ;@LineSelection("lineB", FirstTouch, null, LastTouch, null);
|
||
</code></pre>
|
||
<p>Anchor options: <code>LineBegin</code>, <code>LineEnd</code>, <code>FirstTouch</code>, <code>LastTouch</code>.
|
||
Offset options: <code>null</code>, <code>ShiftTime_s(<seconds>)</code>, <code>ShiftDistance_mm(<mm>)</code>.</p>
|
||
<h3 id="32-two-layer-chained-mapping-controller--sensor">3.2 Two-Layer Chained Mapping (Controller + Sensor)</h3>
|
||
<p>When you have both controller data and sensor data:</p>
|
||
<pre><code class="lang-csharp">PlayNcFile("NC/machining.nc");
|
||
MapSingleByCsvFile("Data/controller.csv"); // maps FileNo/LineNo → ActualTime
|
||
MapSeriesByCsvFile("Data/sensor.csv"); // maps ActualTime → sensor series
|
||
</code></pre>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p><strong>Why two-layer mapping?</strong> Running the NC through the system interpreter produces more accurate simulation paths than direct CSV playback. The controller data bridges simulation steps to real time via <code>FileNo</code>/<code>LineNo</code>, and the sensor data bridges real time to force/torque readings.</p>
|
||
</div>
|
||
<hr>
|
||
<h2 id="4-run-simulation">4. Run Simulation</h2>
|
||
<pre><code class="lang-csharp">PlayNcFile("NC/file1.nc");
|
||
</code></pre>
|
||
<div class="WARNING">
|
||
<h5>Warning</h5>
|
||
<p>During training, <strong>do not</strong>:</p>
|
||
<ul>
|
||
<li>Adjust workpiece, tool, or controller resolution settings</li>
|
||
<li>Use the NC player reset button (close the project instead)</li>
|
||
<li>Save the project (system training configuration may overwrite tool resolution settings)</li>
|
||
</ul>
|
||
</div>
|
||
<hr>
|
||
<h2 id="5-export-simulation-data">5. Export Simulation Data</h2>
|
||
<p>Export step data and waveform data for analysis:</p>
|
||
<pre><code class="lang-csharp">WriteStepFiles("Output/[NcName].step.csv");
|
||
WriteShotFiles("Output/[NcName].shot.csv", 1);
|
||
</code></pre>
|
||
<p>The shot file contains time-resolved force columns: <code>Tool.Fx/Fy/Fz</code>, <code>Workpiece.Fx/Fy/Fz</code>, <code>Spindle.Mx/My/Mz</code>.</p>
|
||
<p>For coordinate system explanations, see <a href="../manual/analysis/milling-physics-coordinates.html">Milling Physics Coordinates</a>.</p>
|
||
<hr>
|
||
<h2 id="6-train-milling-parameters">6. Train Milling Parameters</h2>
|
||
<h3 id="trainmillingpara-new-training">TrainMillingPara (New Training)</h3>
|
||
<p><a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_TrainMillingPara_">TrainMillingPara</a> trains new coefficients independently of any existing workpiece parameters.</p>
|
||
<pre><code class="lang-csharp">TrainMillingPara(Fx|Fy|Fz, "StainlessSteel.mp");
|
||
</code></pre>
|
||
<h3 id="retrainmillingpara-calibration">ReTrainMillingPara (Calibration)</h3>
|
||
<p><a class="xref" href="../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_ReTrainMillingPara_">ReTrainMillingPara</a> calibrates existing coefficients (10% original weight, 90% new sample weight).</p>
|
||
<pre><code class="lang-csharp">ReTrainMillingPara(Fz|Mx|My|Mz, "StainlessSteel.mp");
|
||
</code></pre>
|
||
<h3 id="sample-flag-requirements">Sample Flag Requirements</h3>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Command</th>
|
||
<th>Minimum Data Types</th>
|
||
<th>Feed Per Tooth Requirement</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><code>TrainMillingPara</code></td>
|
||
<td><code>Fx\|Fy\|Fz</code> (dynamometer) or <code>Fz\|Mx\|My\|Mz</code> (smart tool holder)</td>
|
||
<td>At least one sample with different feed per tooth</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>ReTrainMillingPara</code></td>
|
||
<td>No restriction</td>
|
||
<td>No restriction</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="WARNING">
|
||
<h5>Warning</h5>
|
||
<p>Using only <code>Mx|My|Mz</code> without <code>Fz</code> loses one degree of freedom (torque = r × F loses the r-direction), making coefficient training unreliable. Always include <code>Fz</code> when using torque data.</p>
|
||
</div>
|
||
<h3 id="training-conditions">Training Conditions</h3>
|
||
<ul>
|
||
<li>Samples should have <strong>stable, repeatable waveforms</strong> for at least two spindle revolutions</li>
|
||
<li>Under unstable conditions, plowing coefficients tend to be over-estimated</li>
|
||
<li>Any NC path shape (slot milling, side milling, any tool shape) is acceptable when samples are stable</li>
|
||
</ul>
|
||
<hr>
|
||
<h2 id="7-evaluate-training-quality">7. Evaluate Training Quality</h2>
|
||
<p>After training, the system reports three quality metrics:</p>
|
||
<h3 id="correlation-coefficient-r">Correlation Coefficient (R)</h3>
|
||
<p>A single value for the overall result. Ranges from 0 to 1; for new tools, expect 0.95–0.999.</p>
|
||
<h3 id="training-error-ratio-trainingerrratio">Training Error Ratio (TrainingErrRatio)</h3>
|
||
<p>A per-step variable registered automatically after training. Lower values indicate better step-level quality:</p>
|
||
<div class="math">
|
||
\[
|
||
\text{TrainingErrRatio} = \sqrt{\frac{\sum_{i} e_i^2}{\sqrt{\sum_{i} y_i^2 \cdot \sum_{i} \hat{y}_i^2}}}
|
||
\]</div>
|
||
<h3 id="angle-offset-angleoffset">Angle Offset (AngleOffset)</h3>
|
||
<p>A per-step variable representing the cutter rotation phase difference between measured and simulated data:</p>
|
||
<div class="math">
|
||
\[
|
||
\theta_{offset} = \frac{2\pi \cdot i_{min}}{N_{div}}
|
||
\]</div>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p>If <code>AngleOffset</code> varies significantly across segments in the same training batch, the spindle may have experienced speed changes, data gaps, or the system could not accurately analyze the samples.</p>
|
||
</div>
|
||
<hr>
|
||
<h2 id="8-load-trained-parameters">8. Load Trained Parameters</h2>
|
||
<p>After training, load the new coefficients into the workpiece:</p>
|
||
<pre><code class="lang-csharp">LoadCuttingParaByFile("StainlessSteel.mp");
|
||
</code></pre>
|
||
<div class="WARNING">
|
||
<h5>Warning</h5>
|
||
<p>If the training output file path is the same as the tool's existing cutting parameter file, <strong>reload the project</strong> after training to ensure the new parameters take effect.</p>
|
||
</div>
|
||
<hr>
|
||
<h2 id="xml-configuration-gui-workflow">XML Configuration (GUI Workflow)</h2>
|
||
<p>When using the GUI-based training workflow, configure the <code>.hincproj</code> file:</p>
|
||
<pre><code class="lang-xml"><MillingParaGridTrainingDestinationFile>MillingPara/trainedPara.mp</MillingParaGridTrainingDestinationFile>
|
||
|
||
<MillingParaTraining>
|
||
<IsMzEnabled>false</IsMzEnabled>
|
||
<ForceOutlierRatio>2</ForceOutlierRatio>
|
||
<LeadParaTemplate>
|
||
<RakeFaceCuttingParaMap>
|
||
<FluteFormNum>1</FluteFormNum>
|
||
<NAngleDivisionNum>0</NAngleDivisionNum>
|
||
<EcAngleDivisionNum>0</EcAngleDivisionNum>
|
||
</RakeFaceCuttingParaMap>
|
||
</LeadParaTemplate>
|
||
<ResultParaTemplate>
|
||
<RakeFaceCuttingParaMap>
|
||
<FluteFormNum>1</FluteFormNum>
|
||
<NAngleDivisionNum>0</NAngleDivisionNum>
|
||
<EcAngleDivisionNum>0</EcAngleDivisionNum>
|
||
</RakeFaceCuttingParaMap>
|
||
</ResultParaTemplate>
|
||
</MillingParaTraining>
|
||
</code></pre>
|
||
<p>Set <code>IsMzEnabled</code> to <code>true</code> if mapped data contains axial spindle torque from a smart tool holder.</p>
|
||
<hr>
|
||
<h2 id="complete-script-example">Complete Script Example</h2>
|
||
<pre><code class="lang-csharp">MachiningResolution_mm = 0.0625;
|
||
EnablePhysics = true;
|
||
MillingForceCycleDivisionNum = 360;
|
||
|
||
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");
|
||
|
||
PlayNcFile("NC/file1.nc");
|
||
|
||
TrainMillingPara(Fx|Fy|Fz, "MillingPara/trained.mp");
|
||
LoadCuttingParaByFile("MillingPara/trained.mp");
|
||
|
||
WriteStepFiles("Output/[NcName].step.csv");
|
||
WriteShotFiles("Output/[NcName].shot.csv", 1);
|
||
</code></pre>
|
||
<h2 id="see-also">See Also</h2>
|
||
<ul>
|
||
<li><a href="../manual/analysis/milling-physics-coordinates.html">Milling Physics Coordinates</a> — coordinate system reference</li>
|
||
<li><a href="sensor-mapping.html">Sensor Mapping Workflow</a> — detailed mapping workflow</li>
|
||
<li><a class="xref" href="basic-simulation.html">Workflow: Basic Machining Simulation</a> — basic simulation setup</li>
|
||
<li><a class="xref" href="nc-optimization.html">Workflow: NC Optimization</a> — optimization after training</li>
|
||
<li><a class="xref" href="../manual/runtime/machining-step.html">Glossary: Machining Step</a> — step data reference</li>
|
||
<li><a class="xref" href="../manual/runtime/session-shell.html">Glossary: SessionShell Quick-Reference</a> — SessionShell quick-reference</li>
|
||
<li><a href="examples/milling-training-dynamometer.html">Training with a Dynamometer (Example)</a></li>
|
||
<li><a href="examples/mapping-demo.html">Cascading Mapping (Example)</a></li>
|
||
</ul>
|
||
|
||
</article>
|
||
|
||
<div class="contribution d-print-none">
|
||
</div>
|
||
|
||
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
||
|
||
</div>
|
||
|
||
<div class="affix">
|
||
<nav id="affix"></nav>
|
||
</div>
|
||
</main>
|
||
|
||
<div class="container-xxl search-results" id="search-results"></div>
|
||
|
||
<footer class="border-top text-secondary">
|
||
<div class="container-xxl">
|
||
<div class="flex-fill">
|
||
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
</body>
|
||
</html>
|