Single Axis Auto Level Guidance

I'm new to Arduino and am looking to make a auto levelling system working on a single axis.

The easiest way to describe what I'm trying to achieve is by using a a seesaw / teeter-totter and a glass of water for an example.

I'd like to mount a sensor where the pivot is, then at one end of the seesaw mount a servo controlled platform for the glass that counteracts the movement of the seesaw itself. As the end where the glass is located is raised the servo should pull allowing the glass to remain level, and likewise at the opposite end of the scale as the end is lowered the servo should push again keeping the glass flat.

I have an Arduino Uno, I have a couple of servos already set by for this project as well as a cheap wii nunchuk clone.

I had hoped that I could use the nunchuck to control the levels but now I'm not so sure it's suitable. When the seesaw is level and balanced I'd like to be able to set that as my 0 value, then as weight is added to either side of the pivot I'd like to calculate the angle of that movement and then adjust the servo the equivalent amount in the opposite direction.

With my experiments with the nunchuk thus far I've discovered that the readings on the accelerometers only really change when being moved continuously, if I tilt the nunchuk board and hold it at an angle it seems to stop registering it's tilted.

I don't know where to go from here, do I need a different sensor? Any help that you can offer would be gratefully accepted and aid me in completing my first project.

At the fulcrum point of your balance beam, mount a horizontal bar at right angles to the beam so that it rotates with the beam. Connect the end of the bar to the end of a potentiometer spindle. Use the readings from the potentiometer to tell you what angle the bar, and therefore the beam, is at.

I follow what your saying and where your going with that concept but unfortunately it won't work for my application. The hole seesaw concept was the best example I could think of to explain what I wanted to achieve but may well have confused the issue too.

My goal is to create a levelling system for a car headlight so as I carry more people in the front or back of the car the headlights adjust to maintain their level. I'd like to mount the sensor centrally in the car and have something that won't be affected by road vibrations too much.

Prehaps I should have said that to start with, but I felt it might get trolling comments etc as I've found before on other sites like StackOverflow.

lil_bugga:
I follow what your saying and where your going with that concept but unfortunately it won't work for my application. The hole seesaw concept was the best example I could think of to explain what I wanted to achieve but may well have confused the issue too.

My goal is to create a levelling system for a car headlight so as I carry more people in the front or back of the car the headlights adjust to maintain their level. I'd like to mount the sensor centrally in the car and have something that won't be affected by road vibrations too much.

Prehaps I should have said that to start with, but I felt it might get trolling comments etc as I've found before on other sites like StackOverflow.

Have you thought about mounting the headlights on gimbals?

Henry_Best:
Have you thought about mounting the headlights on gimbals?

Wouldn't work well when you're travelling uphill/downhill.

I don't think what OP is asking is reasonably possible with just an accelerometer -- assuming you take into account scenarios where the car's trip might be mainly uphill or downhill. You could do it with distance sensors between the car's frame and the road, front and back, or you could do it with an accelerometer and a GPS if you take altitude changes into account as the car is moving so you can get a proper baseline for when the car is level.

I think mounting the headlights on a gimbals set up alone would be problematic as bumps in the road could set it wobbling around even if dampened.

My thinking was as stated above to mount a sensor in the middle of the car, then when the car is on level ground with me in the drivers seat set that at the 0/base level, then as weight is added to either front or rear calculate the angle and adjust the lights accordingly.

A distance sensor could work, I did think about ultrasonic sensors before but wasn't sure how they would hold up underneath a car where they are likely to get covered in road spray etc. I also wasn't sure if spray etc would affect the sensor giving false readings.

lil_bugga:
My thinking was as stated above to mount a sensor in the middle of the car

Your car's chassis (regardless of whether it has a full frame or is a unibody) is rigid. If the sensor reads a 3* change in the center of the chassis, it would also see a 3* change at the front of the chassis and at the rear of the chassis. Going back to your see-saw example, the entire see-saw is always at the same angle.

Another option would be to monitor the distance between the vehicle's body and axle (or lower control arm, etc) at the front and the rear of the car. With you in the vehicle (your "baseline"), record the readings front and rear. maybe the front is 8" and the rear is 9". As you add weight to the rear of the vehicle, the rear value will decrease and the front may increase (or remain stable). This would allow you to determine changes in vehicle angle relative to itself (and not the environment around it -- Hills, etc). If going this route, I would recommend monitoring all four corners and average the front two readings and average the rear two readings. The averaging would help reduce (or eliminate) false readings when cornering.

Here is an example of what is frequently used for automatic load leveling with airbags:

And here is an example of them installed:

chipreibel:
Here is an example of what is frequently used for automatic load leveling with airbags:

And here is an example of them installed:

I take it these are essentially just potentiometers in waterproof casing with a cantilever arm and push rod. If that assumption is correct they seem pretty pricey for what they are.

lil_bugga:
I take it these are essentially just potentiometers in waterproof casing with a cantilever arm and push rod. If that assumption is correct they seem pretty pricey for what they are.

These particular versions are indeed very expensive - they were just the first images that I came across to show what I was describing. More "cost effective" versions can be found for sure: ($32 ea) ($20 ea)