December 23, 2008

in Projects

Playing around with gravity:


A basic piece exploring interaction with gravity. It is (again) half a ping pong ball. On the rim there is a red dot, which always stays up. You can turn it as you want – the red dot will go up again. Video after the click.

It is much easier to see it in real:

Basically it is a very small “physics engine” which tries to hold the dot up. Which side is up is determined by an accelerometer. The measured gravity creates a force which drags on the dot and by that it is always dragged upwards. By applying the right force you can even try to toss the dot in circles.‚ The whole project does nothing real useful – but using accelerometers is a nice way to interact with electronics objects

The internal construction consists of 12 Micro SideLeds (simliar to but completely independent of the Led Lighthouse), arranged in a circular shape, connected to an ATmega168 controller. There was nothing fancy used like charlieplexing the LEDs. The ATmega168AU has enough pins and a extremely small form factor. An ADXL322 is used as accelerometer:


The whole project was done again using only SMT parts. Mostly due to availability (e.g ADXL322), size (e.g. getting a whole ATmega168 in an ping pong ball) or aesthetics:


The source code can be found in the Gravitron source archive. Perhaps it can help you with anything – perhaps not. Hopefully it does not hurt anybody or destroy anything. If it does – I am not responsible.

{ 15 comments… read them below or add one }

Alex December 23, 2008 at 18:11

Cool! Great piece of work.
How hard was the soldering?


Marcus December 23, 2008 at 18:16

Soldering this stuff was no fun at all. I tried to hand solder it. But after one completely wrecked PCB I just bought an hot air rework station. I can recommend it to anybody. It was cheap (~100€) and now I am not afraid of any smt package anymore!
With my new hot air station it was a cake walk!


Andy December 24, 2008 at 10:58

What happens when the device is completely flat? I’m wondering if the device could be used to ensure workshop equiment like lathes and milling machines.


DTL December 24, 2008 at 15:07

Great project!
Where did you get the cheap rework station from? Sounds ideal for some of my projects.


Ed December 25, 2008 at 15:52

Very neat and clean layout on the pc board. Hand soldering SMT parts is a challenge. If you have a good magnifying scope and a pair of small, low wattage irons, it’s much easier. I’ve been doing it for a long time now…


angus December 25, 2008 at 21:28

WOW what a simple, but fun little project! ……wear can i get the code?….or are you not sharing that?


Marcus December 28, 2008 at 13:42

To answer some of your questions:

If the device lays flat gravity is still dragging in one direction (it is specifie in the ADXL data sheet) but the force of the acceleration 0. Or to put it more mathematically: The acceleration vector is (0,0).

It can of course be used for many other purposes. You probably have to change the source, e.g. to be more precise or to show the direction of gravity rather than implementing some ‘gravity concept’. If you want to try new implementations aks me – I can try o give you an gravitron.

The PCB was designed using the freeware version of CADsoft Eagle. It got an option for rounded traces – and edged traces looked so ugly on a round shape.

The rework station I use is the same as sold over at sparkfun. But I found it at half the price on ebay.


Erwin Zwolle December 29, 2008 at 11:23

Very cool implementation,
seems like a thingy you can’t keep your hands off…
As soon as I’ve got some time, I’ll give it a shot and try to make one myself.

Nice pbc design, who produced the board? If possible, to you have some code snippets for the g-vector calculation?



Marcus December 29, 2008 at 13:57

The PCB was manufactured by BatchPCB. The only ones I found doing custom outlines in small quantities.

You can use the source code if you like. The g-vector calculation was the output of the accelerator (converted into polar coordinates, deriving an accelerating force, orthogonal to the line between the lighted dot and the middle of the ball – and such stuff ;) ).


Martin December 3, 2009 at 13:11

Do you think it can be used for auto-balancing a model “multi-copter”? maybe using relays instead of LEDs to disconnect and reconnect power to motors? Outputs would have to adjusted – surely negated – for example if I have 8 motors (with propellers), all would be running and in case it inclines to one side, those at that side would be disconnected for the moment. Not sure if explained clearly…


Marcus December 3, 2009 at 14:43

I think I know what you mean.
It can definitively be done. But doing a dedicated PCB would be a easier way. But nonetheless it is possible.
The only thing is that the accelerometer only measure gravity or acceleration (which is the same) So if you start to move the copter You get additional acceleration to gravity. You cannot distinguish between those two. That is the reason why you additionally find gyrometers in real copter applications (they stay in the same orientation no matter how you move the object containing it. Unfortunately they tend to drift. If you combine acceleration & gyro values you get a quite good idea about acceleration & position) – but that’s a whole different story ;)


greeeg January 22, 2010 at 17:59

very nice project, have you thought about implementing PWM on the LEDs so they could fade into one another making it appear smother?

also have you thought about making your PCB designs public on BatchPCB? so that others could make your projects? (or at least have a try at soldering those tiny SMD parts)


Marcus January 22, 2010 at 20:39

Doing PWM is totally possible. The current calculation is done in floating point – so there is not very much CPU time left to do this PWM – but there is no reason to not change this.

Regarding the PCB: I still have some PCBs left. I am able to provide you a complete kit (even in different colours – except white and blue). So If you are interested in this just drop me note. I will sell them until they are gone as complete kits. But be aware: soldering the ADXL is not possible without an hot air reflow station or an toaster oven or skillet, or something similar.


Matiss February 21, 2011 at 21:36

You could make a rolling dice out of this project. The dice could even be thrown.


Marcus February 21, 2011 at 22:20

Nope ;)

I do not think that I will revisit this project to create a dice. But if you are interested I can give you a board (even with some parts already assembled) and you can create it.
You can create what you want with my designs. And the funnier the merrier I am ;)


Leave a Comment

{ 2 trackbacks }