こちらは新しい記事シリーズで三菱電機の最新のMXRコントローラーを使用し様々な検証を行います。第5話は、前回で紹介したMOTION FBをバラバラ呼び出すのではなく、1つのFBとしてまとめ、そして構造化FBDから使用します。こちらは今回記事で使用した機器です。
三菱電機製MXR300-64
ワイドミュラー製UR20-FBC-CC-TSN
三菱電機製NZ2GN2S1-32D
EXOR製ex707M
さ、FAを楽しもう!
前書き
いつも私の技術ブログとYouTubeチャンネルをご覧いただき、心より感謝申し上げます。また、いまFullさん(full@桜 八重 (@fulhause) / X)と共に毎週水曜日の夜にお届けしている「高橋クリス」ラジオ番組を運営しています。
技術は独り占めせず、届けるもの
私たちは工場の生産技術や制御に関する技術情報を、ブログや動画などで無料公開しています。「知識は誰でもアクセスできるべき」という信念のもと、現場で役立つ具体的なノウハウやトラブル事例などを発信してきました。すべて無料で続けているのは、「知らなかったせいで困る人」を少しでも減らしたいからです。
また、もしあなたの現場で…
「このPLCとデバイスの組み合わせ、ちゃんと動くのかな?」 「EtherCAT通信でうまくいかない部分を検証してほしい」 「新しいリモートI/Oを試したいけど社内に検証環境がない」
など、困っている構成や試してみたいアイデアがあれば、ぜひお知らせください。機器の貸出や構成の共有が可能であれば、検証し、記事や動画で発信します(ご希望に応じて匿名対応も可能です)。
支援のかたち
現在、私達の活動はほぼ無償で続けており、記事や動画の制作には、時間と検証環境の整備が必要です。この活動を継続的にコンテンツを提供するためには、皆様の温かいご支援が大変重要です。
メンバーシップ(ラジオの応援)
Fullさんとのラジオをより充実させるための支援プランです。
https://note.com/fulhause/membership/join
Amazonギフトリスト
コンテンツ制作に必要な機材・書籍をリストにしています。
https://www.amazon.co.jp/hz/wishlist/ls/H7W3RRD7C5QG?ref_=wl_share
Patreon(ブログ・動画活動への応援)
月額での小さなご支援が、記事の執筆・検証環境の充実につながります。
https://www.patreon.com/user?u=84249391
Paypal
小さな支援が大きな力になります。
https://paypal.me/soup01threes?country.x=JP&locale.x=ja_JP
知ってたら助かること、届けたいだけです
あなたの応援が、知識の共有をもっと自由で持続可能なものにしてくれます。これからもどうぞよろしくお願いします。
soup01threes*gmail.com
https://x.com/3threes2
技術はひとりじゃもったいない。
Reference Link
http://soup01.com/ja/category/mitsubishi-jp/mxr/
Implementation
こちらは今回の記事の構成です。
FB
こちらは今回記事で作成するfbAxisBasicです。
インタフェース
こちらはfbAxisBaisc プログラムのインターフェースです。
VAR_IN_OUT(入出力変数)
ラベル名
データ型
説明
iodutAxis_REF
AXIS_VIRTUAL
軸参照(仮想軸)
iodutServo
dutServo
サーボ制御用DUT
iodutMC_INPUT_REF
MC_INPUT_REF
モーション入力変数
VAR_INPUT(入力変数)
ラベル名
データ型
説明
xEnable
Bit
FB有効化指令
VAR_OUTPUT(出力変数)
ラベル名
データ型
説明
oxServoIsReady
Bit
サーボReady状態
orCurrentPosition
FLOAT [Double Precision]
現在位置
oxError
Bit
エラーフラグ
oxWarning
Bit
警告フラグ
oxAbsDone
Bit
絶対値位置決め完了
oxMotionBusy
Bit
モーション実行中
owErrorID
Word [Unsigned] / Bit String [16-bit]
エラーコード
owWarningID
Word [Unsigned] / Bit String [16-bit]
警告コード
VAR(内部変数)
ラベル名
データ型
説明
xMoveAbsEnable
Bit
絶対値位置決め有効フラグ
xMoveRelEnable
Bit
相対値位置決め有効フラグ
xMoveVelEnable
Bit
速度制御有効フラグ
xHomEnable
Bit
ホーミング有効フラグ
xEnable
Bit
内部有効フラグ
xJogFWEnable
Bit
JOG正転有効フラグ
xJogBWEnable
Bit
JOG逆転有効フラグ
fbMC_Power
MC_Power
サーボ電源制御FB
fbMC_Reset
MC_Reset
エラーリセットFB
fbMC_Jog
MCv_Jog
JOG運転FB
fbMC_Home
MC_Home
原点復帰FB
fbMC_Stop
MC_Stop
停止制御FB
fbMC_MoveAbsolute
MC_MoveAbsolute
絶対値位置決めFB
fbMC_MoveRelative
MC_MoveRelative
相対値位置決めFB
fbMC_MoveVelocity
MC_MoveVelocity
速度制御FB
fbMC_ReadStatus
MC_ReadStatus
軸ステータス読み出しFB
プログラム
こちらはFB内部のプログラムです。
xEnable:=ixEnable ;
xJogFWEnable:=xEnable
// AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
AND NOT iodutServo.Command.xServoJogBW
;
xJogBWEnable:=xEnable
//AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
AND NOT iodutServo.Command.xServoJogFW
;
xHomEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveAbsEnable:=xEnable
AND NOT fbMC_Jog.Busy
// AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveRelEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
// AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveVelEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
// AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
fbMC_ReadStatus(
Axis:= iodutAxis_REF.AxisRef
,Enable := TRUE
,Options:= 0
// ,Valid=> ?BOOL?
// ,Busy=> ?BOOL?
// ,Error=> ?BOOL?
// ,ErrorID=> ?WORD?
,ErrorStop=> iodutServo.Monitor.xErrorStop
,Disabled=> iodutServo.Monitor.xDisabled
,Stopping=> iodutServo.Monitor.xStopping
,Homing=> iodutServo.Monitor.xHoming
,Standstill=> iodutServo.Monitor.xStandstill
,DiscreteMotion=> iodutServo.Monitor.xDiscrete
,ContinuousMotion=> iodutServo.Monitor.xContinuous
,SynchronizedMotion=> iodutServo.Monitor.xSync
);
fbMC_Power(
Axis:= iodutAxis_REF.AxisRef
,Enable := xEnable AND iodutServo.Command.xServoEnb
,ServoON:= xEnable AND iodutServo.Command.xServoON
,Status=> iodutServo.Monitor.xPowerStatus
,ReadyStatus=> iodutServo.Monitor.xReadyStatus
// ,Busy=> ?BOOL?
// ,Error=> ?BOOL?
,ErrorID=> iodutServo.Monitor.wPowerONErrId
);
fbMC_Reset(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoReset
,Options:= 0
// ,Done=> ?BOOL?
// ,Busy=> ?BOOL?
// ,CommandAborted=> ?BOOL?
// ,Error=> ?BOOL?
// ,ErrorID=> ?WORD?
);
fbMC_Home(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoHome AND xHomEnable
,Position:= 0.0
,AbsSwitch:= ioudtMC_INPUT_REF
,Options:= 0
// ,Done=> ?BOOL?
// ,Busy=>
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xHomeErr
,ErrorID=> iodutServo.Monitor.wHomeErrID
);
fbMC_Jog(
Axis:= iodutAxis_REF.AxisRef
,JogForward:= xJogFWEnable AND iodutServo.Command.xServoJogFW
,JogBackward:= xJogBWEnable AND iodutServo.Command.xServoJogBW
,Velocity:= iodutServo.Command.rMoveJogVel
,Acceleration:= 10.0
,Deceleration:= 10.0
,Jerk:= 10.0
,Options:= 0
// ,Done=> ?BOOL?
,Busy=> iodutServo.Monitor.xJogBwBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xHomeErr
,ErrorID=> iodutServo.Monitor.wJogErrID
);
fbMC_Stop(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoStop
,Deceleration:= 10.0
,Jerk:= 10.0
,Options:= 0
,Done=> iodutServo.Monitor.xStopDone
,Busy=> iodutServo.Monitor.xStopBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xStopErr
,ErrorID=> iodutServo.Monitor.wStopErrID
);
fbMC_MoveAbsolute(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveAbs
,ContinuousUpdate:= TRUE
,Position:= iodutServo.Command.rMoveAbsPos
,Velocity:= iodutServo.Command.rMoveAbsVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
,Direction:= 3
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
,Done=> iodutServo.Monitor.xMoveAbsDone
,Busy=> iodutServo.Monitor.xMovAbsBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovAbsErr
,ErrorID=> iodutServo.Monitor.wMoveAbsErrId
);
fbMC_MoveRelative(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveRel
,ContinuousUpdate:= TRUE
,Distance:= iodutServo.Command.rMoveRelPos
,Velocity:= iodutServo.Command.rMoveRelVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
// ,Done=> ?BOOL?
,Busy=> iodutServo.Monitor.xMovRelBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovRelErr
,ErrorID=> iodutServo.Monitor.wMoveRelErrId
);
fbMC_MoveVelocity(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveVel
,ContinuousUpdate:= TRUE
,Velocity:= iodutServo.Command.rMoveVelVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
,Direction:= MC_DIRECTION__mcPositiveDirection
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
,InVelocity=> iodutServo.Monitor.xMoveVelInVevl
// ,Busy=> ?BOOL?
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovVelErr
,ErrorID=> iodutServo.Monitor.wMoveVelErrId
);
iodutServo.Monitor.rActualPos:=iodutAxis_REF.Md.CumulativePosition;
iodutServo.Monitor.rCommandPos:=iodutAxis_REF.Md.CommandedPosition;
iodutServo.Monitor.rCommandVel:=iodutAxis_REF.Md.CommandedVelocity;
iodutServo.Monitor.wErrorID:=iodutAxis_REF.Md.ErrorID;
iodutServo.Monitor.wWarningID:=iodutAxis_REF.Md.WarningID;
oxAbsDone:=iodutServo.Monitor.xMoveAbsDone;
oxError:=iodutServo.Monitor.xError;
oxWarning:=iodutServo.Monitor.xWarning;
oxMotionBusy:= fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
;
oxServoisReady:=iodutServo.Monitor.xPowerStatus;
orCurrentPosition:=iodutServo.Monitor.rActualPos;
owErrorID:=iodutServo.Monitor.wErrorID;
owWarningID:=iodutServo.Monitor.wWarningID;
イネーブル条件の生成
各モーション動作のイネーブルフラグは、共通の安全条件を満たした場合にのみTRUEになります。共通条件(全動作共通)は、xEnable = TRUE AND サーボReady(xReadyStatus)= TRUE AND 軸エラーなし(Md.Error)= FALSE AND 競合する他の動作FB が Busyでなくなります。
xEnable:=ixEnable ;
xJogFWEnable:=xEnable
// AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
AND NOT iodutServo.Command.xServoJogBW
;
xJogBWEnable:=xEnable
//AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
AND NOT iodutServo.Command.xServoJogFW
;
xHomEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveAbsEnable:=xEnable
AND NOT fbMC_Jog.Busy
// AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveRelEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
// AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
xMoveVelEnable:=xEnable
AND NOT fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
// AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
AND iodutServo.Monitor.xReadyStatus
AND NOT iodutAxis_REF.Md.Error
;
各FBの呼び出し
次は各MOTION FBを呼び出します。
fbMC_ReadStatus
Enable=TRUE(常時有効)で軸ステータスを継続監視し、ErrorStop・Disabled・Stopping・Homing・Standstill・DiscreteMotion・ContinuousMotion・SynchronizedMotionをiodutServo.Monitorに格納します。
fbMC_ReadStatus(
Axis:= iodutAxis_REF.AxisRef
,Enable:= TRUE
,Options:= 0
// ,Valid=> ?BOOL?
// ,Busy=> ?BOOL?
// ,Error=> ?BOOL?
// ,ErrorID=> ?WORD?
,ErrorStop=> iodutServo.Monitor.xErrorStop
,Disabled=> iodutServo.Monitor.xDisabled
,Stopping=> iodutServo.Monitor.xStopping
,Homing=> iodutServo.Monitor.xHoming
,Standstill=> iodutServo.Monitor.xStandstill
,DiscreteMotion=> iodutServo.Monitor.xDiscrete
,ContinuousMotion=> iodutServo.Monitor.xContinuous
,SynchronizedMotion=> iodutServo.Monitor.xSync
);
fbMC_Power
軸をSERVO ON/OFFするためのFBを呼び出します。
Enable = xEnable AND xServoEnb
ServoON = xEnable AND xServoONし
PowerStatus・ReadyStatus・エラーIDをiodutServo.Monitorに格納
fbMC_Power(
Axis:= iodutAxis_REF.AxisRef
,Enable:= xEnable AND iodutServo.Command.xServoEnb
,ServoON:= xEnable AND iodutServo.Command.xServoON
,Status=> iodutServo.Monitor.xPowerStatus
,ReadyStatus=> iodutServo.Monitor.xReadyStatus
// ,Busy=> ?BOOL?
// ,Error=> ?BOOL?
,ErrorID=> iodutServo.Monitor.wPowerONErrId
);
fbMC_Reset
軸をリセットするためのFBを呼び出します。
Execute = xServoReset
出力は使用していません(コメントアウト)
fbMC_Reset (
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoReset
,Options:= 0
// ,Done=> ?BOOL?
// ,Busy=> ?BOOL?
// ,CommandAborted=> ?BOOL?
// ,Error=> ?BOOL?
// ,ErrorID=> ?WORD?
);
fbMC_Home
軸をHOME動作するためのFBを呼び出します。
Execute = xServoHome AND xHomEnable
原点位置 = 0.0固定
AdsSwitch = ioudtMC_INPUT_REF
エラー・エラーIDのみMonitorに格納
fbMC_Home (
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoHome AND xHomEnable
,Position:= 0.0
,AbsSwitch:= ioudtMC_INPUT_REF
,Options:= 0
// ,Done=> ?BOOL?
// ,Busy=>
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xHomeErr
,ErrorID=> iodutServo.Monitor.wHomeErrID
);
fbMC_Jog
軸をJOG動作するためのFBを呼び出します。
JogForward = xJogFWEnable AND xServoJogFW
JogBackward = xJogBWEnable AND xServoJogBW
速度 = rMoveJogVel(可変)
加速度・減速度・ジャーク = 10.0固定
BusyをJogBwBusy、エラーをHomeErrに格納(共用)
fbMC_Jog (
Axis:= iodutAxis_REF.AxisRef
,JogForward:= xJogFWEnable AND iodutServo.Command.xServoJogFW
,JogBackward:= xJogBWEnable AND iodutServo.Command.xServoJogBW
,Velocity:= iodutServo.Command.rMoveJogVel
,Acceleration:= 10.0
,Deceleration:= 10.0
,Jerk:= 10.0
,Options:= 0
// ,Done=> ?BOOL?
,Busy=> iodutServo.Monitor.xJogBwBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xHomeErr
,ErrorID=> iodutServo.Monitor.wJogErrID
);
fbMC_Stop
軸をストップ動作するためのFBを呼び出します。
Execute = xServoStop
減速度・ジャーク = 10.0固定
Done・Busy・Error・ErrorIDをMonitorに格納
fbMC_Stop(
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoStop
,Deceleration:= 10.0
,Jerk:= 10.0
,Options:= 0
,Done=> iodutServo.Monitor.xStopDone
,Busy=> iodutServo.Monitor.xStopBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xStopErr
,ErrorID=> iodutServo.Monitor.wStopErrID
);
fbMC_MoveAbsolute
軸を絶対位置決め動作するためのFBを呼び出します。
Execute = xServoMoveAbs、ContinuousUpdate = TRUE
位置・速度はCommandから可変取得
加速度・減速度・ジャーク = 100.0固定、Direction = 3(最短経路)
Done・Busy・Error・ErrorIDをMonitorに格納
fbMC_MoveAbsolute (
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveAbs
,ContinuousUpdate:= TRUE
,Position:= iodutServo.Command.rMoveAbsPos
,Velocity:= iodutServo.Command.rMoveAbsVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
,Direction:= 3
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
,Done=> iodutServo.Monitor.xMoveAbsDone
,Busy=> iodutServo.Monitor.xMovAbsBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovAbsErr
,ErrorID=> iodutServo.Monitor.wMoveAbsErrId
);
fbMC_MoveRelative
軸を相対位置決め動作するためのFBを呼び出します。
Execute = xServoMoveRel、ContinuousUpdate = TRUE
移動量・速度はCommandから可変取得
加速度・減速度・ジャーク = 100.0固定
Busy・Error・ErrorIDをMonitorに格納
fbMC_MoveRelative (
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveRel
,ContinuousUpdate:= TRUE
,Distance:= iodutServo.Command.rMoveRelPos
,Velocity:= iodutServo.Command.rMoveRelVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
// ,Done=> ?BOOL?
,Busy=> iodutServo.Monitor.xMovRelBusy
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovRelErr
,ErrorID=> iodutServo.Monitor.wMoveRelErrId
);
fbMC_MoveVelocity
軸を速度制御する動作するためのFBを呼び出します。
Execute = xServoMoveVel、ContinuousUpdate = TRUE
速度はCommandから可変取得
加速度・減速度・ジャーク = 100.0固定、Direction = 正転固定
InVelocity・Error・ErrorIDをMonitorに格納
fbMC_MoveVelocity (
Axis:= iodutAxis_REF.AxisRef
,Execute:= iodutServo.Command.xServoMoveVel
,ContinuousUpdate:= TRUE
,Velocity:= iodutServo.Command.rMoveVelVel
,Acceleration:= 100.0
,Deceleration:= 100.0
,Jerk:= 100.0
,Direction:= MC_DIRECTION__mcPositiveDirection
// ,BufferMode:= ?INT?
// ,Options:= ?DWORD?
,InVelocity=> iodutServo.Monitor.xMoveVelInVevl
// ,Busy=> ?BOOL?
// ,Active=> ?BOOL?
// ,CommandAborted=> ?BOOL?
,Error=> iodutServo.Monitor.xMovVelErr
,ErrorID=> iodutServo.Monitor.wMoveVelErrId
);
モニタ値の転送
こちらはAXISREF軸のデータをFB出力するプログラムです。
rActualPos ← Md.CumulativePosition(現在位置)
rCommandPos ← Md.CommandedPosition(指令位置)
rCommandVel ← Md.CommandedVelocity(指令速度)
wErrorID ← Md.ErrorID
wWarningID ← Md.WarningID
iodutServo.Monitor.rActualPos:=iodutAxis_REF.Md.CumulativePosition;
iodutServo.Monitor.rCommandPos:=iodutAxis_REF.Md.CommandedPosition;
iodutServo.Monitor.rCommandVel:=iodutAxis_REF.Md.CommandedVelocity;
iodutServo.Monitor.wErrorID:=iodutAxis_REF.Md.ErrorID;
iodutServo.Monitor.wWarningID:=iodutAxis_REF.Md.WarningID;
出力変数への反映
こちらはFB出力するプログラムです。
出力変数
参照元
内容
oxAbsDone
xMoveAbsDone
絶対値位置決め完了
oxError
xError
エラーフラグ
oxWarning
xWarning
警告フラグ
oxMotionBusy
各FB.Busy のOR
いずれかのモーションFB実行中
oxServoisReady
xPowerStatus
サーボReady状態
orCurrentPosition
rActualPos
現在位置
owErrorID
wErrorID
エラーコード
owWarningID
wWarningID
警告コード
oxAbsDone:=iodutServo.Monitor.xMoveAbsDone;
oxError:=iodutServo.Monitor.xError;
oxWarning:=iodutServo.Monitor.xWarning;
oxMotionBusy:= fbMC_Jog.Busy
AND NOT fbMC_MoveAbsolute.Busy
AND NOT fbMC_MoveRelative.Busy
AND NOT fbMC_MoveVelocity.Busy
AND NOT fbMC_Home.Busy
;
oxServoisReady:=iodutServo.Monitor.xPowerStatus;
メインプログラム
最後はメインプログラムを作成します。最初にPart4で作成したプログラムをNo Execution Typeに移動します。それによりpServo1が実行しなくなります。
次はpServo2を作成します。
ラベル
fbAxisBasicは先ほどモーションFBをラップした上位FBであり、pServo2プログラムからはこのインスタンスを通じて軸制御を行う構成となっています。
ラベル名
データ型
説明
fbAxisBasic_00
fbAxisBasic
軸制御基本FB(インスタンス)
udtMC_INPUT_REF
MC_INPUT_REF
モーション入力参照(近点ドグ等)
rCurrentPos
FLOAT [Double Precision]
現在位置格納用変数
プログラム
このCFCはfbAxisBasic_00(fbAxisBasic)を呼び出す上位プログラムです。M900がONになるとfbAxisBasicが有効化され、Axis0001軸の全モーション制御が実行可能になります。各状態はM950〜M955およびD2000・D2002に格納され、後段のHMI監視や保護回路で参照されます。rCurrentPosには常時現在位置が反映されます。
入力
ピン
接続元
内容
EN
M900(①)
FB実行有効
ixEnable
M900(②)
軸制御有効化指令
iodutAxis_REF
Axis0001(③)
制御対象軸参照
iodutServo
udtAxis001(④)
サーボ制御用DUT
ioudtMC_INPUT_REF
udtMC_INPUT_REF(⑤)
モーション入力参照(近点ドグ)
出力
ピン
接続先
内容
oxServoisReady
M950(⑦)
サーボReady状態
orCurrentPosition
rCurrentPos(⑧)
現在位置
oxError
M952(⑨)
エラーフラグ
oxWarning
M953(⑩)
警告フラグ
oxAbsDone
M954(⑪)
絶対値位置決め完了
oxMotionBusy
M955(⑫)
モーション実行中フラグ
owErrorID
D2000(⑬)
エラーコード
owWarningID
D2002(⑭)
警告コード
iodutAxis_REF
Axis0001
軸情報返却
iodutServo
udtAxis001
サーボDUT返却
ioudtMC_INPUT_REF
udtMC_INPUT_REF
入力参照返却
ダウンロード
最後はプロジェクトをMXRコントローラーにダウンロードし、CPUを再起動してください。
結果
M900をTRUEにし、Servo ONをさせます。
そして絶対位置決め動作をさせます。
仮想軸が動き始めます。
Done!それで位置決め完了しました。