In this How-to guide, we will explain how to execute a movement (profile position) by directly changing the register values, instead of using MotionLab or the dedicated macros for motion.
We will consider a movement towards a specific position in this example.
Changing registers can be done in motion lab, by using macros, or externally by using for example CAN-communication. This How-To just focuses on the sequence of commands that needs to be done for a movement.
Changing directly the register values is only recommended for advanced users.
- All the documentation about relevant motion registers can be found in the EMCL documentation: Motion objects
- The register values are always in counts: position is counts, velocity counts/sec etc. The conversions depend on the resolution, maximum stroke of a motor etc. In general, how to convert units can be found here: EMCL Units
- A step by step guide explaining how to set up serial commanding: Serial commanding
- Explanation of profile position mode: Profile position mode
First, the movement should be prepared, meaning all the relevant parameters should be set:
Execute the movement
Starting the movement
Now that all the parameters are set correctly, we can start the movement by changing the controlword (register 0x6040). For more information about the control word, see 'Controlword in profile position mode' explanation: Profile position mode
Most important steps here are:
- Set the driver status to Ready to Switch On -> controlword value to 6
- Set the driver status to Switch On -> controlword value to 7
- Set the driver status to Operation Enable -> controlword value to 15
- The requested target position is sent to the motion controller.
- After the new target position has been delivered to the drive, the motion controller expects a controlword with a rising edge of the "New set point" bit.
- Upon reception of the controlword with the rising edge of the "New set point" bit, the motion controller issues a statusword with a "Set-point acknowledge" bit rising edge.
- To signal its ability to accept new set points, the motion controller issues a statusword with the "Set-point acknowledge" bit cleared.
If the system was not processing any position, the new position is processed and the motion starts. Nevertheless, if there was a previous set point being processed. the behavior of the system depends on the "Change set immediately" bit in the controlword:
- If the "Change set immediately" bit of the controlword is 1, the target point is the new set point, and motion is started to reach this new set point.
- If the "Change set immediately" bit of the controlword is 0, the new set point is added to a buffer of set points, and the motion to the previous set being processed is not altered.
Note: the register values in motion lab are given in either decimal or hexadecimal, so changing the bit can be tricky.
Now that the movement has started, we need to monitor the statusword bit. To see if the target is reached, see 'Statusword in profile position mode' explanation: Profile position mode
Once the 10th bit (target bit) is 1, the target has been reached (unless a controlled stop is being made by the Halt bit of the control word).
Serial code example
Steps to be done to be able to manually move the motor to a specific position.
Set Modes of Operation to Profile Position
Write in Modes of Operation (0x6060) a Value of 1
Set the driver status to Ready to Switch On
Write in the controlword (0x6040) a Shutdown Command (Value 6)
Set the driver status to Switch On
Write in the controlword (0x6040) a Switch on Command (Value 7)
Set the driver status to Operation Enable
Write in the controlword (0x6040) a Switch on Command (Value 15)
Set the new Target Position
Write in Target Position (0x607A) the new value (8000)
Set the new Set-point on controlword
Write in the controlword (0x6040) a Value of 31
Reset the new Set-point on controlword
Write in the controlword (0x6040) a Value of 15
The movement will be executed using the profile acc/dec set. The acc/dec can be changed before changing the 'new set-point' on the controlword.
w 0x6060 1
w 0x6040 6
w 0x6040 7
w 0x6040 15
w 0x607A x (x = your target position, in counts!)
w 0x6040 31
w 0x6040 15