# Measure accelerometer not moved over time

Hi

I have a 3ax accelerometer and I want to measure if it has not been moved over a period of 5 minutes. The accelerometer will be worn by a human. I want to know if the human has stopped moving. I am not worried about any of the actual measurents I just need to know when x, y, z has stopped moving. I may need to measure if all or just measure any (x, y, z) have stopped moving. I am not sure of that yet.

The only way I can think of is, findout when I get “X” number repeated over a specific count or time. Example: If something is sending data 1 time a second and I count 60 times in a row the value is the same. Then we can say that for 1 minute the accelerometer has not moved. Unlucky for me I have no idea how to code that…

Thanks dnickle

Here is what I am working with. The output is pretty smooth.

``````int xin = 1;
int yin = 2;
int zin = 3;
int xval;
int yval;
int zval;
int xavg;
int yavg;
int zavg;
int xtotal;
int ytotal;
int ztotal;
int xarray[60];
int yarray[60];
int zarray[60];
int i;
int count = 0;

void setup() {
Serial.begin(19200);
}

void loop(){
xarray[count] = xval;
yarray[count] = yval;
zarray[count] = zval;
count ++;
if (count == 60){
count = 0;
}
xtotal = 0;
for (i = 0; i <= 59; i ++){
xtotal = xtotal + xarray[i];
}
ytotal = 0;
for (i = 0; i <= 59; i ++){
ytotal = ytotal + yarray[i];
}
ztotal = 0;
for (i = 0; i <= 59; i ++){
ztotal = ztotal + zarray[i];
}
xavg = (xtotal / 60);
yavg = (ytotal / 60);
zavg = (ztotal / 60);
Serial.print(xavg);
Serial.print("\t");
Serial.print(yavg);
Serial.print("\t");
Serial.print(zavg);
Serial.print("\t");
Serial.println();
}
``````

I'm not sure if this answers your question but I have a 3 axis accelerometer in my bike alarm/tracker. Once powered it 'knows' the initial bike position and if the bike is tilted off its side stand or pushed an SMS message is sent to my phone.

It works a little like this: on power on wait 1 second for accelerometer to become stable and store the reading as an absolute value. Then at regular intervals store a new value and compare it to the initial stored value. If the absolute value is greater than a pre-determined threshold value then send the message.

I do this to allow for small flucuations in the accelerometer output to reduce false alarms. the same is done for all three outputs.

Does this make sense, if not let me know and I'll try to clarify.

Yes that makes sense to me. I have a group of guys that are required to conduct a land navigation course. The rule is you have to complete in under 4 hours and you can not rest for more than 5 minutes at a time. So I just need to measure at any given time during a 5 minute interval there are no accelerometer movements. It sounds like I could modify or use what you are doing.

Thanks

Ah, I see. So whereas I’m checking for movement at short intervals, you want to check that you have movement and if not then the ‘alarm’ is raised.

The rule is you have to complete in under 4 hours and you can not rest for more than 5 minutes at a time.

So, rest without moving for 4:59, then, roll over, and rest for another 4:59, then roll back and rest for another 4:59. This is OK?

Absolutely, I expect guys to stop take a short break drink water, read a map, look at a compass. If they do stop for more than the allowed time, either a survival strobe will turn on and or data log the occurance.

Anyone have any ideas? I'm a pig looking at a wrist watch....

dnickle

You can’t just test every 5 minutes because they could happen to have 1-min breaks 4 mins apart.

I think all you have to do is pretty much what’s been said, take a reading evey second (say), compare with the last reading, < X (still) then increment a counter, > X (moving) zero the counter.

If the counter reaches 300 (5mins * 60secs) bingo!

Rob

No, good gent, you asked a question nobody wanted to bother about. This is usually either because the question is senseless or there seems little point in wasting time on it because the one asking will ignore it anyway. If you pose such questions, the problem lies with you, not the community.

Korman

My apologies korman. If I have ignored the response from others is because I am not smart enough to understand or grasp what is passed. I have spent several hundred dollars on parts, pieces and books. I do want to learn and understand. Having said that I would surmise that I will do something in the end. I have two choices; 1 pay someone to build a product, or 2 learn and figure it out. Again my apologies for my poor articulation and ignorance.

Then don't be so smug about other not helping you or your questions being too complicated, it tends to drive people away from helping you. And in case your problem is really a touch one, usually you get very quickly responses from people knowing about such matters that you're moving in problematic areas or that your chosen path has severe limitations.

Korman

K thanks again. I am very new to all of this. I am able to measure time lapse and I can read a gps (PaulS helped) speed so that will work speed, distance and time. I also need to say if someone is not moving in a non gps environment. That part eludes me.