Adding Commands¶
After opening a cyclic buffer, cyclic commands can be added with the AddCommand function. Multiple cyclic commands can be added with a single function call by using the AddCommand function with a count argument.
AddCommand functions that add cyclic commands to multiple axes also exist. For these functions, the indices of the CyclicBufferMultiAxisCommands::cmd[] array passed to the function correspond to the axis numbers of the specified axes. Commands in the other indices are ignored.
Cyclic commands may be added while the axis is in Idle operation state, or dynamically while the axis is in DirectControl operation state after starting execution of a cyclic buffer.
If there is not enough space in the cyclic buffer to add the specified cyclic commands, the AddCommand function will return the BufferSizeIsNotEnough error and no cyclic commands are added to the buffer. However, the AddCommand functions that add cyclic commands to multiple axes will still add cyclic commands to any axes that were specified earlier than the axis that generated the BufferSizeIsNotEnough error.
To prevent the BufferSizeIsNotEnough error, verify that the cyclic buffer of each commanded axis has enough free space to store the added cyclic commands before calling AddCommand. The amount of free space can be obtained by using the GetStatus function and calculating availableCount - remainCount.
Cyclic Commands
Each cyclic command is defined by the CyclicBufferSingleAxisCommand class.
The type member specifies the type of cyclic command.
AbsolutePos - An absolute position specified in WMX3 coordinates. See Axis Position and User Units for more information on the position used in WMX3.
RelativePos - A relative position specified in WMX3 coordinates. This position is relative to the last position commanded by the cyclic buffer (for the first cyclic command, this position is relative to the command position at the time that the Execute function is called). For example, adding three cyclic commands with a command position of 2 will command the axis to move to 2 in the first cycle, 4 in the second cycle, and 6 in the third cycle.
Vel - A velocity specified in user units per second. This velocity is affected by the Gear Ratio. The Axis Command Mode parameter of the axis must be set to Velocity using the SetAxisCommandMode function or SetAxisParam function.
Trq - A torque specified in units of %. The Axis Command Mode parameter of the axis must be set to Torque using the SetAxisCommandMode function or SetAxisParam function.
The intervalCycles member can be set to execute the cyclic command over multiple cycles instead of one cycle. If this parameter is set to 1 or more, the cyclic command is executed over that many cycles. Each cycle, a part of the cyclic command equal to the total motion of the cyclic command divided by the value of this parameter is executed. For example, if the starting position is 100, the absolute position of the cyclic command is 130, and intervalCycles is 3, the position command will be 110 in the first cycle, 120 in the second cycle, and 130 in the third cycle. The amount of space that the cyclic command occupies in the cyclic buffer remains as 1 regardless of the value of this parameter. If this parameter is set to 0, the cyclic command is executed over one cycle.