PDA

View Full Version : Simple up/down inclinometer, any ideas?



Peter Jakacki
05-30-2010, 04:47 PM
One of my current Propeller (what else!) projects requires detecting whether a vehicle is going up or down an incline (immediately) and I thought I would throw this out on the forum for ideas. There are several possibilities but it should be simple and reliable, I don't need to know how much of an incline, just up or down or none. Accelerometers aren't really suitable unless it is reset to a known state but I could be mistaken here. One of my mechanical ideas is to have a simple ball bearing in a V shaped tube with a shallow angle. When the vehicle is level the ball sits in the groove of the V but moving up or down an incline it would move to either end and stay put. The ball could be detected with simple optos or even "RF absorption" sensing by pulsing a pcb contact in proximity with the ends and measuring the rise time through a resistor. This can be manufactured very easily as a simple unit.

There are various specialized ($$+$) and also hard-to-get devices out there but I want to keep it simple. Any ideas?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

BradC
05-30-2010, 05:27 PM
Peter Jakacki said...
When the vehicle is level the ball sits in the groove of the V but moving up or down an incline it would move to either end and stay put.


That was my first idea, and I used to have a car alarm I built that used a similar principle, but acceleration and deceleration will move the ball regardless of the incline of the vehicle.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Are you suggesting coconuts migrate?"

Andrey Demenev
05-30-2010, 05:47 PM
It would depend on ball mass and what minimum detectable inclination is desired

Peter Jakacki
05-30-2010, 07:40 PM
To make it easier I can say that it is a large slow moving vehicle, so this method should work. The V tube could also be pivoted in such a way to lend some mechanical hysteresis but I'd rather keep it simple. Even so, the simple fixed V can be debounced easily enough if you accept the fact that you can't really go from down to up or vice-versa without hovering around level for some small amount of time.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

BradC
05-30-2010, 07:56 PM
I'd use a pendulum on a rotary encoder, or if you want really cheap... a pot.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Are you suggesting coconuts migrate?"

Peter Jakacki
05-30-2010, 08:36 PM
Well a pendulum would work of course but it does not lend itself to being manufactured simply because of the whole swinging nature of it although I won't discount anything completely. So that gets back to refining my definition of what I need which I think needs to be more like a component than a mechanism. The ball in a tube can be quite compact and not prone to any mechanical interference or damage so something like that would be good.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

LarryG
05-30-2010, 09:24 PM
Hi Peter.

I think this is what you are looking for http://www.adafruit.com/index.php?main_page=product_info&cPath=35&products_id=173

Cost about $2 USD.

Peter Jakacki
05-30-2010, 09:43 PM
I suppose I could use two of these tilts sensors in an inverted V on a horizontal PCB or simply arranged on a vertical pcb in a similar format. These tilt sensors are cheap so arranging two of them on a pcb and mounting that at right angles to my vertical pcb which is mounted in the dash should work well. I remember coming across various tilt sensors before but for some reason they were either bulky or expensive. By combining a this with an accelerometer chip I can always have the best of both worlds as the tilt sensors provide that initial absolute reference. As these switches are ball type rather than the old glass mercury bulbs they are intrinsically safe and won't cause a problem with certifications.

Thanks for the link Larry, as this is a "component" that doesn't need any extra work other than the pcb and they are readily available I think I will definitely try this one out.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Timmoore
05-31-2010, 01:00 AM
http://www.junun.org/MarkIII/Info.jsp?item=78 this one is easy to use, you can mount it as normal on a pcb
or this one http://store.fungizmos.com/index.php?main_page=product_info&cPath=66&products_id=215

Erik Friesen
05-31-2010, 01:25 AM
I have a home built car computer that has a pressure sensor (mpx6115 or similar) feeding a 12bit adc. It can very easily sense 5-10 foot elevation change while driving.

Rayman
05-31-2010, 01:31 AM
I don't see why an accelerometer wouldn't work for you...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

