Go Down

### Topic: Using accelerometer to detect driving state(s) (Read 11175 times)previous topic - next topic

#### knox

##### Jul 18, 2011, 03:08 pmLast Edit: Jul 18, 2011, 03:29 pm by knox Reason: 1
Hi everybody,

I am working on a project that makes use of an accelerometer to detect a car's driving state. For the start I will 'only' need to figure out if (when) there is a full braking taking place. Since this event will be used to trigger other functions the detection will have to be in realtime. So what I am looking for is a reliable and solid identification of the braking event. Here are some parameters I identified:

• Accelerometer will be mounted to the car. So I can assume to have a constant axis (probably x)

• Despite the constant axis there will be tilting of the car to some degree due to braking/accelerating or cornering. I am not sure how much impact this will, though. We are not talking about a race car

• Full braking are said to produce 1 to 1.2 g's (or 9.81 to 11,77m/secĀ²). Airbags go off at more than 2 g's

• I haven't figured out the minimum time for a full braking but I guess that everything longer than 2 or 3 tenth of a second should be sufficient.

So what I am actually looking for is an algorithm that is able to detect that sort of braking. Does anyone have a piece of advice on this?

#### AWOL

#1
##### Jul 18, 2011, 03:29 pm
If you need to detect braking, why not start with the brake pedal?
Otherwise, how do you distinguish braking from, say driving up a steep hill?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### knox

#2
##### Jul 18, 2011, 03:38 pm
Hi and thanks for noticing.

Making use of the brake pedal is not an option since the device should be as unobtrusive as possible. Yet, it must be very easy to install. I am planning on building a small box that
a) holds the Arduino board and the accelerometer and
b) connects to a 12 Volts power outlet to provide power for the board and allows for charging an Android handset.
There will probably be a simple push button glued to the dashboard (i.e. being reachable for the driver) to trigger a manual action.
Since we do not have many steep mountains in our tiny country we usually don't drive uphill with 1g
But you might have a point here. That's why I am asking you guys. I don't have any experience in making sense of accelerometer data.

#### fax8

#3
##### Jul 20, 2011, 11:11 pm
Supposing you have a 3-axis accelerometer, I would point the accelerometer with the X axis to the front of the car and the Y axis to the left of the car so that the Z axis of the accelerometer is perfectly normal to the ground and car plane. This way, gravity (you know, an accelerometer is also subject to static accelerations, not only dynamic accelerations - for an explaination on this see my thesis) won't impact on anything but the Z axis.

Then, everything > that 1G acceleration on the X axis means a braking.

Just hope not to get 1G acceleration on the Y axis, as that would mean you have been hit by a car or something

#### knox

#4
##### Jul 21, 2011, 09:37 amLast Edit: Jul 21, 2011, 09:40 am by knox Reason: 1

Supposing you have a 3-axis accelerometer, I would point the accelerometer with the X axis to the front of the car and the Y axis to the left of the car so that the Z axis of the accelerometer is perfectly normal to the ground and car plane. This way, gravity (you know, an accelerometer is also subject to static accelerations, not only dynamic accelerations - for an explaination on this see my thesis) won't impact on anything but the Z axis.

That's exactly what I am planning to do. It would result in x=0g; y=0g; z=1g for a not moving vehicle.
Now I'll start digging through your thesis

Quote
Then, everything > that 1G acceleration on the X axis means a braking.

Yes, but I am afraid that it will be a little more complicated. Assumably,
Code: [Select]
`if(x>=1.0) triggerFullBraking(true);` won't be enough for a reliable and robust detection. I am thinking about how a hard braking would be printed as a graph. Wouldn't it take some tenths of a second to build up the full braking pressure, i.e. reaching the maximum deceleration? On the other hand, you could also detect if the car comes to a full stop if you were able to identify the "nodding" of the car's body.

Quote
Just hope not to get 1G acceleration on the Y axis, as that would mean you have been hit by a car or something
Or you have a pretty nice car that allows for some decent cornering speeds...

#### fax8

#5
Keep us posted.

#6
##### Jul 21, 2011, 08:22 pm
Your scenario isn't nearly as simple as it's being portrayed, and your end goal is going to dictate the best method of reading/detecting braking to accomplish that.

1.0-1.2g braking is likely max braking for most vehicles under ideal conditions.  Dirt roads, dirt on the road, rain, snow, will all have a significant impact on max braking forces.

Most normal driving will also never see anywhere near 1.0-1.2g of braking.  More likely to be around 0.5g for normal daily driving (maybe even less for some people).  So are you looking to detect any normal braking event, or are you looking to detect some sort of emergency stop situation (in which it is assumed that you are braking as hard as possible)  Are you going to be doing anything when this is detected that could be problematic if it's just a case of the person stopping really hard just for the fun of it?

#### liuzengqiang

#7
##### Jul 21, 2011, 10:15 pm
According to simple law of physics, the static friction is only a small portion of gravity of an object, the factor is called static frictional coefficient. Unless you have some tank tracks or sticky surfaces (spider man), you will not have a static friction that exceeds gravity. So you will not have a deceleration greater than g.

http://hyperphysics.phy-astr.gsu.edu/hbase/mechanics/frictire.html

As for the braking thing, I think you should ride with an accelerometer and record the entire process of a number of hard breaks, soft breaks and what not so you have data to look at. Without data, I could argue 0.5g is trigger and needs to be at 0.5g+ for 0.1 second and you say different and neither has proof this is what actually happens.

