So, it is better to just bear with the 10% errors and move on with the data i get?

When you start writing the code that uses the senor readings, I would include variables for offset and scale, so you would have for example

x_real = (x_raw - x_offset) * x_scale

and similar for y and z.

To start with, you can just set all the offsets to 0, and set all the scales to the nominal 3.9 (1000/256).

Then you don't need to change the main part of the code if you add a calibration step later where you actually measure values for the offsets (and if using the 'turn it over' method also values for the scales).

When you start writing the code that uses the senor readings, I would include variables for offset and scale, so you would have for example

x_real = (x_raw - x_offset) * x_scale

and similar for y and z.

To start with, you can just set all the offsets to 0, and set all the scales to the nominal 3.9 (1000/256).

Then you don't need to change the main part of the code if you add a calibration step later where you actually measure values for the offsets (and if using the 'turn it over' method also values for the scales).

Right now, i know scale but i am not completely sure how to calculate the offset.

I don't think you do know the scale exactly. You are just assuming that it is the nominal value from the datasheet, which it probably won't be exactly.

However, that may be good enough. Depends how accurate you need it to be.

So, one last time.

There are a number of different calibration methods, depending on how accurate you need it.

1) simple one position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

This was described back in post #15.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give you the offset directly.

For the z offset, you have to assume the scale/sensitivity is the nominal value given in datasheet. In practice it probably won't be, so you have some error in the z offset.

2) slightly improved two position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give offsets directly, ignore z readings.

Then reposition board such that z is now in 0g.

Take z reading, this gives you the z offset.

3) full on 'turn it over' method on all 3 axis, gives offsets and scale.

Place board so z is in 1g. Take z reading.

Turn it over so z is in -1g. Take z reading.

The combination of the 2 readings gives you both offset and scale for the z axis.

Place board so x is in 1g. Take x reading.

Turn it over so x is in -1g. Take x reading.

The combination of the 2 readings gives you both offset and scale for the x axis.

Place board so y is in 1g. Take y reading.

Turn it over so y is in -1g. Take y reading.

The combination of the 2 readings gives you both offset and scale for the y axis.

I don't think you do know the scale exactly. You are just assuming that it is the nominal value from the datasheet, which it probably won't be exactly.

However, that may be good enough. Depends how accurate you need it to be.

So, one last time.

There are a number of different calibration methods, depending on how accurate you need it.

1) simple one position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

This was described back in post #15.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give you the offset directly.

For the z offset, you have to assume the scale/sensitivity is the nominal value given in datasheet. In practice it probably won't be, so you have some error in the z offset.

2) slightly improved two position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give offsets directly, ignore z readings.

Then reposition board such that z is now in 0g.

Take z reading, this gives you the z offset.

3) full on 'turn it over' method on all 3 axis, gives offsets and scale.

Place board so z is in 1g. Take z reading.

Turn it over so z is in -1g. Take z reading.

The combination of the 2 readings gives you both offset and scale for the z axis.

Place board so x is in 1g. Take x reading.

Turn it over so x is in -1g. Take x reading.

The combination of the 2 readings gives you both offset and scale for the x axis.

Place board so y is in 1g. Take y reading.

Turn it over so y is in -1g. Take y reading.

The combination of the 2 readings gives you both offset and scale for the y axis.

Right now i really did understand there are different methods to do "calibration". But can you explain more on the "Turn it over" method? Also all these "calibration" test is a one off thing right? Means i only need to do one of these "calibration" once right, then next time i just sub those values in without doing the "calibration" again. Am i right on this one?

It's called ‘calibration’ - you do it once and store the offset and scale values usually in eeprom. For a one off, you might hard code these values into your code. Whilst the calibration drifts with temperature, it is only small. The datasheet says around 0.01% per degreeC.

'turn it over' means rotate it on its axis 180 degrees. Basically look for the most positive reading, then look for the most negative reading.

Also all these "calibration" test is a one off thing right? Means i only need to do one of these "calibration" once right, then next time i just sub those values in without doing the "calibration" again. Am i right on this one?

YES!!!

ckkkkk wrote:

But can you explain more on the "Turn it over" method?

This is ka7ehk method from way back in post #10.

For each axis, you need to position it so that axis is vertical. But there are 2 ways it can be vertical, the positive direction of the axis can either be pointing into the ground or up into the air. So you take a reading (or a set of readings and average them) in both positions.

For each axis, you need to position it so that axis is vertical. But there are 2 ways it can be vertical, the positive direction of the axis can either be pointing into the ground or up into the air. So you take a reading (or a set of readings and average them) in both positions.