hover1
05-31-2010, 02:09 AM
I think the first one would be·unuseable since the data sheet only show 90 degree increments, (car pointing towards the sky or pointing towards the ground.

The second on kicks in at +/- 30 degrees, still that's pretty steep incline.

I would imagine Peter is looking for something like +/- 5 degrees.

Jim


Timmoore said...
http://www.junun.org/MarkIII/Info.jsp?item=78 this one is easy to use, you can mount it as normal on a pcb
or this one http://store.fungizmos.com/index.php?main_page=product_info&cPath=66&products_id=215

hover1
05-31-2010, 02:11 AM
I guess it would depend if you need to measure incline if the car was standing still.

Jim


Erik Friesen said...
I have a home built car computer that has a pressure sensor (mpx6115 or similar) feeding a 12bit adc. It can very easily sense 5-10 foot elevation change while driving.

hover1
05-31-2010, 02:24 AM
I think Brad summed it up "acceleration and deceleration will move the ball regardless of the incline of the vehicle"

My first though was a pendulum also, but a little costly to construct.

Maybe a gyro? That would be set to zero when the vehicle is first started and would not have to be reset during it's run.

Jim




Rayman said...
I don't see why an accelerometer wouldn't work for you...

Rayman
05-31-2010, 03:57 AM
Look, an accelerometer works great as a tilt sensor... That's how the iPhone does it...

Maybe some people aren't aware, but 3-axis accelerometers always tell you which way is down when sitting still.

If you drop your iPhone off a roof, that's when it doesn't know which way is down....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

hover1
05-31-2010, 05:20 AM
@Ray,

So would you have to monitor the Z axis to know that you are actually going up/down? If Z does not change than you are just going forward/backwords/left/right on on plane? Not up on an angle?

"If you drop your iPhone off a roof, that's when it doesn't know which way is down...."

But it knows it's on the way down. That what the "Free Fall" output pin is all about on some a 3-axis accelerometers. Shuts down and locks the hard drives. Used on may Laptops.

Jim

Rayman
05-31-2010, 05:39 AM
It depends on how you mount it, but assuming the tilt is on the Z axis, then you just monitor X and Y to determine the angle...

For example, in a certain orientation and with a non-moving accelerometer, X will read +1 G and Y will read 0 G when vertical. At 90 degrees, X will read 0 G and Y will read +1 G...

So, the square root of the sum of the squares of X, Y, and Z will always read 1 G when it's not moving. That's because it directly reads earth's gravity field...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Peter Jakacki
05-31-2010, 06:02 AM
Thanks for the feedback guys, my head's still a little fuzzy from a cold but I want to nail down this last feature. Rayman, are you saying that an accelerometer can indicate the incline even from a cold start? There can be no "reset switch" to indicate that it's level although that is essentially what the tilt switch would do. It is also true that I would want to detect a shallower angle than 30' and some tilt switches I saw said 15' but after looking at the datasheets I am not so sure they would be all that good. I probably need some hard figures as to the degree of incline but at the moment I am working on around 5 to 15.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Rayman
05-31-2010, 06:18 AM
yes, 3-axis accelerometer tells vertical even from cold start...

Basically, it's just made from 3 paddles that bend by gravity (or actual acceleration).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Peter Jakacki
05-31-2010, 06:30 AM
Ray, I have some MMA7660 chips but haven't had time to play with them. I was worried about being on a little bit of an incline and not being able to trust the readings from it on a cold start. I know that definitely if it was upside down or vertical it would tell me, but a small incline? Do you think? (I know, I know, I should try it myself).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Rayman
05-31-2010, 07:13 AM
Well, I have to say that each chip has it's own slight offset... So, if it's less than say 10 degrees you're interested in, you need to do a per chip calibration....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

ElectricAye
05-31-2010, 07:57 AM
Peter Jakacki said...
...One of my mechanical ideas is to have a simple ball bearing in a V shaped tube with a shallow angle. When the vehicle is level the ball sits in the groove of the V but moving up or down an incline it would move to either end and stay put....


This might be okay for smooth surfaces but if your track is a bit bumpy, you might need to think about what the ball does during vibration. One possible solution (no pun intended), might be to have your V-shaped track immersed in a fluid that might help dampen vibration. Of course, you could punt the ball altogether and just go with a fluid, too, and have optical sensors give a signal when the fluid level (meniscus) passes across their lines of sight.

That's 0.002 cents worth, so remember: if you use that idea, you owe me, man.

Peter Jakacki
05-31-2010, 08:09 AM
Ok, I am mounting a penny onto a lathe to measure and shave off 0.002 cents worth just in case....

I don't think I'd be worried about vibration too much as a bit of sensible and smart debouncing would say whether the signal was "on the level". If at least I keep this part of the design on a plug-in module then I can experiment with various solutions easily without redoing the whole pcb. Maybe I just need a sensor that says it's level to reset the calibration on the accelerometer assuming that this figure will remain relatively stable between operations.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

wjsteele
05-31-2010, 09:00 AM
I agree with Rayman, there is no reason why a 3 axis accelerometer won't work in this situation... If all you need to do is determine some arbitrary angle, then the accelerometer can do that quite easily. The problem comes in if you try to rely on that angle being constant... with an accelerometer, you're going to get a lot of "jitter" from the local movements occuring, so you will need to filter the data (over time) and assume that the maximum load will always be the Earths gravitational pull. From that, you can calculate the approximate angle to within a few degress of accuracy.

BTW, don't always assume 1g = earth either, because the local gravitational field strength will vary depending on your position, so just use the max and you'll be fine, especially if you're not moving very fast. (Remember, a fast movement with an acceleration greater than 9.8ms2 will confuse it, like Ray's example of dropping it.)

