Zero/Tare accelrometer

I’m working on creating a pitch/roll gauges and would like to zero the gauges out.

My tablet does not sit perfectly vertical where it’s mounted in my Jeep so the pitch angle shown pitched forward.

You might be able to adjust it in gauge math no and subtract the value it’s different by.

I tried subtracting the tilt value, but it limited the range. When I tilt the tablet forward it stops at around 60 degrees. I have the value limited to 90 degrees.

The accelerometer data from the tablet goes from -1 to 1. For pitch, when the tablet is vertical it reads 0 (sitting on the bottom edge). When I tilt the tablet forward it reads plosive numbers till lying flat which equals 1. Than negative numbers rotating backwards. Past lying flat the numbers start going back to 0, 0 being siting on the top edge.

Is there a way of saying x=0? x being the angle the tablet sets.

What value is it so I can try and make an example for you

Accelerometer reads 0.4.

look’N Feel → Special → Gauge Math → V - 1

Replace one with whichever value you want. Make sure you’re on an flat even surface. That’ll adjust the value you see and get it to equal 0° or 90°. I don’t know which of those you want.

From there test it out.

That does not work. It’ll set 0 correct when the tablet is in the mount but once it rotates to about what would be close to a 60 degree decent the gauge starts back towards 0 instead of continuing towards 90. Incline looks like it works ok with this math.

I think the reason this does not work is since the tablet leans forward 0.4 and i subtract that value to “zero” the gauge. Once the tablet is lying flat the accelerometer is reading 1 which the gauge shows 0.6, the accelerometer than starts back down to zero as the tablet continues to rotate forward so it can’t get past 0.6 on the gauge.

I hope that makes sense.

I’m working. So sorry if I lagged have you tried 1 - V, basically flipping the equation around ? You can use +/- if necessary. See if those results help.

Also did you check min and max of the values so they aren’t stopping the value from going past 0.6.

So on my phone Acceleration Z (Raw) is what I used. If I lean the phone back it gives a positive number. Laying down back with screen visible is a +1. Laying it down foward with screen not visible to me is a -1.

So going down hill I should get a positive number and going uphill I should get a negative number.

Does that help?

Edit: From there id setup the tablet, most likely subtract “X” value to “tare” it out. And then while driving it’ll tell me if the car is going up or downhill based on +/-. Is that what you want?

Edit edit: Acceleration X (Raw) would show me if I’m leaning left(-) or right(+).

I think for this to work reliably it would require a ‘reset calibration’ option to RealDash. I can investigate this option.

Easiest option would be to install the device level :grinning:

The current work around I have is using “Acceleration Z(Raw)” and in gauge math using (V - Uv) *90. Uv would be the user value to 0 out the device while on an even surface.

For me it was 0.58.

From there I find the limits by using (1-Uv)*90 and using +/- value of it.

Reason being is that once V = +/- 1 it’ll starting going back to 0.

So if the device was perfectly straight on your setup, then you wouldn’t have an issue. For my tablet, the top is tilted back a bit.

This limits me to my +/-38° if I were to make a pitch gauge.

I hope that helps the original poster. Please let me know if anything, thank you.

Could you help me help verify if this equation is correct? And if so, how would we type that in to realdash?

pitch angle = arcsin(Ax / g)

I wanted to verify the accuracy of pitch and this is what Google showed me for the formula.

I got to finish making a working gauge but I read online the 3 axis accelerometer in devices need a formula to calculate the angle. Just waiting to see if someone can confirm this and how we could input it into the gauge math.

Edit: I don’t know if gauge math could support trigonometric equations or pi


1 Like