It doesn't need to be in vertical right? Can it be horizontal?

MrKendo wrote:

And

A + B = 240 + (-260) = 2 * offset

-20 = 2 * offset

-10 = offset

I don't understand why -20 is not the offset for z-axis instead -10 is the offset. Also can i perform the "calibration" now and can you please take a look to check whether if i do it correctly or not?

Acceleration in X-Axis : -4
Acceleration in Y-Axis : 5
Acceleration in Z-Axis : 223
Acceleration in X-Axis : -4
Acceleration in Y-Axis : 5
Acceleration in Z-Axis : 223
Acceleration in X-Axis : -4
Acceleration in Y-Axis : 5
Acceleration in Z-Axis : 223
Acceleration in X-Axis : -5
Acceleration in Y-Axis : 5
Acceleration in Z-Axis : 223
Acceleration in X-Axis : -7
Acceleration in Y-Axis : 3
Acceleration in Z-Axis : 218
Acceleration in X-Axis : -7
Acceleration in Y-Axis : 3
Acceleration in Z-Axis : 218
Acceleration in X-Axis : -7
Acceleration in Y-Axis : 3
Acceleration in Z-Axis : 218
Acceleration in X-Axis : -9
Acceleration in Y-Axis : 3
Acceleration in Z-Axis : 218
Acceleration in X-Axis : -9
Acceleration in Y-Axis : 3
Acceleration in Z-Axis : 218
Acceleration in X-Axis : -9
Acceleration in Y-Axis : 5
Acceleration in Z-Axis : 218

When data is positive

Acceleration in X-Axis : -13
Acceleration in Y-Axis : 0
Acceleration in Z-Axis : -264
Acceleration in X-Axis : -13
Acceleration in Y-Axis : 0
Acceleration in Z-Axis : -264
Acceleration in X-Axis : -13
Acceleration in Y-Axis : 0
Acceleration in Z-Axis : -271
Acceleration in X-Axis : -14
Acceleration in Y-Axis : 0
Acceleration in Z-Axis : -271
Acceleration in X-Axis : -14
Acceleration in Y-Axis : 0
Acceleration in Z-Axis : -271
Acceleration in X-Axis : -10
Acceleration in Y-Axis : -1
Acceleration in Z-Axis : -268
Acceleration in X-Axis : -10
Acceleration in Y-Axis : -1
Acceleration in Z-Axis : -268
Acceleration in X-Axis : -10
Acceleration in Y-Axis : -4
Acceleration in Z-Axis : -271
Acceleration in X-Axis : -11
Acceleration in Y-Axis : -4
Acceleration in Z-Axis : -271
Acceleration in X-Axis : -11
Acceleration in Y-Axis : -4
Acceleration in Z-Axis : -271

When data is negative

Average of positive data = 220 and Average of negative data = -269

And your value for the sensitivity is 1g = 489 / 2 = 244.5

So you can see it is a bit different to the nominal value of 256.

And if you want to convert 1g= 244.5 to scale in mg then scale = 1000 / 244.5 = 4.09mg

So for the scale value, which 1 do i follow? Should i take the one from the datasheet?

MrKendo wrote:

ckkkkk wrote:

Oh, so in order to solve the offset is to +10

Yes, or you can think of it as subtracting -10,

as in z_real = (z_raw - z_offset) * z_scale.

I'm done now!

