next up previous contents
Next: Efficient Implementation Up: Stepper Motor Control Previous: Displacement   Contents

Steering

Given $D_{L}$ as the linear distance to travel and $D_{a}$ as the angular displacement to travel, we can apply the previous algorithm independently to determine the acceleration. With the independent accelerations, $v_{L}$ and $v_{a}$ can be computed.

We then combine $v_{L}$ and $v_{a}$ to compute the actual velocity for the right motor and the left motor. In other words, each motor does not really have its own acceleration.

Note that for the angular displacement, we also need to take the sign into consideration. The modified code to handle signed quantities is as follows:


\begin{algorithmic}
\STATE set $r = sign(v) \times \frac{v^{2}}{2 \times a_{max...
... $c_{a} = c_{a} + f_{base}$
\STATE $v = v + sign(a)$
\ENDIF
\end{algorithmic}

The previous code should be replicated so we end up with one for linear distance and one for angular distance. Then we combine the two and control the stepper motors. The following is the code for the left motor. Code for the right motor is almost the same, except the change $v_{l}+v_{a}$ to $v_{l}-v_{a}$.


\begin{algorithmic}
\STATE $c_{ml} = c_{ml} + v_{l} + v_{a}$
\IF{$c_{ml} \geq ...
...c_{ml} = c_{ml} + f_{base}$
\STATE one step backward
\ENDIF
\end{algorithmic}



Tak Auyeung 2003-09-29