Compass Integration

After far too much pain and effort, the magnetic compass is integrated with the robot.  Calibration is a bit finicky, and I don’t think the SYNC signal is implemented properly.  But, the compass works, and the heading matches my mechanical compass.  Here are a few lessons learned:

  1. RTFM.  Set the pin data direction (DDRQS) because inputs don’t work well as outputs and outputs don’t work well as inputs.  The QSPI hardware will halt with “mode faults” if the pin directions are wrong.  Set the PORTQS register to the inactive pin state.  The slave select pins are active low, and don’t forget that when setting the PCS bits in the COMMAND bytes.
  2. RTFM.  The Vector V2Xe compass has a response timeout, and trying to write out a bunch of debug information in the middle of reading the response is ill-advised.  Also, the compass does not respond immediately, so look for the 0xAA synchronization byte.  The compass manual is, unfortunately, vague in a few areas.  The manual mentions the response delay for GetData commands but not for other commands.  Also, the manual does not give full timing specifications (e.g. setup and hold times) for the SPI bus or the SYNC signal.  The manual doesn’t say if the slave select may temporarily go inactive in the middle of a command or response.

I’m busy tweaking navigation and obstacle avoidance behaviors.  The Sharp IR range finders give false positive readings when moving into the sun, so the ‘bot can develop heliophobia.  I just finished implementing a simple low-pass filter for the IR ranges, and I’ll see if performance improves.  I’m considering the addition of tactile bumper — the IR filtering and the elevated sonar (to avoid ground reflections) make the robot blind to short obstacles.

I’m ready for the AVC.  Are you?