Click to See Complete Forum and Search --> : Plotting large data sets in small spaces


evanandr
December 12th, 2007, 09:52 AM
I'm currently working with a USB based oscilloscope and writing a plot program to display the oscope trace. Data values from the oscope come in the form of 'ADC counts' (32768 to -32768). We then use the current device settings to convert to millivolts for oscope plotting (or further convert to an amplitude for a spectrum analyzer display).

The problem is that data sample sizes returned can be anywhere from a few hundred values to over 100,000 values (depends on the time base used). Our plotting space is a bitmap (using GDI). Of course, Bitmap space is inherently limited. Our bitmap is 560 pixels wide at this point, we could grow that a bit but the problem remains the same.

When drawing a spectrum analyzer display we can afford to drop some data values and get a reasonably accurate display. The existing code here would simply get 560 data points (one per pixel) from the captured data. The values used are evenly spaced through our sample size, i.e. every 178th sample from a 100,000 value data capture to get 560 plotting values.

When drawing an oscope display this becomes problematic. Individual pulses may only be represented by 10-20 data values. Our existing logic will entirely miss pulses. We can group captured data values and average them together but this will distort the actual voltage value of the pulses.

Has anyone faced a similar problem before plotting large data samples into small spaces? So far we've haven't come up with a algorithm to scale our sample size down into a smaller space and maintain accuracy.

pm_kirkham
December 21st, 2007, 09:36 AM
Maybe you could plot all the points using a graphics library which supports non-integral points and correctly antialiases lines. Anti-grain geometry is one such library, but I haven't used it in production. You should get something that looks like a scaled down version of the true graph, rather than a subsampled plot.

evanandr
December 21st, 2007, 12:12 PM
Thanks for the idea, I'll look into it