How do I use the TMCL command MVP COORD?
The MVP (Move to Position) tells the motion controller to move a motor to a specific position. This command has 3 "types" that define how the target position is interpreted. The COORD type will be discussed in detail in this article. For other MVP types, please reference KA-15007.
MVP COORD command moves the motor to an absolute position, similar to the MVP ABS command, but the position value is already stored in memory, called a "coordinate". Each motor axis has its own coordinate memory and some TMCM modules can store up to 20 coordinates per axis. Please reference the TMCL firmware manual for your device to find out how many coordinates you can store.
If using a multi-axis TMCM board, the COORD type also allows for moving multiple motors at the same time. In this case, you have the option to move all motors with our without interpolation.
Interpolation allows for all motors to reach their target position at the same time. The TMCM will calculate all velocities and accelerations needed such that the motors will arrive at their destination at the same time, offloading these calculations away from the host device. This can be very useful for gantry applications or applications that require strict coordination between multiple motors.
Without interpolation, all movements occur using velocity and ramp settings defined by the Axis Parameters for those motor axes.
Please see examples below for information on how to command multiple motors, both with and without interpolation.
Syntax for this command is as follows: MVP COORD <axis> <coordinate number>
EXAMPLE 1: Moving a single motor (axis 0) to location 15000 using the MVP COORD command
Step 1: First, a target position must be written to axis 0's coordinate memory. This can be achieved using the Set Coordinate command (SCO), Capture Coordinate command (CCO), or Accumulator to Coordinate command (ACO). For more information on these commands, please reference the firmware manual of your TMCM device.
SCO 1 0 15000 //Set axis 0's coordinate number 1 to a value of 15000.
Step 2: Then, the MVP COORD command can be called. <axis> will be 0 to address motor 0. <Coordinate number> will be 1 to specify which block in memory to pull the target position from.
MVP COORD 0 1 // Moves motor 0 to position stored in coordinate 1
Motor 0 will now rotate to position 15000 using velocity and ramps as defined by axis 0's Axis Parameters.
EXAMPLE 2: Moving motor 0 to position 15000, and motor 4 to position 7500 using the MVP COORD command without interpolation
Step 1: Again, the target positions must be written to coordinate memory.
SCO 1 0 15000 // Sets axis 0's coordinate number 1 to a value of 15000
SCO 1 4 7500 // Sets axis 4's coordinate number 1 to a value of 7500
Step 2: Call the MVP COORD command. To command movement of multiple motors without interpolation, set bit 7 of <axis>. Now the bits 0... 5 of the <motor> parameter define which motors are to be started. Each of these bits stands for one motor. Since we want to move motor 0 and motor 4 without interpolation, the <axis> value should be 145 (145 is decimal for binary 1001 0001).
MVP COORD 145 1 // Moves motors 0 and 4 (without interpolation) to positions stored in their respective coordinate 1
Motor 0 will now rotate to position 15000 and motor 4 will rotate to position 7500. Velocity and ramps are defined by each motor axis' Axis Parameters.
EXAMPLE 3: Moving motor 0 to position 15000, and motor 4 to position 7500 using the MVP COORD command with interpolation. The goal being to start motor movements at the same time, and have them reach their target destinations at the same time
Step 1: Write target positions to coordinate memory.
SCO 1 0 15000 // Sets axis 0's coordinate number 1 to a value of 15000
SCO 1 4 7500 // Sets axis 4's coordinate number 1 to a value of 7500
Step 2: Call the MVP COORD command. To command movement of multiple motors with interpolation, set bit 6 of <axis>. Now the bits 0... 5 of the <motor> parameter define which motors are to be started. Each of these bits stands for one motor. Since we want to move motor 0 and motor 4 with interpolation, the <axis> value should be 81 (81 is decimal for binary 0101 0001).
MVP COORD 81 1 // Moves motors 0 and 4 (with interpolation) to positions stored in their respective coordinate 1
Motor 0 will now rotate to position 15000 and motor 4 will rotate to position 7500. Velocity and ramps are internally calculated such that target positions will be reached at the same time.