Accelerometer controlling two servos

Good Morning Everyone,

What I am trying to do is use an accelerometer (sparkfun.com/commerce/product_info.php?products_id=847) to control two seperate servos (servocity.com/html/s3003_servo_standard.html), I was thinking I would use this microcontroller (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.

thanks for the response, can I ask why the 3 axis tilt would be better? As the platform will only lean forward and backward (axis 1), as well as left and right (axis 2). Im new to mems so just trying to get as much knowledge as I can before I start investing money.

Thanks again

Thank you that does make sense.

Do you know where I can find examples of wiring schematics for my project (accelerometer => microcontroller => two servos)

Also in wiring these together are there any hidden dangers, (ie. random capacitors or what gage of wire is best to use)

Can these just be assembled on a standard pc board (from radioshack), and how do you take care of grounding the components?

thank you

thanks for the help fellas, here is a schematic I came up with. As you can tell my electrical sense is not the best. If anybody can take a look over it and point out any mistakes or improvements. I would really appreciate it.

Here are the components involved

Microcontroller

sparkfun.com/commerce/product_info.php?products_id=666

Accelerometer

sparkfun.com/commerce/product_info.php?products_id=9269

Servos

www3.towerhobbies.com/cgi-bin/wti0001p?&I=LXH288&P=ML

And here is the schematic
img706.imageshack.us/i/schematic.png/
http://img706.imageshack.us/img706/617/schematic.png

Great! thanks Casmat, also my reasoning for running the separate voltage regulators was because I am under the impression that while the board can supply the voltage it can only put out around 50mA, while the servos may need up to 300-400mA, and therefore may not function properly if running directly from the board.

Also thanks for finding those parts for me, you guys have earned my business.

Hey fellas, another quick question regarding wiring connections…

I understand how to supply power to all the components when using a breakboard, but what is the best way to do this on a final project? Is there some sort of “splitter” to divide the power wire up, or run multiple wires from a single wire???

Thanks Again

You can always simply splice the wires to make your custom harness:

instructables.com/id/Master-a-perfect-inline-wire-splice-everytime/

In order to accurately measure the roll and pitch of your platform you will require a triple axes accelerometer. A good candidate would be the the Seeedstudio Triple Axis ±3g Accelerometer.

Two standard servos as the ones you chose would also be appropriate: Futaba Standard Servo.

Finally, the Arduino should be able to handle all the signals and respond quickly enough in order to keep the servos refreshed. Given it is programmed properly.

Good luck with your project!

Accelerometers measure acceleration. In order to sens if your platform is tilted, you need to measure the gravitational acceleration.

In order to determine the pitch and roll, you need to measure the all the components of the gravitational acceleration (let’s call it g).

g is a vector and it is characterized by its three spatial components (along the X, Y and Z axis). When the platform is perfectly horizontal, we can assume that g will have a 9.8 m/s^2 magnitude in the Z axis, 0 m/s^2 in the X axis, and 0 m/s^2 in the Y axis.

When you tilt the platform g will be perceived in all tree axis with different magnitudes depending on its orientation. The magnitude along each axis (Lest call them g_x, g_y and g_z) will be the orthogonal projection of g along each one of them. Here you can find more information on vectors.

I hope the rationale for a triple axis accelerometer is clearer but I would be happy to elaborate more.

In order to simplify the wiring, you could opt for a microcontroller with connections for servos. A good example would be the Arduino-compatible Romeo. This way you can connect your servo motors directly to the board without any hassles.

Also, the accelerometer previously suggested comes with male headers that should fit in the microcontroller’s female headers. You can always get jumper wires that will help you out with your connections.

With these components you will not need another perfboard or breadbaord unless you would like to add further parts.

You selection of hardware seems correct. Also, your connections diagram is appropriate but you need to keep in mind that the voltage regulators and capacitors are all built into the microcontroller. Furthermore, make sure that if you add extra capacitors to the power supply, they have to go from the power signal to ground (if they are intended for noise filtering).

Also, for you convenience, you can buy all these items at RobotShop instead of going hunting around different websites and manufacturers :slight_smile: :

]Arduino Duemilanove/:m]
]SFE ±3g Triple Axis Accelerometer/:m]
]Futaba S3004/:m]

You can power a few servos from the Arduino 5V voltage regulator (only if the Arduino is powered externally and not only by the USB cable). Nevertheless, you cannot power them trough logic signals, the current involved would exceed by far the microcontroller’s output capabilities.

If you need extra power, you will indeed need to use an external power supply for the servos (6 V max).

This is why, in order to reduce the hassle and the part count, I initially suggested using the Romeo, which can handle servos directly and has provision for external power supply. The romeo is basically an Arduino compatible board with built-in motor controllers and extra headers for servos and other applications.

I’m not sure of what you are willing to connect but the best way of making simple connections (without soldering and using heat shrink tubbing) would be to use a cleanly wired breadboard. An inexpensive set of jumper wires would do the trick.