02-25-2009 07:56 PM
I am trying to create an algorithm that timestamps when a subject's arm is raised. The subject has a bluetooth accelerometer attached to their arm and y acceleration=0 when raised and y=1 when lowered. We want to timestamp the raise. Right now we have (using shift registers) that when Yaccel <0.2 and Yaccel-1>0.2 and Yaccel-2>0.2, write to file (In Case Structure).
We used 2 shift registers to get the Yaccel-1 and Yaccel-2 values.The problem is: any jerk in the direction of the y axis causes the acceleration in this direction to go to 0 momentarily. We need to look at a longer running list (about 1 second or 100 data points) of data to assure that this isn't a jerk but a raise. However, we can't have 100 shift registers as that would be crowded.. What can we do?
Thanks,
-Adam
02-25-2009 08:00 PM
How about using one shift register but make it an array. Each time you add a pt to the end, take the first one off (after you take 100 pts). Then you can take the average of the last 100 pts.
Is that good enough or do you need an example?
03-02-2009 08:48 PM
That sounds right. Could you help me with an example? I tried creating the array, but couldn't get it to append a 101st value than delete the 1st value correctly. I'd really appreciate it.
Thanks,
-Adam
I need to be able to apply conditional statements to certain values in the array of the last 100 points. Ex. If the last value (100 points back) >0.2 and the 99th through 1st values are all <0.2, condition=true.
03-02-2009 09:08 PM
03-02-2009 11:37 PM - edited 03-02-2009 11:38 PM
You can look at the enclosed example which relies on time of 1sec interval, however I just considered Yaccel - 1 for demonstration, you may include others later.
The timer is set(just double click on it) to 1 sec and time duration been scrutinised to make a decision of using the data or scrap it off. If time goes above 1sec(no jerks occured), values are retained and ticks to state-0(you may code here, to write the data to the FILE), where if time is <1sec(jerky behaviour) and data is discarded by moving to state-2.
The reason to do the time check in side the case structure is that, we don't want to loose the data till first second if the check is positive. To conclude, the structure starts gathering values when Yaccel - 1 goes >0.2 and also makes decision to write or not by checking the timer value inside it.
Hope it gives some idea.
03-03-2009 01:03 AM
Just got home and it looks like Parny has taken care of an example. Thanks Parny.
So... is this good enough? Or do you need more help?