描述
Move to the target position in Profile Position mode (pp).
Relevant Objects
- Object 6040h: Controlword
- Object 6041h: Statusword
- Object 607Ah: Target position
語法
int pp_Run(int32_t position, int relative = CIA402_PP_ABSOLUTE, bool change_immediately = false);
參數
[in] position
The target position to be set.
[in] relative
A value indicating whether the position parameter is relative or absolute:
| 定義 | 代碼 | 描述 |
| CIA402_PP_ABSOLUTE | 0 | position is an absolute value. |
| CIA402_PP_RELATIVE | 1 | position is a relative value. |
[in] change_immediately- true: Interrupt the actual positioning and start the next positioning.
- false: Finish the actual positioning and then start the next positioning.
A Boolean to determine if the target position change should be executed instantly.
回傳值
Return an error code. If the returned value is zero, it indicates a successful execution of this function.
備註
This function must be called after a successful execution of EthercatMaster::start(). This function is blocking and cannot be called in callback functions.
範例程式碼
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_CiA402 motor;
void setup() {
master.begin();
motor.attach(0, master);
motor.setCiA402Mode(CIA402_PP_MODE);
master.start();
motor.enable();
}
void loop() {
motor.pp_SetMotionProfileType(0);
motor.pp_SetVelocity(100000);
motor.pp_SetAcceleration(5000);
motor.pp_SetDeceleration(5000);
motor.pp_Run(100000, CIA402_PP_RELATIVE, true);
while (motor.pp_IsTargetReached() == 0);
motor.pp_SetMotionProfileType(0);
motor.pp_SetVelocity(30000);
motor.pp_SetAcceleration(5000);
motor.pp_SetDeceleration(5000);
motor.pp_Run(-100000, CIA402_PP_RELATIVE, true);
while (motor.pp_IsTargetReached() == 0);
}Please see the EtherCAT CiA 402 User Manual for more QEC EtherCAT instructions and API usage.