But for my case z_real = (220 - (-24.5) * 0.0039 = 0.95355G ? Also i have to do it for X and Y-axis right in order to acquire the offset from the x and y-axis.

Correct. You need to reorient it and repeat the measurements for each axis. There is a unique pair of offset/scale values for each axis.

If it is fall detection you are after, the question is: are you talking about a fall as in "the cellphone is falling" or a fall as in "my grandfather fell down"? In the first case, all axes go very close to zero during the fall time of a few 10s of milliseconds. The usual reason for doing this is to shut down any moving parts (e.g. memory). In the second case, the orientation will be different from that of a standing or sitting person. So, different criteria for detecting what is a fall and what is not. Neither of these cases really needs calibration of the kind you have been asking about.

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

Correct. You need to reorient it and repeat the measurements for each axis. There is a unique pair of offset/scale values for each axis.

If it is fall detection you are after, the question is: are you talking about a fall as in "the cellphone is falling" or a fall as in "my grandfather fell down"? In the first case, all axes go very close to zero during the fall time of a few 10s of milliseconds. The usual reason for doing this is to shut down any moving parts (e.g. memory). In the second case, the orientation will be different from that of a standing or sitting person. So, different criteria for detecting what is a fall and what is not. Neither of these cases really needs calibration of the kind you have been asking about.

Jim

Oh i am doing the "my grandfather fell down" one. Also could you please help me check whether the above calculations i did are correct and should i follow the scale on the datasheet or just use the scale value i found during the calibration?

You can easily check if your calculations are correct - you should measure +/- 1g. If you don't, then your calcs are wrong. Really, this is simple linear algebra math - nothing magic. The same techniques would apply to finding the centre of a piece of wood.

You can easily check if your calculations are correct - you should measure +/- 1g. If you don't, then your calcs are wrong. Really, this is simple linear algebra math - nothing magic. The same techniques would apply to finding the centre of a piece of wood.

Alright, then everything is fine as all come close to 1g and -1g.

Think about the basic physics of the problem - if someone trips over, what is the acceleration involved? Do you care about this acceleration or are you more interested in the position of the subject in relation to the ground?

My concern is you seem to lack basic maths skills and to do fall detection successfully requires a lot of maths- both from the physics involved, but also filtering and processing of the data. Unfortunately it is not as simple as: read sensor, determine vertical or horizontal, alarm or no alarm. Whilst it might appear simple, this is a stunningly difficult problem.

Think about the basic physics of the problem - if someone trips over, what is the acceleration involved? Do you care about this acceleration or are you more interested in the position of the subject in relation to the ground?

My concern is you seem to lack basic maths skills and to do fall detection successfully requires a lot of maths- both from the physics involved, but also filtering and processing of the data. Unfortunately it is not as simple as: read sensor, determine vertical or horizontal, alarm or no alarm. Whilst it might appear simple, this is a stunningly difficult problem.

Well, this is really challenging to me but i definitely am going to try my best to do it. Also thanks for your concern, appreciate it.

ckkkkk wrote:When you start writing the code that uses the senor readings, I would include variables for offset and scale, so you would have for example

x_real = (x_raw - x_offset) * x_scale

and similar for y and z.

To start with, you can just set all the offsets to 0, and set all the scales to the nominal 3.9 (1000/256).

Then you don't need to change the main part of the code if you add a calibration step later where you actually measure values for the offsets (and if using the 'turn it over' method also values for the scales).

- Log in or register to post comments

TopMrKendo wrote:Right now, i know scale but i am not completely sure how to calculate the offset.

- Log in or register to post comments

TopI don't think you do know the scale exactly. You are just assuming that it is the nominal value from the datasheet, which it probably won't be exactly.

However, that may be good enough. Depends how accurate you need it to be.

So, one last time.

There are a number of different calibration methods, depending on how accurate you need it.

1) simple one position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

This was described back in post #15.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give you the offset directly.

For the z offset, you have to assume the scale/sensitivity is the nominal value given in datasheet. In practice it probably won't be, so you have some error in the z offset.

2) slightly improved two position calibration. Gives offsets only. Scale (or sensitivity) is assumed to be the nominal value from datasheet ie. 256 for 1g.

Place board on level surface so x and y are in 0g, z is in 1g.

x and y readings give offsets directly, ignore z readings.

Then reposition board such that z is now in 0g.

Take z reading, this gives you the z offset.

3) full on 'turn it over' method on all 3 axis, gives offsets and scale.

Place board so z is in 1g. Take z reading.

Turn it over so z is in -1g. Take z reading.

The combination of the 2 readings gives you both offset and scale for the z axis.

Place board so x is in 1g. Take x reading.

Turn it over so x is in -1g. Take x reading.

The combination of the 2 readings gives you both offset and scale for the x axis.

Place board so y is in 1g. Take y reading.

Turn it over so y is in -1g. Take y reading.

The combination of the 2 readings gives you both offset and scale for the y axis.

- Log in or register to post comments

TopMrKendo wrote:Right now i really did understand there are different methods to do "calibration". But can you explain more on the "Turn it over" method? Also all these "calibration" test is a one off thing right? Means i only need to do one of these "calibration" once right, then next time i just sub those values in without doing the "calibration" again. Am i right on this one?

- Log in or register to post comments

TopKartman wrote:'turn it over' means rotate it on its axis 180 degrees. Basically look for the most positive reading, then look for the most negative reading.

- Log in or register to post comments

Topckkkkk wrote:YES!!!

ckkkkk wrote:This is ka7ehk method from way back in post #10.

For each axis, you need to position it so that axis is vertical. But there are 2 ways it can be vertical, the positive direction of the axis can either be pointing into the ground or up into the air. So you take a reading (or a set of readings and average them) in both positions.

