accelerometer question???

Instead of using a gyro to measure deg/sec can i do this with an accelerometer?

this is my accelerometer: Dual Axis Accelerometer Breakout Board - ADXL321 +/-18g - SEN-00848 - SparkFun Electronics

Thank you,
Casey Gross

No. It's possible to do a one g barrel roll from a climb. What would a gyro show? What would an accelerometer show?

Under what circumstances are you trying to measure rotation?

im building a balancing robot. I need help with the PID controller.

Okay. I'm not an expert, but that is only a 2-axis accelerometer.

Would it be acceptable to do something simpler, or have you got other sensors too, or is it all or nothing?
I don't think you can get enough information from a 2-axis accelerometer alone to build a balancing robot.

Could try to turn the balancing robot problem into an inverted balancing pendulum problem, i.e. fix the axle, and try to keep it balanced in a plane?

With the two accelerometer axis orthogonal to the axle, and well away from the axis of rotation, it should give readings which resolve the changes of forces.

I don't think that will be a trivial calculation.

As a freely moving robot falls, complex things may be happening. If the robot is moving freely, and there are no other sensors, the forward or reverse motion of the robot itself will add an extra dimension to the calculations, which may be make it too complex. That's why I suggest an inverted balancing pendulum, the forces will be more predictable.

The ideal may be an axle on a freely sliding 'train', free to move on a straight track (unpowered, just free to move) then the rotation will exert a force to move the train, and the accelerometer readings will look close to free fall.

I think that is a pretty poor accelerometer for any of these jobs. According to the spec sheet, it is +/-18g full scale. When it is falling, it is at 0g, and presumably the robot is only able to correct the fall at a couple of g, so it isn't a good fit by a factor of, maybe, 4-6x.

Further, its sensitivity is about 57mV/g, which is approximately 11 steps of the Arduino's analogue to digital converter (ADC). So it's worth considering amplifying the signal. That should be done carefully, as the device will have noise.
[edit]The point here is, when it is just starting to fall, the change of forces on the two axis will be small, and hence hard to see. They may be well below the resolution of the ADC. The displacement would be detected later when it gets bigger. That would mean the motor has to correct for bigger displacements. Without amplification, the effect of the correction may be a change in forces too small to detect and correct quickly enough. The system may be hard to get stable, or to characterise so that it is feasible to get stable in the time available.[/edit]

The last thing I can think of, which I haven't thought of before, is the noise. For this sensor noise is related to have fast the 'robot' oscillates correcting itself. Put another way, as the robot tries to correct itself faster and faster, the response of the device changes, and the noise increase. Not insurmountable, but an added complication.

Summary. I think an inverted balancing pendulum, fixed on a single axle of rotation, may be doable, but it'll need, carefully considered, amplify of the sensor signal if you want to use it with an Arduino.

You could do some simple tests by putting the accelerometer on a pendulum on an axle, so it only swings in one plane, and measuring it as it swings freely. That may be enough to get a first cut signal amplifier.
[edit]If you access to a good quality storage oscilloscope, you might get good data without any amplification, or even an Arduino. A similar setup with a motor added may be enough to establish the range of sensor values, and motor performance.
A good solution, if you are an EE with analogue experience, may be to solve, at least, the sensor side of the problem using analogue electronics, which, I think, could do the calculation in sub-microseconds (depending on the op amps etc.) for a few $'s, but I'm not knowledgeable enough to explain how (I'd use "The Art of Electronics" by Horowitz & Hill). [/edit]

HEALTH WARNING - I've thought about this problem before a bit, but I have always come at it from the point of plenty of data, including a gyro, sensors that are a good fit, and good drive system. It's been a hobby project, with unlimited time, but with fun and learning much of the focus. This may be too far from your situation to be helpful.

Having said all that, you have got further than me, so have at it, and good luck :slight_smile:

HTH
GB

I've had a bath. The tiles make a nice "thinking surface".
I am not confident that I can think of a solution without more sensors.

I believe the math for making a gyro, for 2 axis rotation has eluded me. I'm no maths genius, but that tells me it is more 'non trivial' than I had at first thought.

First problem is as the accelerometer rotates, the axis rotate, and so the initial 'pendulum' thought, which is the high-school physics simplification, doesn't work in general. A problem is the relationship between x and y changes, and that needs to be factored in. When the only force is gravity and a rigid pendulum, I think this can be done, but ...

It gets worse. Anything physical, which this is attached to, will have inertia. So that will need to be characterised so that it can be factored in. Think of this as second force, modulating the force of gravity.

Where it gets hard for me is the 'balancing' part. This introduces a second, dynamic force which needs to be measured and modeled in order to compensate, and get to a gyro reading.

I haven't been able to think of any solution which even sounds plausible without another piece of data. For example, if it is a rigid pendulum, knowing the angle of the pendulum wrt. the vertical allows the components of the force of gravity to be resolved. If the speed of rotation were known, the problem is, I think, soluble.

Now, it may be possible to characterise the system so well using other sensors, that a model can be built, and that model can be used at 'run time' and so it can be made to balance. But, in a way, that is cheating. It isn't converting an accelerometer to a gyro, it is a different problem, which is getting something to balance using accelerometers.

Anyway, I think this all leads to the conclusion that I don't know to make a gyro using an accelerometer, and I could only do a balancing robot with more sensors, either used ahead of time to build a model, or within the active system.

Sorry about that
GB

yes, i do have a gyro this one to be exact:

The biggest problem i ran into is combining the two.
I need to use a PID controller for the balance.
Any ideas?

I need to use a PID controller for the balance.
Any ideas?

I don't understand what it is you're asking.

PID control is explained on the web.
A 2 axis accelerometer, and gyro should provide enough information.
There are a bunch of balancing robots, with some explanation of the models used on the web.

What is it you need?