#### AWOL

#8
##### Jul 22, 2011, 08:31 am
Quote
So you will not have a deceleration greater than g.

Brick wall?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### liuzengqiang

#9
##### Jul 22, 2011, 06:20 pm

Quote
So you will not have a deceleration greater than g.

Brick wall?

OP was talking about braking. There is no collisions involved.

#### AWOL

#10
##### Jul 22, 2011, 06:32 pm
Sorry, I forgot the smiley after "brick wall"

Anyway, you never heard of "the other way of stopping"?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### liuzengqiang

#11
##### Jul 22, 2011, 07:04 pm

Sorry, I forgot the smiley after "brick wall"

Anyway, you never heard of "the other way of stopping"?
Heard now but never tried
The problem of driving where I live is the winter is too long with frequent snow. I should stop being cheap and my next car will have ABS. I wonder if someone is interested in making such a "traction lost" sensing arduino. I wonder if falconfour is interested. You would have to be able to read speedometer and tire rotation speed.

#12
##### Jul 22, 2011, 09:45 pm

Two options that I can think of.

1)Put a pressure sensor on the brake master cylinder to detect brake pressure and send to Arduino. They make a simple on-off style switch or you could have a gauge pressure sensor if you wanted precision.

2)If you still have your brake light switch that opens and closes by the movement of the brake pedal, you can send that signal through a voltage divider to the Arduino letting it know that you have applied the brakes.

If the Arduino knows when the brakes are applied then, you will know when you have data that is related to braking.

Mark
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

#### knox

#13
##### Jul 26, 2011, 03:21 pmLast Edit: Jul 26, 2011, 03:48 pm by knox Reason: 1
Wow, quite a lot of answers. Somehow my email notifications got lost since I did not receive any after my last post. Sorry for taking so long to get back to you guys...

Your scenario isn't nearly as simple as it's being portrayed, and your end goal is going to dictate the best method of reading/detecting braking to accomplish that.

I never imagined it to be easy, that's why I turned to you folks

Quote
1.0-1.2g braking is likely max braking for most vehicles under ideal conditions.  Dirt roads, dirt on the road, rain, snow, will all have a significant impact on max braking forces.
Sorry I did not make that any clearer: I am talking about emergency brakings under normal (or best-case) conditions. Snow, dirt, rain, are not going to be considered in this very 1st prototype (or proof of concept).

Quote
Most normal driving will also never see anywhere near 1.0-1.2g of braking.  More likely to be around 0.5g for normal daily driving (maybe even less for some people).  So are you looking to detect any normal braking event, or are you looking to detect some sort of emergency stop situation (in which it is assumed that you are braking as hard as possible)  Are you going to be doing anything when this is detected that could be problematic if it's just a case of the person stopping really hard just for the fun of it?
As I just said above: I am interested in just those emergency stop situations. This projects aims at documenting why this particular situation required hitting the brakes so intensively. One part will be a front bumper mounted wide angle camera that takes a picture of what is going on in front of the car. To be able to capture the actual source of the situation lag should be as low as possible. Besides the camera thing we will also trigger an audio recording in the passenger compartment of the car. Moreover, drivers will be instructed to articulate the reason for their braking. Therefore, if a driver made an emergency braking just for the fun of it (who does that for fun?) all it would produce is a false positive recording. Not an issue for my scenario.

According to simple law of physics, the static friction is only a small portion of gravity of an object, the factor is called static frictional coefficient. Unless you have some tank tracks or sticky surfaces (spider man), you will not have a static friction that exceeds gravity. So you will not have a deceleration greater than g.
http://hyperphysics.phy-astr.gsu.edu/hbase/mechanics/frictire.html

Now that is pretty interesting. I haven't worked through the article, yet. That's probably why I am going to make a fool out of myself now: my emergency braking is around 1g comes from a site which explains how airbags in cars work (I'd provide the link but unfortunately it is in german). However, I found a Wikipedia article about Formula 1 cars that are supposed to decelerate with up to 5.0 g. This is quite remarkable since the best street legal car, the Bugatti Veyron, is -and I quote- "claimed to be able to brake at 1.3 g" [SOURCE]
Another interesting section is to be found under Deceleration

Quote
As for the braking thing, I think you should ride with an accelerometer and record the entire process of a number of hard breaks, soft breaks and what not so you have data to look at. Without data, I could argue 0.5g is trigger and needs to be at 0.5g+ for 0.1 second and you say different and neither has proof this is what actually happens.

Generating braking samples myself is what I consider my very last option since this is going to cost me quite some money (gas, tyres, brake pads and discs, depreciation, etc.).

Two options that I can think of.
1)Put a pressure sensor on the brake master cylinder to detect brake pressure and send to Arduino. They make a simple on-off style switch or you could have a gauge pressure sensor if you wanted precision.

Sorry, not a solution for me. This thing is going to be inserted into actual customer cars and should as easy to install as possible

Quote
2)If you still have your brake light switch that opens and closes by the movement of the brake pedal, you can send that signal through a voltage divider to the Arduino letting it know that you have applied the brakes.

If the Arduino knows when the brakes are applied then, you will know when you have data that is related to braking.

Not really. This would allow me to detect that there is some braking while not being able to determine its severity.