accelerometers and gyroscope to control arm?

Hello all. How can I use accelerometers to keep a robot’s arm parallel to the ground? My initial thought process was to use the accelerometers to measure acceleration due to gravity, and if it felt any, then make the motors move the arm the opposite way. Does this seem about right? And can this be done with one accelerometer? Thanks in advance!

Yes, this can be done, but you need to use a dual-axis accelerometer. The best mounting orientation is with the x and y axis at a fourty-five degree angle relative to the gravity vector (this is because the maximum rate of change of the accelerometer outputs is at this angle). Also, have a look at the atan2() function.

-Kevin

Have you considered using a potentiometer instead? You could mount one on the pivot point on your arm, and use a PID loop to get it to be level by default. I would think this would be easier and more accurate than an accelerometer.

I’m not sure if it’s easier or more accurate, but I do know the accelerometer is a cooler solution :D.

-Kevin

We have been trying to mount a pot on the arm for a long time, and are finding it nearly impossible. I think we are going to have to go with the potentiometer though, after just realizing that the accelerometer is going to measure the acceleration of the entire robot also, if I set it up this way.:frowning:

It’s more work, but you could use another accelerometer pair mounted perpendicular to the gravity vector to measure the 'bots acceleration due to movement and then use this information to correct the arms position.

-Kevin

If you can’t mount a potentiometer on the actual rotation point on the arm there are other solutions. One would be mounting a shaft encoder somewhere else, and running a cable from it to the arm. As the arm moves, it will pull the cable and turn the encoder (essentially a spool or an inverse winch). You can then translate the rotations of the encoder into distance travelled into rotations of the arm.

Where can we get one of these encoders? Can’t encoders only measure distance traveled, or can they measure direction also?

Quadrature shaft encoders can measure direction as well as distance. There are many suppliers for shaft encoders, pretty much any large electronics supplier will carry them, as well as some specialty companies.

Hey,

I suggest using an accel & gyro so as to correct for the linear acceleration. Kinda like we did on the DIY Segway (The DIY Segway)… You can even view our code.

Then again it might not work as well for this.

It’s like as Kevin suggested:

It’s more work, but you could use another accelerometer pair mounted perpendicular to the gravity vector to measure the 'bots acceleration due to movement and then use this information to correct the arms position.

-Kevin

But since they don’t give you two accelerometers, and they do give you 1 accel & 1 gyro… it’s more KOP-compatible.

Although if anybody has an extra gyro, we need one, ours is broken and we want to use it. Just a heads up, as we’ve already posted in CD-swap. We can probably trade our accel for your gyro if you wanna do the 2-accel method.

Why not use an absolute or even an incremental encoder to monitor the position of the arm? Actually, the potentiometer might be the simplest idea, but since I didn’t see anything about an eoncoder…decided to mention it. On the other hand, if you’re using ferrous metal gears on your arm you could use the GTSs too!