Bill

Peter Jakacki
05-31-2010, 09:14 AM
Ok, I'm going to be blond for a moment and act dumb but doesn't an accelerometer measuring changes in g-forces rather than static g-forces. The chip may give you a latched output that says the phone is now upside down but it's only worked that out from the fact that it has experienced a change from being upright. I could just experiment but hey, this is the world's best forum and many of you will have already had experience with this.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

wjsteele
05-31-2010, 09:23 AM
Peter,

Yes, but it will always show an acceleration force due to the natural gravitational tug of Earth. If you were in space, far far away from any other objects, then you will get to a point where they will read zero g's. (Or in a free fall condition, but that is really only theroetical.)

So, yes... and no. http://forums.parallax.com/images/smilies/wink.gif (Gravity is an acceleration force... 9.8ms^2, which is why it detects it.)

Bill

Peter Jakacki
05-31-2010, 09:32 AM
Good, thanks Bill, that confirms what I thought too but whether it would be enough of a force that it could be discernible on a cold start at a shallow incline I'm not certain. Either way though I will use a simple tilt sensor with my accelerometer chip which I had planned to use from the beginning anyway.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

jazzed
05-31-2010, 09:57 AM
The only problem with using an accelerometer would be when they are in the presence of vibration. There are painful filtering techniques for that problem though :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
May the road rise to meet you; may the sun shine on your back.
May you create something useful, even if it's just a hack.

Peter Jakacki
05-31-2010, 10:16 AM
jazz, maybe if I have a sunshine detector I could use that to detect the road "rising" http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

jazzed
05-31-2010, 11:57 AM
Peter Jakacki said...
jazz, maybe if I have a sunshine detector I could use that to detect the road "rising" http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif

Peter, that is actually a form of a blessing although some of the phrasing is a little different from the Irish tradition.




May the road rise to meet you,
May the wind be always at your back.
May the sun shine warm upon your face,
The rains fall soft upon your fields.
And until we meet again,....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
May the road rise to meet you; may the sun shine on your back.
May you create something useful, even if it's just a hack.

HollyMinkowski
05-31-2010, 12:21 PM
The ball rolling in a tube seems kind of clumsy somehow.
Mercury in a tube seems better but also seems TOXIC.
Slightly saline water in a tube might work, and be non-toxic.
If I had to rig from scratch my inclination(lol) would be to
utilize some optical phenomena like hang something reflective
in a small container that when inclined would swing over an LED
that is both pulsing and sensing light, two of these in the container
would tell you the direction of the incline forward/backward
and 4 or perhaps 3 could tell you of tilt in any direction.

Peter Jakacki
05-31-2010, 12:48 PM
jazzed said...

