# Accelerometer controlling 2 servos

Good Evening Everyone,

What I am trying to do is use an accelerometer (http://www.sparkfun.com/commerce/product_info.php?products_id=847) to control two seperate servos (http://www.servocity.com/html/s3003_servo_standard.html), I was thinking I would use this microcontroller (http://www.sparkfun.com/commerce/product_info.php?products_id=666). (Are these all compatible?)

The idea is balance a platform in a dynamic equilibrium with the two servos, as on if it rotates clockwise (0 to 90 degrees) in the x axis, it would move servo a in the positive direction, and servo b in the negative direction.

likewise on the same x axis if the platform rotated counterclockwise, servo a would move in the negative direction, and servo b would move in the positive direction.

Also there will be movement in the y axis(0 to 90 degrees). In a manner such that if the board starts to rotate forward servos a AND b will both move in the positive direction, and if it starts to rotate backward, servos a AND b will both move in the negative direction.

Will the microcontrolled be able to accept those signals and send out the proper balance to each servo? (As in there will movement in x and y axis at the same time, which will mean each servo has two inputs)

For example if movement in the x axis tells servo a to rotate 30degrees clockwise, but movement in the y axis tells it to move 15 degrees counterclockwise, will the end result be a rotation of 15 degrees clockwise like I need it to be?

Hope this can be understood.

## Comment viewing options

sld be ok, but i tink instead of having 2 inputs for 1 servo, u can try combining the 2 values (value = Servo1 + Servo2) and sent out the result to the servo. Of course, this is not fool proof, u'll need to make sure it stay within the min and max range.

My experience with the parallax accelerometer was that these devices are very sensitive, so if connected to the servos, it might result in jittering.

Thank you thats a good idea, as for the accelerometer, as an optional replacement I was looking at this one http://www.dimensionengineering.com/DE-ACCM6G.htm, have you had any experience with it/will it still work in conjunction with the microcontroller?

It depends on how much resolution you require. for tilt sensing, 2 g is more than enough.

the arduino feature a 10 bit ADC, which means the reading will be from 0 to 1024, so the resolution is .0117 g.

the one i used was from parallax, it comes with a 12 bit ADC, so u can just connect it to an digital I/O.

this video uses 2 servos to control the platform

As for sensitivity, very little is required. As the object will rotate up to a max of 90 degrees (through normally will only be around 45) in each direction.

In fact due to how much vibration the object will encounter, I was thinking some sort of delay should be programmed into the microcontroller as to help eliminate jittering. As I am just trying to compensate for excessive roll, not tiny vibrations.

u can try saving the old value and do a comparison with the new value, if it's within +- tolerance, then dun move, else, move servo.

can all this be programmed into the arduino opensource programming that they offer? Which I believe is similar to C?

On a side note would these components be assembled on just a standard pc board like the ones at radioshack. Also, what is a good way to ground out the microcontroller?

I tink it sld be doable, u'll need the servo and analogread functions.

what do you mean by assembled? for the accelerometer from dimension engineering, the component is as shown in the pic.

I'm not really sure about the gounding part. Just connect to the power source??? What power source r u using?

Just assembled as in mechanically attaching the microcontroller and accelerometer to a board, that will then be attached to the platform.

As for power source, would just a standard 9v work with that microcontroller?

Also concerning power the accelerometer I am looking at said "There is no on-board regulation, provided power should be between 1.8 and 3.6VDC." I am assuming the accelerometer will get its power from the microcontroller, but how do you control how much power the microcontroller will supply to the accelerometer?

I don't want to be negitive here but it seems by some of your questions, you might be biting off more than you can chew here. I wish you the best of luck with this project, but you might want to start a bit smaller or break this up into smaller steps. Also, you might want to read some of the data sheets that come with your products.

I say this as a friend... There are a few "rules" around here --People will not react well if you are asking a question that is easily found in a manual. I.e. the fact that the microcontroller board you are looking at has a 3v out or that almost everything connected to anything must share a ground. Also, and this might be a personal pet-peeve, don't ask questions about step 487 when you have not figured out step 1,2 and 3.

I'm not sayin', I'm just sayin'.