units of calibration coefficients?

Just about everything about Red Pitaya
Post Reply
Hylocereus
Posts: 1
Joined: Thu Oct 15, 2015 4:52 pm

units of calibration coefficients?

Post by Hylocereus » Thu Oct 15, 2015 5:15 pm

Hey pitaya users,

i am about to calibrate my pitaya and i don't fully understand the calibration vector you get with the "calib -r -v" command.
I understand the offset calibration as it is described in the user manual but what about the "full scale coefficients"?

FE_CH1_FS_G_HI = 45870551 # Front-End Channel1 full scale coefficient for High gain (LV) jumper configuration.
FE_CH2_FS_G_HI = 45870551 # Front-End Channel2 full scale coefficient for High gain (LV) jumper configuration.

What are the units of these numbers? I expect something like "samples per volts" but the number is much larger.
So if you acquire a measured number of samples with the "acquire" command, how do you compute a measured voltage out of it with this coefficient and the offset?

I would really appreciate any help on this.
Regards

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: units of calibration coefficients?

Post by Nils Roos » Thu Oct 15, 2015 8:15 pm

These are the sections of code that transform samples to voltages by way of the calibration values:

Code: Select all

float sample_to_voltage(int sample) {
	float voltage, ch1_max_adc_v;
	uint32_t fe_fsg1;

	fe_fsg1 = (curr_params[GAIN_CH1].value == 0) ? rp_calib_params->fe_ch1_fs_g_hi
	                                             : rp_calib_params->fe_ch1_fs_g_lo;

	ch1_max_adc_v = osc_fpga_calc_adc_max_v(fe_fsg1, (int)curr_params[PRB_ATT_CH1].value);

	voltage = osc_fpga_cnv_cnt_to_v(sample, ch1_max_adc_v, rp_calib_params->fe_ch1_dc_offs, 0);

	return voltage;
}

/*----------------------------------------------------------------------------*/
/**
 * @brief Converts ADC counts to voltage [V]
 *
 * Function is used to publish captured signal data to external world in user units.
 * Calculation is based on maximal voltage, which can be applied on ADC inputs and
 * calibrated and user defined DC offsets.
 *
 * @param[in] cnts           Captured Signal Value, expressed in ADC counts
 * @param[in] adc_max_v      Maximal ADC voltage, specified in [V]
 * @param[in] calib_dc_off   Calibrated DC offset, specified in ADC counts
 * @param[in] user_dc_off    User specified DC offset, specified in [V]
 * @retval    float          Signal Value, expressed in user units [V]
 */
float osc_fpga_cnv_cnt_to_v(int cnts, float adc_max_v,
                            int calib_dc_off, float user_dc_off)
{
    int m;
    float ret_val;

    /* check sign */
    if(cnts & (1<<(c_osc_fpga_adc_bits-1))) {
        /* negative number */
        m = -1 *((cnts ^ ((1<<c_osc_fpga_adc_bits)-1)) + 1);
    } else {
        /* positive number */
        m = cnts;
    }

    /* adopt ADC count with calibrated DC offset */
    m += calib_dc_off;

    /* map ADC counts into user units */
    if(m < (-1 * (1<<(c_osc_fpga_adc_bits-1))))
        m = (-1 * (1<<(c_osc_fpga_adc_bits-1)));
    else if(m > (1<<(c_osc_fpga_adc_bits-1)))
        m =  (1<<(c_osc_fpga_adc_bits-1));

    ret_val =  (m * adc_max_v / 
                (float)(1<<(c_osc_fpga_adc_bits-1)));

    /* and adopt the calculation with user specified DC offset */
    ret_val += user_dc_off;

    return ret_val;
}

/*----------------------------------------------------------------------------*/
/**
 * @brief Calculates maximum [V] in respect to set & calibration parameters
 *
 * Function is used to calculate the maximal voltage which can be applied on ADC inputs.
 * This calculation is based on calibrated Front End Full Scale Gain setting and configured
 * Probe Attenuation.
 *
 * @param[in] fe_gain_fs     Front End Full Scale Gain
 * @param[in] probe_att      Probe attenuation
 * @retval    float          Maximum voltage, expressed in [V]
 */
float osc_fpga_calc_adc_max_v(uint32_t fe_gain_fs, int probe_att)
{
    float max_adc_v;
    int probe_att_fact = (probe_att > 0) ? 10 : 1;

    max_adc_v = 
        fe_gain_fs/(float)((uint64_t)1<<32) * 100 * (probe_att_fact);

    return max_adc_v;
}
(pieced together from the scope app's worker.c and fpga.c , see there for the missing constants, types and parameters)

The unit of the calibration value 'full scale coefficient' is V/cnt , but there are some constants factored into it. This is why its magnitude seems kind of arbitrary.

edgo
Posts: 34
Joined: Wed Jun 25, 2014 11:38 pm

Re: units of calibration coefficients?

Post by edgo » Thu Oct 15, 2015 8:37 pm

viewtopic.php?f=14&t=510

You may find my calibration utility helpful

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 110 guests