cmdMO_SETIndex

Command Code:

The Packet:

Description:

This command is only available on BrainStem modules with the motion control feature.

The cmdMO_SET command is used to change the current 2-byte control setting for the motion control channel.

PID Mode

In any mode using PID control, the new setting becomes the new setpoint.  The PID loop will attempt to apply the appropriate PWM output to maintain the new setpoint.

Stepper Mode

In stepper mode, the setpoint is the number of steps to apply to the motor.  The sign of the value indicates the direction of the steps.  The PID PERIOD parameter determines the speed at which the motor will perform multiple steps.  If the stepper motor is performing more than one step, entering a setpoint of 0 while the motion is in progress will stop the stepper motor.  Then a new setpoint may be entered.  Entering a non-zero setpoint while a multiple step motion is in progress will cause an error.

PWM Mode

In a PWM mode using no PID control, the new setting is applied directly to the PWM output.  Internally, the PWM duty cycle is set with an unsigned 10-bit value.  An additional digital output is required to change the direction of an h-bridge.

When using this command to set a PWM duty cycle, the setting is represented as a signed 16-bit value.  The most significant bit is the sign bit which determines motor direction.  The next 10 bits are the PWM setting which determine the duty cycle.  This 16-bit value is broken up into two bytes.  The high byte contains the sign bit and 7 most significant bits.  The the low byte contains the remaining 3 bits in its 3 most significant bits.  An example of this scheme is shown below.

Hex Value Duty Cycle Direction
0x7FFF 100% Forward (+)
0x8000 100% Reverse (-)
0x4000 50% Forward (+)
0xC000 50% Reverse (-)

Mono Encoder Mode

In a PID mode using mono encoders, there is no notion of positive or negative encoder feedback.  In order to switch the direction of a motor, it must first be stopped by issuing a setpoint of 0.  The motor should come to a complete stop before issuing a new setpoint that will make the motor spin in the opposite direction.  If the motor is still spinning, there is a chance that the encoder input may be misinterpreted.

Changes introduced in Moto 1.0 Firmware Build 8

The setpoint in encoder-based position PID control mode is absolute with respect to starting position when the mode is enabled or re-enabled.  In earlier builds, a new setpoint is treated as a relative offset to the previous setpoint.  The following table illustrates this behavior.  This example assumes ideal PID parameters.

Console Command Action (Moto 1.0 Build 8 or newer)
4 63 0 0 5 0 Mode enabled
Position initialized to 0
4 62 0 0 200 New setpoint of 200
Motor moves 200 ticks to position 200
4 62 0 0 150 New setpoint of 150
Motor moves -50 ticks to position 150
4 62 0 255 246 New setpoint of -10
Motor moves -160 ticks to position -10

The following table illustrates the behavior for the same commands when issued to an older Moto module.  This example also assumes ideal PID parameters.

Console Command Action (Moto 1.0 Build 7 or earlier)
4 63 0 0 5 0 Mode enabled
Position initialized to 0
4 62 0 0 200 New setpoint of 200
Motor moves 200 ticks to position 200
4 62 0 0 150 New setpoint of 150
Motor moves 150 ticks to position 350
4 62 0 255 246 New setpoint of -10
Motor moves -10 ticks to position 340

version: 1.0, build 80903
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado.  All rights reserved.