# How to measure tilt on a dynamic device?

I'm trying to instrument a vehicle component. I want to measure a component's angle during a drive cycle. The component has a single degree of freedom, it has a fixed axis. I'm trying to figure out an efficient way to measure this. I'm hoping to use Internet of Things (Raspberry Pi / Arduino) technology as appropriate. Without going into details, I must power this thing via battery. I'm assuming the testing will be done during daytime, on asphalt or concrete pavement.

Sensors that seem to offer possibilities:

• Accelerometer (X,Y,Z)
• Electrolytic Tilt Sensor
• Passive InfraRed (PIR) sensor
• Sonic sensor
• Laser Time of Flight

My original thought was to use an accelerometer, attach it to the bottom of the device and analyse the direction of gravity to deduce component's angle. I know this would work on a fixed vehicle, but my situation is anything but fixed. I won't be able to deduce vehicle travel direction. Additionally, my vehicle's speed is not constant. I will be monitoring acceleration (but subtracting out gravity) while I'm looking for other characteristics...

Because of my huge variance in accelerations, I don't think a fluid based Electrolytic Tilt Sensor would work either.

My next thought is to accurately measure the distance from the component to ground. I'd fix the sensor to the movable end of my component, then calibrate distance observed to component angle, while vehicle is at a complete stop. I can monitor distance in real time to deduce component angle relative to the ground.

Scratch passive infrared. I'm pretty sure sunlight will mess that up bad.

Radar is a pretty nice technology, but seems to be oriented to metal, water or humans, and has a very slow response time. Scratch that.

And that leads me to either a sonic distance sensor or Laser Time of Flight sensing. At first glance both methods are cost effective and seem to work in the ranges I'm interested in. But I have no experience here. What I don't know is if on road testing in daylight will affect these devices. Will ambient noise mess things up? What about reflected sunlight?

Does anyone have any experience here with those last two technologies (Sonic Distance or Laser Time of Flight)?

Are there any technologies that offer an alternative method for measuring a component's angle (relative to the ground) in a dynamic, moving vehicle, perhaps something I've missed?

Note: I've done a lot of work using magnetometers and accelerometers (Ugh, remember the Vector Cross Product?) but I've never touched a gyro device. Are there opportunities there?

• Gyros are rate sensors. You have to integrate to get angle, and they drift (and don't have a zero reference). You can combine them with other sensors but then you're looking more like an IMU than a single sensor. – Spehro Pefhany Aug 7 '18 at 22:08
• This brief comment on Inertial Measurement Units is very helpful. Any references? How do you deal with drift? (or just recalibrate between tests?) Many thanks. – zipzit Aug 7 '18 at 22:32
• With a tiltometer – Voltage Spike Aug 7 '18 at 22:57
• I'm grateful for the responses here... all of which point me towards using a gyro. I didn't realize the gyro was readily available on the iphone. My Apple Dev license is paid up so I can actually prove out code (sensor fusion & kalman filter, etc.) without spending a dime. I've got testing folks in a variety of locations. if we can come up with a decent 3D printed enclosure this is a winner. Problem now is: how to pick an accepted answer? All the submits add timely response and / or great value... – zipzit Aug 8 '18 at 1:11

My Ipod 6th gen, and other mobile devices have a Gyro controller (Tilt sensor) which with a suitable app can display X,Y tilt with a 0.1deg resolution fast enough > 10 sps. My iPod has a 2D bubble level application in a Multi-function App.

• I've done a whole lot of work on mobile apps. I've always utilized the accelerometer for angle determination. But if the gyro works as advertised, I can see where this can be helpful. I guess I program one up (swift or Flutter/dart) an see if this works on my iphone. I could 3d print a protective box for the phone, attach it and test before committing to the gyro logic. Ultimately I'd rather not use my phone, but that will definitely work for proveout... – zipzit Aug 7 '18 at 22:04
• 6D gyro’s and accelerometers may have limits that I am not familiar with – Tony Stewart EE75 Aug 7 '18 at 23:13

I want to measure a component's angle... The component has a single degree of freedom, it has a fixed axis. I'm trying to figure out an efficient way to measure this.

"This" being what? An angle in vehicle coordinate system or an angle with a horizon? If your component has an axis then a simple potentiometer or encoder can give you an angle between component and vehicle.

My original thought was to use an accelerometer ... and analyse the direction of gravity to deduce component's angle.

OK, let's assume you want an angle with a horizon. Yes, that is what accelerometers often used for. And this is probably your best option.

I won't be able to deduce vehicle travel direction.

Umm... so, what is it you are trying to measure with accelerometer, angle or travel direction? These two are completely different.

If you mean that you won't be able to interpret accelerometer's readings because of vehicle movement then you haven't done your research. By using a combination of 3-d accelerometers, 3-d gyros and sensor fusion algorithm the sensor orientation can be easily calculated with good precision.

• No way to instrument an encoder to the rotation axis. On the angle discussion, (horizon or vehicle coordinate system.) Apologies. In my case the tracking wheel is solid, and there is no suspension. I really want angle to the horizon. The vehicle is traveling at a huge variety of speeds (acceleration is +/0/-) and the travel path is not straight nor is it a regular sinusoid. Perhaps my words "I've never touched a gyro device. Are there opportunities there?" gave you the hint that I haven't done [my] research? Not sure exactly what your recommendation here is. Reference for inertial stuff? – zipzit Aug 7 '18 at 22:29
• I thought my recommendation is clear - use 6-axis gyro/accelerometer combination chip and apply sensor fusion algorithm to its output. (just google for sensor fusion or kalman filter). Alternatively you can use chips made by InvenSense, like MPU-6050 which have built-in DMP. – Maple Aug 7 '18 at 22:46

My first thought, if I understand your application, is an integrated Orientation Sensor. The de-facto is the Bosch Sensortec BNO055. You can find a breakout board on Adafruit, or put it on your own PCB. The sensor has a 3-axis accelerometer, a 3 axis gyroscope, and a 3 axis magnetometer (not super useful in this case). Most importantly, the chip has its own CPU, loaded with a proprietary Sensor Fusion algorithm. In addition to the raw sensor data, the chip outputs Euler Vector and Quaternion orientation data. The chip supports i2c, so you should be able to connect it to most IoT platforms.

The limitations of this approach:

• The Sensor must be mounted on the thing you want to measure. I'm not totally clear on your application, but I'll assume that's possible.
• The Sensor Fusion can only handle so much angular velocity. Again I don't know the details, but if you are trying to measure the angle of a crankshaft or something that's really moving, you will have trouble.

Feel free to add more application details if I've misunderstood.