|moID -||The channel (zero based) whose ramp parameters are to be set or retrieved.|
|paramID -||The index of the ramp parameter to change or retrieve.|
|paramH -||The high byte of the new ramp parameter.|
|paramL -||The low byte of the new ramp parameter.|
This command is only available on BrainStem modules with the motion control feature.
The cmdMO_RMPCFG command is used to set or retrieve ramp control parameters. If no parameter data is included in the packet, a reply packet is sent reporting the current value for the requested parameter.
The ramp feature provides a capability for performing motions with a trapezoidal velocity profile. The ramp motion is defined with the range to travel, maximum velocity, acceleration step time, and some control flags. The velocity and range must have the same sign. To reverse a ramp motion, both the range and maximum velocity must be negated. NOTE: The trapezoidal ramp feature may only be used with mode 7 (ENCVEL or velocity from encoder input) motion control.
The ramp feature also provides a velocity damping mode. In this mode, changes in the velocity setting take place gradually. The MAXV parameter is the velocity setting. The acceleration step time controls the rate at which the velocity changes from the old MAXV setting to the new MAXV setting. The RANGE parameters are unused in velocity damping mode. Once activated, velocity damping stays in effect until the control flags are changed or the ramp is disabled with the cmdMO_RMPENA command. NOTE: The velocity damping feature may only be used with mode 6 (A2DVEL) or mode 7 (ENCVEL) motion control*.
* Change introduced in Moto 1.0 Firmware Build 8
The velocity damping feature may also be used with mode 4 (A2DPOS) or mode 5 (ENCPOS) motion control. When using these modes, this feature applies new position setpoints instead of new velocity setpoints.
Parameter 0 --- RANGEH
This is a two-byte parameter that contains the two most significant bytes of the 4-byte range parameter. The range is specified in encoder ticks. It is up to the user to determine how many ticks correspond to a desired distance.
Parameter 1 --- RANGEL
This is a two-byte parameter that contains the two least significant bytes of the 4-byte range parameter.
Parameter 2 --- MAXV
This is a two-byte value for the maximum velocity for the ramp motion. Velocity units depend on the current motion control settings.
Parameter 3 --- ACCDT
This is a two-byte value for the time it takes to increase/decrease the velocity by one unit. This parameter is also known as the "accleration step time". The time units are in milliseconds.
Parameter 4 --- RMPFLAG
The first byte of this two-byte parameter is a reflex control value. The most significant bit is an enable flag. The seven least significant bits are a reflex ID. When the enable bit is set, the ramp motion triggers a reflex with the given ID when the motion is completed.
The second byte of this two-byte parameter contains ramp control flag bits. Bit 0 may be used to enable velocity damping. Bit 1 may be used to synchronize identical or complementary ramp motions. Bit 2 may be used to find the error in the ramp motion. When bit 2 is set and a trapezoidal motion is completed, the error between the desired distance and actual distance traveled will be written back to the RANGEH, RANGEL parameters. Bit 3 may be used to enable a final "nudge" step in a trapezoidal ramp motion. There is usually some error when performing a trapezoidal ramp motion. The nudge drives the motor at minimum speed to push the motor as close as possible to the desired position. The time it takes to perform a nudge depends on the physical system and the PID velocity control parameters. When Bit 4 is set, disabling a trapezoidal ramp motion for a channel will automatically switch that channel to velocity damping mode. Then a user may control the motor's speed by changing the MAXV setting. This is useful when a robot detects an obstacle during a ramp motion and must make a gradual stop.
The most significant 3 bits define a postscaler. The postscaler is multiplied by the current ramp setpoint and becomes the new setpoint. A postscaler is useful when valid setpoints can have a wide range and the normal ramping delay is too slow to get a desired response. For example, suppose the valid setpoint range for a user's system ranges from 0 to 32000 and the user wants to perform a gradual velocity ramp from 0 to 32000. With the minimum ramp delay of 1ms, this will take 32 seconds. To get a quicker response, the user can select a postscaler of 32. Then the velocity will ramp up to 32000 by increments of 32. This will take 1 second. When using a postscaler, the ramp velocity must be scaled down by the user. For this example, the user would specify a maximum target velocity of 1000 to make the system ramp up from 0 to 32000.
|0||0=trapezoidal ramp, 1=velocity damping|
|1||0=ramps independent, 1=ramps synchronized|
|2||0=RANGE not altered, 1=RANGE reset to error when done|
|3||0=nudge off, 1=nudge enabled|
|4||0=normal, 1=transition to velocity damping mode when ramp disabled|
|7:5|| 3-bit velocity postscaler|
000 - none
001 - velocity * 2
010 - velocity * 4
011 - velocity * 8
100 - velocity * 16
101 - velocity * 32
110 - velocity * 64
111 - velocity * 128
The feature associated with Bit 4 was added in Moto 1.0 Firmware Build 5.
Velocity damping makes changes in the velocity take place one unit at a time. The acceleration step time determines how quickly the velocity changes. For example, if the current MAXV is 30 and a new MAXV of 50 is entered, the velocity will step through 20 increments (31, 32, 33, etc.) until it reaches 50. If the ACCDT parameter is 20ms, it will take 0.4 seconds for the velocity to reach its new setting. This feature is useful when rapid changes in velocity might cause undesirable effects, such as excessive current surges or physical instability (robot flipping over).
A trapezoidal ramp increases motor velocity at a constant acceleration rate, then holds the velocity at a maximum setting, then decreases the velocity at the same acceleration rate to bring the motor to a stop. This makes the position vary smoothly over time. Since the acceleration is known, it is possible to determine the moment when to start slowing down in order to reach a desired position.
The Moto board ramp algorithm records the distance traveled when the maximum velocity is obtained. This is the deceleration offset distance. When that much distance remains until the target range is met, the ramp algorithm begins the deceleration phase of the motion. If the ramp motion reaches the halfway point before reaching the maximum velocity, the deceleration phase begins immediately.
For best results, the ramp accleration step time parameter, ACCDT, should be significantly larger than the PID period. As a rule-of-thumb, try an ACCDT parameter of at least 10 times the PID period. This gives the PID loop several iterations to settle at a velocity before the ramp algorithm assigns a new setpoint.
Ramp Error and Nudge
The ramp motion will have some error because of the implementation of the ramp algorithm. The speed will not be truly linear during the acceleration phase. This will introduce some error in the deceleration offset distance. When cruising at the maximum velocity, the distance traveled is sampled every millisecond so it is not possible to start decelerating at the exact moment when the deceleration offset distance is reached. Furthermore, the speed will not be truly linear during the deceleration phase. The end result of all these errors is usually a small undershoot when trying to travel a desired range with a ramp motion. When the "nudge" feature is enabled, it can greatly reduce this error. Since the nudge is performed at minimum velocity, a ramp motion with nudge may take a significant amount of extra time.
Trapezoidal Ramp Synchronization
In a two-wheel drive robot, both wheels must change speeds at the same time in order to go straight or perform a rotation. In the Moto 1.0 module, setting the synchronization bit for both channels forces the wheels to change speeds at the same time. Setting the bit for only one channel has no effect. When synchronizing ramp motions, the absolute values of the maximum velocity settings and absolute values for the range settings for both channels must be identical. When the signs are the same, the robot will go straight forward or backward. When the signs differ, the robot will perform a rotation. The acceleration step times must also be the same. If these conditions do not apply, synchronizing ramp motions will have unexpected results.
There may still be some error in the distances traveled by both motors when using ramp synchronization. The ramp synchronization algorithm only affects the velocity setpoints. Actual velocities for each motor will always differ slightly. The ramp synchronization only ensures that the motor velocity settings will change at the same time.
A trapezoidal ramp motion can trigger a reflex when it finishes. If the nudge feature is enabled, the reflex is issued after the nudge finishes. If the nudge is not enabled, the reflex is issued after the deceleration stage of the motion is completed.
The main use for the ramp reflex is to allow a TEA program to perform an automatic delay until a ramp motion is finished. A TEA program can start a ramp motion then wait for its semaphore to be written. If the ramp reflex writes to the semaphore, then the TEA program will continue. When controlling synchronized ramps, both ramp motions will finish at nearly the same time. In this case, it is sufficient to enable the ramp reflex for only one channel. Then the single reflex will indicate when the dual ramp motions are done.