Thursday, July 2, 2009

Software Design

The software can be broken up into three major sections, timers, PWM signal edge detection, and wheel torque adjustments. In combination these parts are able to accurately read each wheel’s velocity and acceleration and allocate the proper amount of torque to reach and maintain a desired speed while improving traction by reducing wheel slip.

Interrupts and Timers

Due to the relatively slow servo motor maximum speed, encoder signal noise, and difficulties with edge triggered interrupts, we decided it would be sufficient to poll the rotary encoders. Therefore we maintained a counter for each wheel that was incremented in our interrupt every 0.2ms. Placing the counters in the interrupt ensures that the few hundred to roughly two thousands increments were done consistently, and any timing accuracy lost was only during the processing of these counts. For example, during our testing we underestimated the length of time to send data to Hyper Term. Before placing the counters in the interrupt we saw a very large margin of error with our elapsed time measurements as the hyperterm task influenced each increment. After moving the counters to the interrupt we only had one delay per encoder phase instead of a delay for each additional timer increment. This gave much more consistent speed measurements (although we decided to remove Hyper Term functionality all together for the final car).

Detecting Encoder Edges and Recording Data

Due to budget constraints we were forced to use the less expensive and reliably mechanical type encoder instead of the more advanced optical encoders. During our debugging process we noticed that the edges during phase transitions were very inconsistent as the switches would make and break a connection multiple times at each transition. This variability would often continue for around 1ms (see diagram).

No comments:

Post a Comment