Skip to content
Nemo157 edited this page Oct 17, 2011 · 7 revisions

##Differences from other boards

  • The steering board contained a quadrature decoder for use in converting the pulses from the encoder to two input signals on PB23 and PB24. There were 26828 pulses per revolution
  • A motor driver board attached to the top of it for use with the steering motor
  • Two limit switches were attached to its IO ports PB28 and PB29

##Function

This board controlled the servo that was used to steer the kart. The servo had a limit switch at either end to mark the fill extent of its travel, along with a rotary encoder to give its relative position

##Code implemented on the board

###Interrupts The encoder position was updated via an interrupt. The pin PB23 received the clockwise pulses and the pin PB24 received the anticlockwise pulses. When a pulse from PB23 was received an interrupt increased a variable encoder_count by one. When a pulse from PB24 was received this variable was decreased.

The inputs for the clockwise and anticlockwise end of travel limit switches also activated interrupts. These interrupts caused the system to enter an error state and stopped the steering motor as to trigger the limit switch the software controlling it must have malfunctioned. These interrupts were not activated until after the calibration of the encoder had been completed.

The over temperature and other warnings and errors from the motor drive also caused the system to enter this error state.

###Calibration The Encoder used to detect the position of the steering wheel did not give any indication of the absolute position of the wheel. Because of this it had to be initialized at the start. This was done by turning it clockwise until a limit switch was encountered and recording the counts value. The motor was then turned anti-clockwise until the other limit was encountered and the value of the counts was recorded. From here the center position was calculated and the wheel was turned to the center before interrupts were enabled.

###Control The Control of the wheel was set by an interrupt changing the variable steering_loc when a new number was received on the CAN bus. This loctaion was in degrees from center. It was converted to encoder_pulses and a proportional controller was then used to set the PWM wave that was output to drive the motor.

The code for this board can be found in the Steering main file