Let's say reading A is 240.

And the other way up, reading B is -260.

The 2 readings will be of opposite sign.

You can then say

A - B = 2g

A + B = 2 * offset

So in this example,

A - B = 240 - (-260) = 2g

500 = 2g

250 = g

And

A + B = 240 + (-260) = 2 * offset

-20 = 2 * offset

-10 = offset

- Log in or register to post comments

TopMrKendo wrote:MrKendo wrote:I don't understand why -20 is not the offset for z-axis instead -10 is the offset. Also can i perform the "calibration" now and can you please take a look to check whether if i do it correctly or not?

- Log in or register to post comments

Topckkkkk wrote:draw a diagram. It will make sense when you think about it.

- Log in or register to post comments

TopWhen data is positive

When data is negative

Average of positive data = 220 and Average of negative data = -269

MrKendo wrote:220 + (-269) = 2 * offset

-49 = 2 * offset

-24.5 = offset?

- Log in or register to post comments

TopMrKendo wrote:Oh, so in order to solve the offset is to +10

- Log in or register to post comments

Topckkkkk wrote:Yes, offset = -24.5

And your value for the sensitivity is 1g = 489 / 2 = 244.5

So you can see it is a bit different to the nominal value of 256.

And if you want to convert 1g= 244.5 to scale in mg then scale = 1000 / 244.5 = 4.09mg

ckkkkk wrote:Yes, or you can think of it as subtracting -10,

as in z_real = (z_raw - z_offset) * z_scale.

I'm done now!

- Log in or register to post comments

TopMrKendo wrote:So for the scale value, which 1 do i follow? Should i take the one from the datasheet?

MrKendo wrote:But for my case z_real = (220 - (-24.5) * 0.0039 = 0.95355G ? Also i have to do it for X and Y-axis right in order to acquire the offset from the x and y-axis.

- Log in or register to post comments

TopThese are data from x-axis

MrKendo wrote:Average of positive data = 250.5 and Average of negative data = -266.3

250.5 + (-266.3) = 2 * offset

-15.8 = 2 * offset

-7.9 = offset

value for the sensitivity is 1g = 516.8 / 2 = 258.4

1000 / 258.4 = 3.87 mg

Below are data from y-axis

Average of positive data = 256.5 and Average of negative data = -261.4

256.5 + (-261.4) = 2 * offset

-4.9 = 2 * offset

-2.45 = offset

value for the sensitivity is 1g = 517.9 / 2 = 258.95

1000 / 258.95 = 3.86 mg

Am i doing all these calculations correctly?

- Log in or register to post comments

TopCorrect. You need to reorient it and repeat the measurements for each axis. There is a unique pair of offset/scale values for each axis.

If it is fall detection you are after, the question is: are you talking about a fall as in "the cellphone is falling" or a fall as in "my grandfather fell down"? In the first case, all axes go very close to zero during the fall time of a few 10s of milliseconds. The usual reason for doing this is to shut down any moving parts (e.g. memory). In the second case, the orientation will be different from that of a standing or sitting person. So, different criteria for detecting what is a fall and what is not. Neither of these cases really needs calibration of the kind you have been asking about.

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

- Log in or register to post comments

Topka7ehk wrote:Oh i am doing the "my grandfather fell down" one. Also could you please help me check whether the above calculations i did are correct and should i follow the scale on the datasheet or just use the scale value i found during the calibration?

- Log in or register to post comments

TopYou can easily check if your calculations are correct - you should measure +/- 1g. If you don't, then your calcs are wrong. Really, this is simple linear algebra math - nothing magic. The same techniques would apply to finding the centre of a piece of wood.

- Log in or register to post comments

TopKartman wrote:Alright, then everything is fine as all come close to 1g and -1g.

- Log in or register to post comments

TopCan i know what is the most suitable measurement range for fall detection? There are the +-2,4,8,16G.

- Log in or register to post comments

TopThink about the basic physics of the problem - if someone trips over, what is the acceleration involved? Do you care about this acceleration or are you more interested in the position of the subject in relation to the ground?

My concern is you seem to lack basic maths skills and to do fall detection successfully requires a lot of maths- both from the physics involved, but also filtering and processing of the data. Unfortunately it is not as simple as: read sensor, determine vertical or horizontal, alarm or no alarm. Whilst it might appear simple, this is a stunningly difficult problem.

- Log in or register to post comments

TopKartman wrote:Well, this is really challenging to me but i definitely am going to try my best to do it. Also thanks for your concern, appreciate it.

- Log in or register to post comments

Top## Pages