Headlight auto leveler

Am a complete novice here, so any advice greatfully recieved.
What I want to do is fit headlight auto leveling to a vehicle, sounds simple, well it's a 4x4 so random bits of potentiometers and mechanical links dangling below don't appeal.
Thinking outside my comfort zone and doing some research I came across the Arduino and ultrasonic distance sensor.
So the question is would it be practicle and / or possible to use an Arduino to read the output of a pair of these ultrasonic sensors to determin the vehicle pitch angle relative to the road surface and automatically adjust the headlight level acordingly?
Obviously the Arduino would have to be satndalone once programmed.
The reason for this project is that HID headlights legally require to be automatically self leveled. It does not require to adjust with any great speed, and as a minimum it must adjust at the start of a trip to take acount of the vehicle load, although dynamic leveling would be nice.

Any thoughts?

Regards

Simon

Wouldn't a tilt sensor make more sense?

Already thought about both tilt sensors and even remote control gyro pitch controls but the problem with that approach is that as roads are rarely horizontal, hence the need to control relative to vehicle pitch.

Weird. I would have thought car markers considered that. Guess you're right.

As I understand what car makers are doing is to take account of velocity pitsh, aceleration and a few other variable to come up with a solution but all seem to rely on a mechanical link to the suspension,
This even to date is not an option for a land rover defender, so I can't retro fit anything.

The article I linked to clearly says automakers use a tilt sensor. That article references articles from Audi, BMW, NHTSA, and a researcher. I'm guessing one of those will backup the claim that in order to determine the car's tilt, they use a tilt sensor.

Indeed, but for my ends this would be overly complicated.
All I am looking for is an expedient way to fit HID headlights and stay legal,
Without adding mechanical componants to the vunerable underside of the vehicle, where they may well get squashed or ripped off

Damn, you got me again.

It is always really complicated to use the right components for a job. Somehow I didn't make the connection that when you want to detect tilt, it was more complicated to use a "tilt sensor" than to use a "distance sensor [ultrasonic sensor]". My bad.

Makes total sense now. Sorry again.

I think that ultimately you need to measure front and rear ride height, and the easiest and most practical way to do that is with a potentiometer connected to the suspension linkages. There are lots of ways to do this but a 'string pot' is the easiest to make - essentially, a potentiometer that is operated by a string. Connect the potentiometer to a fixed part of the vehicle, tie the string to a moving part of the suspension and you have a ride height sensor. You will need to calibrate each sensor to work out how to calculate the ride height from the sensor value - and the front and rear sensors will need to be calibrated separately since they will have different characteristics.

Once you have got the front and rear ride heights you can compare these against the 'at rest' values to get the front and rear deflection and subtract these and divide by the wheel base to get the pitch change. Presumably you'd use that to steer the headlamps up or down to counteract the pitch.

As I said initially, I don't want to use any form of mechanical link to the suspension.
Sure if it were a road only car then that would be fine, but it is not. I play off road as the vehicle was designed to do, which is a little tough and unforgiving.
Back to the original question...
Can an Arduino work standalone once programmed as a permanant fit in a vehicle, and use a pair of distance sensors to control the headlights.
I really don't consider ANY form of mechanical device suitable for my application.
Only looking to use "non contact" type sensors.

si67:
Can an Arduino work standalone once programmed as a permanant fit in a vehicle, and use a pair of distance sensors

Yes.

si67:
to control the headlights.

Not without a Servo.

Good luck.

Excellent,
The servos arn't a huge problem.

si67:
Already thought about both tilt sensors and even remote control gyro pitch controls but the problem with that approach is that as roads are rarely horizontal, hence the need to control relative to vehicle pitch.

You can do this with a 3 axis accelerometer. Detect bumps in the road which, assuming the car is not accelerating or decelerating, will always occur along the current normal. So you're looking for high frequency changes in acceleration and finding out what vector they occur in.

Car manufacturers handle this problem. Aside from an accelerometer there's only a few ways to do it: using mechanical means with the suspension, or comparing the pressure in the front and rear suspension, or using ultrasonic distance sensors under the front and rear of the vehicle. None of those methods would be as inexpensive or reliable as an accelerometer.

I still wouldn't do this without some kind of manual override, notably just stick a potentiometer on your dashboard so you can fine tune the level and/or a button to trigger it to readjust when you are on a level surface.

si67:
As I said initially, I don't want to use any form of mechanical link to the suspension.
Sure if it were a road only car then that would be fine, but it is not. I play off road as the vehicle was designed to do, which is a little tough and unforgiving.

I really don't consider ANY form of mechanical device suitable for my application.
Only looking to use "non contact" type sensors.

I don't know why you think that - it seems to work OK for Land Rover. You can make mechanical devices rugged if you need to - this stuff doesn't need to be down in the sticks and mud. Trying to use remote sensing techniques or inertial techniques to determine the vehicle pitch I regard as difficult at the best of times and futile in the sort of dirty and dynamic environment you're describing.

www.yashu.com

http://www.yashu.com/VIM2_Specs_v1a.pdf