Current Ranger Sample Rate

Started by d72huang, March 10, 2025, 08:12:27 PM

d72huang

I was wondering what the sample rate in Hz is the current ranger?

Felix


d72huang

Just to confirm then the ADC samples data at around 1-2 kHz.

Felix

The CurrentRanger samples data internally, then outputs data to USB at the fastest rate is able to.

d72huang

Was wondering what that internal sample rate is. Just a little more context, we are using the current ranger to measure a current through a device and a sweep of voltages and wanted to ensure that the number of data points coming out from the current ranger is synced with the voltage source device we are using. However currently, the number of data points is off and the current ranger seems to be outputting more data points than the actual sweep itself, so I was curious to know if there were any adjustments that we could make to either device that might be able to sync it up. Thank you for all the help.

Felix

By default there is a certain sampling speed and averaging in the internal ADC, to achieve a good balance between accuracy and the output rate over serial.

However there is the 's' option which will toggle between ADC sampling speeds. There is a tradeoff between speed and accuracy (ie more or less sampling averaging).
You can see all the options available through the '?' (brings up the Menu), see this page for that.
Otherwise you can modify the given firmware if you wish, to achieve specific sampling speed or perhaps sync up the sampling with an external event - you could leverage the GPIO pin header for this purpose but you'd have to be careful to avoid ground loops when you interface that to your DUT or other external device that might be grounded at a different potential.

d72huang

For each of the toggles (ie average, fast, slow) what are the numerical frequency values for them? I have seen in the software that there could be a combination for 1024 samples to average, but I was wondering if there could be some clarification as to what that meant. Thank you for all the help.

Felix

There are several registers involved in determining the ADC speed. The ADC has a clock prescaler, sample control, average control registers.
So there is not 1 number for each "sampling speed" that we choose in the CR menu.
One could adjust the ADC in many different ways using the registers directly but to make things easy there are only these 3 modes available to the user "out of box".
To really determine the speed you'd have to do the math that's involved with all the clocking prescaling and then the specific ADC registers to get an actual ADC sampling frequency.
So the ADC will take many readings and then do some averaging before you see a reading on the serial port.
So the closest to having an ADC output frequency will be to just take a window of time and count the readings on the serial port.

d72huang

As we are currently using a device to sweep voltage from -2V to 2V in 100 steps to our DUT, the amount of total datapoints outputted by the CR is much greater than this (around 5000 datapoints right now). Was wondering if there were some suggestions on things that could be changed on the CR to be able to match the amount of datapoints.

Felix

You mean to specify how many data points per time unit should be output? Something like 100samples/s?
What would be your target samples/s? Is it variable?

d72huang

I can change the step size of the voltage sweep. But based on current measurements I believe it's roughly 10samples/second from the voltage sweep.

Felix

It's possible but it would require a change in firmware to adjust the sample rate either directly in the ADC or only output the readings at the requested sample rate (and anything in between to be discarded).
In most instances the more data you get the better, and for the CurrentRanger, we usually look for fast current transients that might be hidden in the otherwise more constant current that a DUT is drawing.

d72huang

Thank you for the information. For the firmware adjustments where would be a good place to start with those?

Felix

The datasheet is a good place, ch33 - page 781.

If you'd like to just poke around and see the effects, a good shortcut is to check out the definitions for the ADC prescaler and sample control, comments are suggestive:

#define ADC_PRESCALER          ADC_CTRLB_PRESCALER_DIV16
//#define ADC_AVGCTRL            ADC_AVGCTRL_SAMPLENUM_128 | ADC_AVGCTRL_ADJRES(0x4ul)
                               //ADC_AVGCTRL_SAMPLENUM_1 | ADC_AVGCTRL_ADJRES(0x00ul);  // take 1 sample, adjusting result by 0
                               //ADC_AVGCTRL_SAMPLENUM_16 | ADC_AVGCTRL_ADJRES(0x4ul); //take 16 samples adjust by 4
                               //ADC_AVGCTRL_SAMPLENUM_256 | ADC_AVGCTRL_ADJRES(0x4ul); //take 256 samples adjust by 4
                               //ADC_AVGCTRL_SAMPLENUM_512 | ADC_AVGCTRL_ADJRES(0x4ul); //take 512 samples adjust by 4
                               //ADC_AVGCTRL_SAMPLENUM_1024 | ADC_AVGCTRL_ADJRES(0x4ul); //take 1024 samples adjust by 4
#define ADC_SAMPCTRL           0b111 //sample timing [fast 0..0b111 slow]