2025-12-18 11:09:45 +08:00

205 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>訓練與校正銑削係數 | HiAPI-C# 2025 </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="訓練與校正銑削係數 | 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 &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<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="Cmd-MillingTraining">
<h1 id="訓練與校正銑削係數">訓練與校正銑削係數</h1>
<p>銑削係數為計算銑削力的必須參數。</p>
<p>訓練與校正銑削係數需先完成<a href="../Mapping/index.html">資料映射</a></p>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_TrainMillingPara_">TrainMillingPara</a><small>(API)</small>訓練銑削係數,不需先設定工件銑削係數,輸出的新係數也與原工件銑削係數無關。</p>
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ReTrainMillingPara_">ReTrainMillingPara</a><small>(API)</small>校正銑削係數需基於已設定之工件銑削係數才可輸出校正後係數。校正時原係數的權重10%、從資訊映射而得的樣本權重90%。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code>//訓練銑削係數
TrainMillingPara(&lt;樣本旗標&gt;, &lt;檔案輸出路徑&gt;);
//校正銑削係數
ReTrainMillingPara(&lt;樣本旗標&gt;, &lt;檔案輸出路徑&gt;);
</code></pre>
</div>
<p>&lt;樣本旗標&gt; 為應用於訓練資料的資料種類,包含:<code>Fx</code><code>Fy</code><code>Fz</code><code>Mx</code><code>My</code><code>Mz</code>
使用<code>|</code>號作聯集。</p>
<div class="TIP">
<h5>Tip</h5>
<p><strong>以動力計資料為例,輸出訓練銑削係數</strong></p>
<pre><code>ClearTimeMappingData();
AddTimeDataByFile( &quot;lineA&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:25:51.7100&quot;, &quot;18:26:12.9910&quot;);
AddTimeDataByFile( &quot;lineB&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:26:30.5750&quot;, &quot;18:27:12.2880&quot;);
PlayNcFile(&quot;NC/file1.nc&quot;)
TrainMillingPara(Fx|Fy|Fz, &quot;StainlessSteel.mp&quot;);
</code></pre>
</div>
<div class="TIP">
<h5>Tip</h5>
<p><strong>以智慧刀把資料為例,輸出校正銑削係數</strong></p>
<pre><code>ClearTimeMappingData();
AddTimeDataByFile( &quot;lineA&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:25:51.7100&quot;, &quot;18:26:12.9910&quot;);
AddTimeDataByFile( &quot;lineB&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:26:30.5750&quot;, &quot;18:27:12.2880&quot;);
PlayNcFile(&quot;NC/file1.nc&quot;)
ReTrainMillingPara(Fz|Mx|My|Mz, &quot;StainlessSteel.mp&quot;);
</code></pre>
</div>
<h2 id="訓練條件">訓練條件</h2>
<p>路徑樣本<u>以穩定資料訓練佳</u>,即資料波形有重複性維持至少兩轉。因系統演算法最低以一轉波形做訓練。
在非穩定情況,會因為模擬中的每刃進給固定、訓練資料不穩定,造成剪切力於總力占比降低,使得訓練出的犁切係數偏高。</p>
<p>樣本穩定的情況下NC路徑沒有限制切削形狀槽銑或側銑任意形狀刀具皆可用來訓練及校正銑削係數。</p>
<p><code>TrainMillingPara</code>訓練銑削係數,資訊映射須包含至少一組不同每刃進給的路徑樣本。訓練資料的資料種類建議最少為(動力計)<code>Fx|Fy|Fz</code>或(智慧刀把)<code>Fz|Mx|My|Mz</code>
如果資料種類少於前述,如<code>Fx|Fy</code><code>Mx|My|Mz</code>,則樣本的自由度太高,訓練出來的係數不能符合訓練樣本以外的路徑。</p>
<p>如果僅使用<code>Mx|My|Mz</code>,由於力矩資料為 <span class="math">\(\vec{r} \times \vec{F}\)</span>所以r方向資料會遺失相當於少了一個自由度難以訓練材料系數。
所以力矩資料須搭配<code>Fz</code>使用。</p>
<p><code>ReTrainMillingPara</code>校正銑削係數,沒有限制資料種類及每刃進給。</p>
<h2 id="訓練品質指標">訓練品質指標</h2>
<p>訓練完成後,系統會計算以下品質指標:</p>
<h3 id="相關係數-correlation-coefficient-r">相關係數 (Correlation Coefficient, R)</h3>
<p>相關係數 <span class="math">\(R\)</span> 是整體訓練結果的單一數值,用於評估訓練後模擬值與量測值的線性相關程度,範圍為 <span class="math">\(0\)</span><span class="math">\(1\)</span>,越接近 <span class="math">\(1\)</span> 表示訓練結果越好。新刀的相關係數通常介於 0.95 至 0.999 之間。</p>
<h3 id="訓練誤差比-trainingerrratio">訓練誤差比 (TrainingErrRatio)</h3>
<p>訓練誤差比是在執行 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_TrainMillingPara_">TrainMillingPara</a><small>(API)</small><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ReTrainMillingPara_">ReTrainMillingPara</a><small>(API)</small> 後,動態註冊並設置到訓練區域內各步的<a href="../StepVariables/index.html">步變數</a>,用於評估該步的模擬與量測之間的誤差程度,數值越小表示該步的訓練品質越好。</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>
<p>其中:</p>
<ul>
<li><span class="math">\(e_i = y_i - \hat{y}_i\)</span>:第 <span class="math">\(i\)</span> 個樣本的誤差</li>
<li><span class="math">\(y_i\)</span>:量測值</li>
<li><span class="math">\(\hat{y}_i\)</span>:模擬預測值</li>
</ul>
<p>此指標會嵌入到每個加工步驟的輸出資料中,可用於識別訓練品質較差的段落。</p>
<h3 id="角度偏移-angleoffset">角度偏移 (AngleOffset)</h3>
<p>角度偏移是在執行訓練函數後,動態註冊並設置到訓練區域內各步的<a href="../StepVariables/index.html">步變數</a><span class="math">\(\theta_{offset}\)</span> 表示該步量測資料與模擬資料之間的刀刃旋轉相位差。系統會自動對齊相位以獲得最佳訓練結果。</p>
<div class="math">
\[
\theta_{offset} = \frac{2\pi \cdot i_{min}}{N_{div}}
\]</div>
<p>其中:</p>
<ul>
<li><span class="math">\(i_{min}\)</span>:使預測誤差最小的角度索引</li>
<li><span class="math">\(N_{div}\)</span>:一轉的角度分割數,即 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MillingCycleDivisionNum">MillingCycleDivisionNum</a><small>(API)</small></li>
</ul>
<div class="TIP">
<h5>Tip</h5>
<p>如果同一批訓練中各段落的 AngleOffset 差異過大,可能表示主軸旋轉突然放慢或放快或資料缺失,或系統無法準確分析樣本並導致不理想訓練的結果。</p>
</div>
<div class="TIP">
<h5>Tip</h5>
<p>較大的 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MillingCycleDivisionNum">MillingCycleDivisionNum</a><small>(API)</small> 設定可以得到更準確的 AngleOffset 結果,進而訓練出更準確的銑削係數。</p>
</div>
<h2 id="範例專案-動力計訓練銑削係數">範例專案-動力計訓練銑削係數</h2>
<p>使用動力計訓練銑削係數的範例專案可於此下載:</p>
<p><a href="https://superhightech-gitea.webredirect.org/HiNC-Deploy/Demo-Para-Training-S50C-202501">https://superhightech-gitea.webredirect.org/HiNC-Deploy/Demo-Para-Training-S50C-202501</a></p>
<p>此專案使用 Kistler 動力計量測資料,透過<a href="../Mapping/index.html#%E6%8C%87%E5%AE%9A%E6%95%B8%E6%8E%A7%E8%B7%AF%E5%BE%91%E5%8F%8A%E6%99%82%E9%96%93%E5%B1%80%E9%83%A8%E6%98%A0%E5%B0%84">一對多映射-指定數控路徑及時間局部映射</a>方式,訓練 S50C 材料的銑削係數。</p>
<p><img src="demo-training-S50C.png" alt="demo-training-S50C.png"></p>
<div class="TIP">
<h5>Tip</h5>
<p>加工路徑與切削條件可以根據現場情況自由更改。</p>
</div>
</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>