fixed interval export


Recommended Posts

I have a question concerning export sets with the fixed interval option. I stream 4 channels (U3-HV, as shown in the example files) stop the streaming and then export to Excel. Everything works fine, as long as I have the the option "all data points" in the export set. I want to increase the accuracy by upping the streaming rate 10x from 250 to 2500, streaming until the history is full, and then exporting the averaged data (10 points average) at the fixed interval of 4ms to get smoother results.

When I tried changing the detail settings in the export set to the fixed interval and "averaged" I get only one line of data in the csv file. What am I doing wrong?

Thanks

Adam

Link to comment
Share on other sites

Personally, I'd do this in script to get total control, especially since you only want to average 2 channels. However, you might try just doing the averaging in the expression instead of using the export set. So, where you have an expression of "grip" for the first column, put:

BoxCar(grip, 10)

You might consider reducing release and distance too by using BoxCarMax(), and then use all data points / aligned instead of snapshot.

Link to comment
Share on other sites

This is great - the Boxcar and BoxcarMax functions work! There is one problem though: the number of sample rows is now 2000, not 1000, which should be the case, since the streaming rate was 2500Hz and 10 samples are averaged by boxcar. For some reason the alignment is off as well - the interval now varies from 1 to 3ms, not 4ms. This is at alignment = 0 in the export set. At alignment = 1 only four rows total get exported to the Excel file.

I tried to reduce the number of sample rows to 1000, which works when the boxcar-ed average is 20. Still, the alignment is off and the rate varies from 1 to 7ms between the rows.

For my application, the varied interval is not a problem as long as it is no more than 4ms, but the alignment between the channels is important, so that I can see exactly what each channel is doing at any given moment.

Thanks again

Adam

Link to comment
Share on other sites

I'd probably just write a little script to stick the results in a single variable and log that variable, probably using File. functions, though an export set might still work.

private out

out[][0] = boxcar(a,10)

out[][1] = boxcar(b,10)

out[][2] = boxcarMax(c,10)

out[][3] = boxcarMax(d,10)

where a,b,c, and d are your channels.

Then either export just "out", or use file. functions and writedelim() to log it yourself.

Link to comment
Share on other sites

Thak you. I am not sure how to export "out" via the export set, but I found I can use Boxcar for all channels in the export set, as long as I do not have the BoxcarMax for a channel in the same set (then all trouble start as above). I can live with the Boxcar, so this problem is solved.

I need to ask for another thing: I want to have more columns in the export set for calculated data on two channels. This is to subtract the offset (for a load cell) and have the result in pounds. The offset is averaged over the last 20 values. I made something like this:

Boxcar((grip - Mean(grip[0,19]))/51*1000/0.0075), 10)

It seems to work, but I wonder if it is possible to use the first 20 values rather than the last for averaging. The history length is 10000, so perhaps Mean(grip[9980,10000] would work? Do I need to specify the column number as well, as grip[9980,10000][0]?

Lastly, is it possible to filter the data before the beginexport command? I need to export only the rows after the "distance" channels > 0, but then end the export once the"release" channel jumps up to 0.5 (it is a switch type input). How to do it and where to put the filter sequence? I can do all that later in Excel, but it would be neat to have everything done so fast.

Thanks for your patience

Adam

Link to comment
Share on other sites

Yes, you can select just the last 20 values. I'd probably use numrows() to determine it instead of hardcoding it based on the history length:

grip[numrows(grip) - 21, numrows(grip)-1]

You only need to specify column if grip is a multidimensional array.

As for filter, you probably can use the filter() function and do it right in the export set.

Link to comment
Share on other sites

Thanks, the numrows works very well. If I want to have the first 20 values averaged, do I still need to specify the (9980,10000) or there is a way around it? It would be safer here to averaged the first 20, since then a possible post-bounce decay can be avoided.

I tried the filter function in the export set, but the file did not get exported. It went like this:

Filter(Boxcar(grip, 10), ((distance > 0) && (release < 0.3))

for all channels (with the channel names changed from grip to the other ones, while the filter condition remained the same for all. No export file.

Thanks again

Adam

Link to comment
Share on other sites

I don't understand your first question. Using numrows() the way I did gives you the oldest 20 data points, and avoids the 9980,10000.

As for filter, use the command / alert window to test the filters before you export. The issue you are likely having is that boxcar(grip) is a different sized array than distance and release. Unlike XY graphs, the filter() function does NOT align data based on time. It is a simple 1 to 1 in the array. You should probably apply the filter first, then apply the boxcar to the result of the filter.

Link to comment
Share on other sites

I am sorry, I thought you refered in your example to the last (most recent) data points, not the oldest, since the [0] is the most recent.

Would this make sense:

Boxcar(Filter(grip, ((distance > 0) && (release < 0.3)), 10) ?

The filtering is done first, then boxcar.

Thanks

Adam

Link to comment
Share on other sites

Yes, though you need to understand the implications. Boxcar is done on data points, not time, so you will likely get averages across any breaks. You actually might be better off boxcarring grip, distance and release, then filtering. Its the opposite of what I just said, but will do the job as well. In that case, however, it will be filtering on averaged values of distance and release.

I'm assuming also that grip, distance and release are all sampled at the same rate.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.