Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: cpctc1234 on November 30, 2010, 11:24:44 AM

Title: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: cpctc1234 on November 30, 2010, 11:24:44 AM
Hey guys I'm building a robot that needs to know its orientation based of a starting direction. Like a compass in way that if the robot starts off in the North direction it will always know which direction it started in and finishes in.

I've been looking at a compass module, but I'm worried about EMF interference so I was leaning toward an accelerometer or gyro, but I'm unsure if they can be used to measure orientation.

Do you guys have any idea of what I can use if any of these above? 
Title: Re: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: LunchBox! on December 01, 2010, 12:28:51 AM
couldn't it be done with encoders?

encoders could keep it straight, and you would know how much it turned and could turn it back on track.

Title: Re: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: rbtying on December 01, 2010, 01:21:44 AM
You can use all of them (encoders, accelerometers, compasses, gyros - in order of drift), but you'll need to write a closed control loop.  Take a look at Admin's PID control tutorial.  If you decide to use accelerometers, be aware they have integral drift - correction with a gyro is the best way to avoid it, using a Kalman filter.  Then you'll have an IMU (inertial measurement unit)
Title: Re: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: cpctc1234 on December 02, 2010, 10:15:53 AM
couldn't it be done with encoders?

encoders could keep it straight, and you would know how much it turned and could turn it back on track.



Yeah I thought of using encoders. I was really wanting to use something else because I'm not sure if my wheels will accommodate encoders.
Title: Re: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: cpctc1234 on December 02, 2010, 10:22:07 AM
You can use all of them (encoders, accelerometers, compasses, gyros - in order of drift), but you'll need to write a closed control loop.  Take a look at Admin's PID control tutorial.  If you decide to use accelerometers, be aware they have integral drift - correction with a gyro is the best way to avoid it, using a Kalman filter.  Then you'll have an IMU (inertial measurement unit)

So your saying that in order to accelerometers I would have to predict the error and account for it. So are you saying in your opinion wheel encoders would be best?
Title: Re: Need a direction sensor. Compass, Accelerometer or Gyro?
Post by: rbtying on December 03, 2010, 10:44:22 PM
Encoders are easier.  Arguably, an IMU would be "best", but likely the total error over total runtime will be pretty small, so it's not much different.