# LabVIEW

cancel
Showing results for
Did you mean:

## Using Shift Registers

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,

Message 1 of 6
(2,762 Views)

## Re: Using Shift Registers

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?

************ kudos always appreciated, but only when deserved **************************

Message 2 of 6
(2,761 Views)

## Re: Using Shift Registers

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,

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.

Message 3 of 6
(2,712 Views)

## Re: Using Shift Registers

I'll try to send you one later tonight when I get home...  If I forget, remind me.

************ kudos always appreciated, but only when deserved **************************

Message 4 of 6
(2,709 Views)

## Re: Using Shift Registers

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.

Message Edited by Parny on 03-02-2009 11:38 PM
Message 5 of 6
(2,679 Views)

## Re: Using Shift Registers

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?