新增距離感測器記錄程式
調整參數(ProportionalGain、IntegralGain、DifferentialGain)時,您需要在執行距離追蹤功能時檢查雷射位移計的測量所得數據。
可以運用以下程式例子取得雷射位移計的測量所得數據。
請向以下章節中建立的程式添加★符號部分。
____________________________________________________________
Integer fileNum ' ★宣告檔案編號
Function AIOTrackingSample
'============================================================
' 用於記錄距離感測器(正在執行距離追蹤功能)測量值的程式。
'============================================================
'------------- 機器人配置---------------
Motor On
Power High
SpeedS 30
AccelS 300, 300
Tool 1
'--------- 建立用於記錄的CSV檔案 ------------------
fileNum = FreeFile ' ★取得檔案編號
WOpen "AIO_Monitor.csv" As #fileNum ' ★儲存到專案資料夾
'-------------動作部分---------------
Move P1 ' 移動至開始位置
Xqt AIO_Monitor ' ★開始記錄距離感測器測量值
AIO_TrackingSet 1, -1, 0, -3, 3, 0, 2 ' 設定距離追蹤功能
Wait 2AIO_TrackingStart 1, 10, 0, 0 ' 啟動距離追蹤功能
Move P2 ' 移動至目標位置
AIO_TrackingEnd ' 結束距離追蹤功能
Wait 2
Quit AIO_Monitor ' ★結束記錄距離感測器測量值
Close #fileNum ' ★關閉CSV
Motor Off
Fend
____________________________________________________________
Function AIO_Monitor ' ★
'=======================================================
' 由AIOTrackingSample叫用。
' 將輸入到類比I/O電路板Ch1的值持續記錄到CSV。
'=======================================================
Do ' ★
Print #fileNum, AIO_In(1) ' ★
Wait 0.002 ' ★
Loop ' ★
Fend ' ★
____________________________________________________________