you can use a buffer with a fixed size. Use it as an endless buffer. Start at 0 and write til the end, if you are at the end start with 0. You need a buffer which can store the data of 5 sec. If the alarm occurs you can add the additional data to your buffer and store it to a file.
Hope it helps.
Several solutions. my favorite one:
Use a Functional Global Variable (an uninitialized shift register in your while loop to hold the array data), add the scalar data at the front of the array and then resize the array to the size needed to store 5 secs of data. Pass the scalar data also to a chart graph for display. To save the last 5 secs of data take the whole content of the array and write it to disc.
i'll send a VI tomorrow
here's the VI. Remember, it's just a suggestion, there are other ways to implement this (e.g. queues).