Peter Jakacki said...
jazz, maybe if I have a sunshine detector I could use that to detect the road "rising" http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif http://forums.parallax.com/images/smilies/smile.gif

Peter, that is actually a form of a blessing although some of the phrasing is a little different from the Irish tradition.




May the road rise to meet you,
May the wind be always at your back.
May the sun shine warm upon your face,
The rains fall soft upon your fields.
And until we meet again,....




Yes, I am quite familiar with it, but I couldn't resist answering it as it is talking about the "grade" of the road, just what I was asking about. Hence three smilies.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Beau Schwabe
05-31-2010, 01:09 PM
Peter,

page 1 of the data sheet ... www.parallax.com/Portals/0/Downloads/docs/prod/sens/28017-Memsic2Axis-v2.0.pdf (http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/28017-Memsic2Axis-v2.0.pdf) ... "...both static acceleration (gravity and tilt) and dynamic acceleration
(like taking a ride in a car) can be detected."


Just a thought... if you are in a vehicle, why not monitor the tach. Applying the delta or 'acceleration' from the tach into a simple PID (proportional–integral–derivative) controller where you are also looking at the values from the Memsic2125 accelerometer should negate 'some' of the actual acceleration value leaving you with more of the true tilt value. Monitoring the tach independently on multiple wheels as an additional PID loop can compensate for centrifugal forces by determining the turning radius of the vehicle with respect to acceleration. If your car has ABS, the independent tach information from each wheel may already be available to the central computer.


Another thought... Using two Memsic2125 accelerometers 'fixed' to the same plane will experience the same or similar acceleration values. When the plane is tilted, you see a tilt vector proportional to the magnitude of the tilt that will eventually decay. So mathematically the two accelerometers would provide a result that is basically the differential of the two.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

Peter Jakacki
05-31-2010, 01:33 PM
This is on a slow moving truck and I should mention that I have GPS as well basically to give me my ground speed as I can't tap into the truck's systems. I am incorporating an extra MMA7660 on the pcb but as it has fixed addressing of $98 I will simply swap the clock and data to share two devices on the bus. There may be some flexibility in using multiple accelerometers on the same plane and on different planes perhaps. At least if I allow for it I can collect the data to determine the best method.

Looking at the MEMSIC sensor I see that it's actually based on a heated gas concept so it would perhaps be superior for sensing small static positions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

LarryG
05-31-2010, 08:40 PM
Peter, it can be a bit confusing with the static g vs dynamic. I have been testing a few different accelerometers for my bike computer lately. Here is what I have learned:

1) A basic 2 axis chip works fine, but can find a 3 axis cheaper at times.
2) One of my favorite 2 axis is the Analog Devices ADXL213
3) You typically will be looking for the grade of the road instead of how many degrees of tilt. But it might not matter for your application. (Grade is rise over run, tangent of the angle)
4) There are about 16mg in one degree of tilt
5) Bouncing was not too bad due to rough roads. I take 10 samples then average them.
6) You only need to do the calibration one time. In a 3.3v application, level is going to be pretty close to 1.65v. (Over 1.65v you have a positive grade, below that you are going down hill.) You will need to figure out what margin you want to use for level. For instance, if tilt is one degree either way, then it is basically on level ground. Use a level at the time of mounting the sensor. Get the offset value and plug that in to your equation to set that as a level value.
7) For item #6, the further you are off of level for the offset, the less accurate you will be in higher readings. This mostly comes into play when you are over 6 degrees of tilt.
8) I have also used the 3 axis Freescale MMA7361L. Mount it on edge. You do not need to look at the Z, only X or Y depending on how it is mounted. Z is not going to tell you if the road is going up or down, it will only tell you it is not level


Some good resources on measuring tilt:
-Analog Devices app note AN-603
-Memsic app note #AN-00MX-012
-Freescale AN3107

This stuff was good enough to work on my bicycle where I did not take into account acceleration going up the grade (I usually do not accelerate going up hill, I am lucky to just get up the hill). You can use both X and Y readings to negate the effects of acceleration. You have to mount the sensor at a 45 degree angle. This is shown in the Memsic app note mentioned above.

Hope at least some of this helps.

-Larry G