loss of precision during histograming

Post general discussions on using our drivers to write your own software here
Post Reply
johnm1019
Newbie
Posts: 0
Joined: Mon Nov 08, 2010 10:15 am

loss of precision during histograming

Post by johnm1019 »

Hello, I've recently written my own code to histogram my data as it comes back from fast_streaming.

I have a problem that I can only seem to get 6 bits of precision. If I try to bin with 128 bins my histogram has precision artifacts as seen in the picture attached. When I use 64 bins, I get a proper histogram with no precision artifacts but of course have lost resolution.
The waveform is a pulse-height spectrum from a nuclear detector. It should be a two gaussians next to each other. You can see in the incorrect picture that the counts in each channel go high/medium/high/medium/high/medium and it is not smooth. In the correct picture, you can see the two gaussians with the single channel in the middle being a proper 'valley' in between the two peaks.

Below the pictures I discuss my code used (3 lines).

Incorrect
bad
bad
Correct
good
good
spectrum_correct_64.png (9.8 KiB) Viewed 6538 times
Correct with actual waveform overlaid
correct with target waveform (poorly) overlaid
correct with target waveform (poorly) overlaid

The whopping 3 lines of code that touch my data are listed below. I believe I should be getting 7 bits of precision because my waveform lies between 0 and 1 volt so I am sampling between -1 and 1 volt and losing one bit not having negative values. (the waveform really lies between 0 and ~550mV)

Code: Select all

//initialize bin divisor
m_binDivider = std::numeric_limits::max() / static_cast(m_bins-1);
// m_binDivider is a float
// (m_bins-1) is used because 0 is used as a bin
// copy from the picoscope
memcpy(Picoscope::m_buffer + Picoscope::m_bufferSize * sizeof(short), *overviewBuffers, nValues * sizeof(short));

for each peak in peaks_seen_in_sampleInterval
{
  m_events.push_back((peak / m_binDivider)); // yes, the cast causes truncation
}
// m_events is a std::vector of ints
// peak is a short which holds maximum value of each peak of each gaussian seen coming down the line
// push m_events entries into histogram vector before painting where the histogram vector bin-values are ints
// paint histogram
Am I going about this incorrectly?

Thanks so much for any help.

PS - is it possible to ask the picoscope to sample with +-500mV at some DC offset? I didn't see this in the documentation.

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Re: loss of precision during histograming

Post by ziko »

Hi this depends on the product that you are using, the new 3000 A and B range and the 6000 range have DC offset of up 2.5V.

Kind regards
Ziko

Technical Specialist

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Re: loss of precision during histograming

Post by ziko »

Hi,

With regards to your initial question, is this histogram a frequency versus amplitutde plot? If so have you tried using our spectrum view to replicate this?

If not could you explain further what this view is doing?

Kind regards
Ziko

Technical Specialist

johnm1019
Newbie
Posts: 0
Joined: Mon Nov 08, 2010 10:15 am

Re: loss of precision during histograming

Post by johnm1019 »

ziko wrote:Hi,
With regards to your initial question, is this histogram a frequency versus amplitutde plot? If so have you tried using our spectrum view to replicate this?
If not could you explain further what this view is doing?
Kind regards

This is a plot of pulse-height frequency. The input signal is randomly spaced gaussians with varying maximum amplitudes. I stream from the ps2203 as fast as possible and perform basic threshold-based peak detection and for each peak, record the maximum amplitude seen (by taking the maximum signal amplitude seen for the entire interval the signal is over the lower threshold). The frequency of each peak-height bin is continuously updated as more signal comes in and then displayed in this plot.

The maximum resolution of my pulse-height-spectrum *should* be equal to the maximum amplitude resolution of the measurement device.

FWIW I'm using PS2000.dll 2.0.8.73 -- is there a newer version?

HTH

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Re: loss of precision during histograming

Post by ziko »

Have you tried to use PicoScope 6 and in frequency mode go to spectrum options and select Peak Hold?

Kind regards
Ziko

Technical Specialist

Post Reply