no-OS
Loading...
Searching...
No Matches
powrms_data_processing.c File Reference

POWRMS data processing source file for POWRMS project. More...

#include "powrms_data_processing.h"
#include <math.h>
Include dependency graph for powrms_data_processing.c:

Functions

void update_values_of_digit (struct powrms_variables *input_var, uint8_t increment_pos)
 Update the value of a specific digit in the input variable.
 
void update_values_from_new_value (struct powrms_variables *input_var, double new_value)
 Update the digits array based on a new value.
 
void sync_all_digits_from_values (void)
 Synchronize all input variables' digits arrays with their current values.
 
int _calc_interpolating_values (double *x_values, double *y_values, double *x_values_rev, double *y_values_rev, uint8_t freq_index, uint32_t local_frequency_MHz, float *position)
 
int _calc_temp_coefficients (float *temp_coeffs, uint8_t freq_index)
 
int32_t _cubic_function (float v_tmp, float a1, float a2, float a3)
 
double _Lagrange_interpolaiton (double *x_values, double *y_values, uint8_t points_number, double x_input)
 
double _correct_newtone (double newtone_meas, int32_t freq_MHz)
 
double _correct_newtone_3rd_order (double newtone_meas, int32_t freq_MHz, bool reverse)
 
int calculate_power ()
 

Variables

int32_t use_eeprom_calibration_data = 0
 
uint32_t frequency_MHz_ranges [FREQUENCY_RANGE_NR]
 
volatile struct adc_data adc_data_input
 
struct powrms_variables input_variables [VARIABLE_NUMBER]
 
int32_t precision_values [PRECISION_ARRAY_SIZE]
 
int32_t precision_values_reverse [PRECISION_ARRAY_SIZE]
 
double poly_5000MHz_intercept = 0
 
double poly_5000MHz_c_x = 0
 
double poly_5000MHz_c_f = 0
 
double poly_5000MHz_c_x2 = 0
 
double poly_5000MHz_c_xf = 0
 
double poly_5000MHz_c_f2 = 0
 
double poly_5000MHz_c_x3 = 0
 
double poly_5000MHz_c_x2f = 0
 
double poly_5000MHz_c_xf2 = 0
 
double poly_5000MHz_c_f3 = 0
 
double poly_5000MHz_intercept_reverse = 0
 
double poly_5000MHz_c_x_reverse = 0
 
double poly_5000MHz_c_f_reverse = 0
 
double poly_5000MHz_c_x2_reverse = 0
 
double poly_5000MHz_c_xf_reverse = 0
 
double poly_5000MHz_c_f2_reverse = 0
 
double poly_5000MHz_c_x3_reverse = 0
 
double poly_5000MHz_c_x2f_reverse = 0
 
double poly_5000MHz_c_xf2_reverse = 0
 
double poly_5000MHz_c_f3_reverse = 0
 
double temperature_precision_values [TEMPERATURE_CORRECTION_COEFFS *FREQUENCY_RANGE_NR]
 
int32_t temperature_compensation_value
 

Detailed Description

POWRMS data processing source file for POWRMS project.

Author
Robert Budai (rober.nosp@m.t.bu.nosp@m.dai@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2025(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ _calc_interpolating_values()

int _calc_interpolating_values ( double * x_values,
double * y_values,
double * x_values_rev,
double * y_values_rev,
uint8_t freq_index,
uint32_t local_frequency_MHz,
float * position )

◆ _calc_temp_coefficients()

int _calc_temp_coefficients ( float * temp_coeffs,
uint8_t freq_index )

◆ _correct_newtone()

double _correct_newtone ( double newtone_meas,
int32_t freq_MHz )

◆ _correct_newtone_3rd_order()

double _correct_newtone_3rd_order ( double newtone_meas,
int32_t freq_MHz,
bool reverse )

◆ _cubic_function()

int32_t _cubic_function ( float v_tmp,
float a1,
float a2,
float a3 )

◆ _Lagrange_interpolaiton()

double _Lagrange_interpolaiton ( double * x_values,
double * y_values,
uint8_t points_number,
double x_input )

◆ calculate_power()

int calculate_power ( )

◆ sync_all_digits_from_values()

void sync_all_digits_from_values ( void )

Synchronize all input variables' digits arrays with their current values.

This function updates the digits array for all input variables based on their current value field. Useful after loading values from EEPROM or other external sources that modify the value but not the digits.

◆ update_values_from_new_value()

void update_values_from_new_value ( struct powrms_variables * input_var,
double new_value )

Update the digits array based on a new value.

Parameters
input_varPointer to the variable structure to update
new_valueThe new value to set (will be clamped to valid range)

◆ update_values_of_digit()

void update_values_of_digit ( struct powrms_variables * input_var,
uint8_t increment_pos )

Update the value of a specific digit in the input variable.

Update the value of an input variable based on digit increment.

Variable Documentation

◆ adc_data_input

volatile struct adc_data adc_data_input
Initial value:
= {
.adc_averaging_nr = 1,
.adc_p_fwd_raw = 0.0,
.adc_p_rev_raw = 0.0,
.adc_vin0_voltage = 0.0,
.adc_vin1_voltage = 0.0,
.adc_vin2_voltage = 0.0,
.adc_vin3_voltage = 0.0,
}

◆ frequency_MHz_ranges

uint32_t frequency_MHz_ranges[FREQUENCY_RANGE_NR]
Initial value:
= {
10,
100,
1000,
2000,
3000,
4000,
5000,
5250,
5500,
5750,
6000,
}

◆ input_variables

struct powrms_variables input_variables[VARIABLE_NUMBER]

◆ poly_5000MHz_c_f

double poly_5000MHz_c_f = 0

◆ poly_5000MHz_c_f2

double poly_5000MHz_c_f2 = 0

◆ poly_5000MHz_c_f2_reverse

double poly_5000MHz_c_f2_reverse = 0

◆ poly_5000MHz_c_f3

double poly_5000MHz_c_f3 = 0

◆ poly_5000MHz_c_f3_reverse

double poly_5000MHz_c_f3_reverse = 0

◆ poly_5000MHz_c_f_reverse

double poly_5000MHz_c_f_reverse = 0

◆ poly_5000MHz_c_x

double poly_5000MHz_c_x = 0

◆ poly_5000MHz_c_x2

double poly_5000MHz_c_x2 = 0

◆ poly_5000MHz_c_x2_reverse

double poly_5000MHz_c_x2_reverse = 0

◆ poly_5000MHz_c_x2f

double poly_5000MHz_c_x2f = 0

◆ poly_5000MHz_c_x2f_reverse

double poly_5000MHz_c_x2f_reverse = 0

◆ poly_5000MHz_c_x3

double poly_5000MHz_c_x3 = 0

◆ poly_5000MHz_c_x3_reverse

double poly_5000MHz_c_x3_reverse = 0

◆ poly_5000MHz_c_x_reverse

double poly_5000MHz_c_x_reverse = 0

◆ poly_5000MHz_c_xf

double poly_5000MHz_c_xf = 0

◆ poly_5000MHz_c_xf2

double poly_5000MHz_c_xf2 = 0

◆ poly_5000MHz_c_xf2_reverse

double poly_5000MHz_c_xf2_reverse = 0

◆ poly_5000MHz_c_xf_reverse

double poly_5000MHz_c_xf_reverse = 0

◆ poly_5000MHz_intercept

double poly_5000MHz_intercept = 0

◆ poly_5000MHz_intercept_reverse

double poly_5000MHz_intercept_reverse = 0

◆ precision_values

int32_t precision_values[PRECISION_ARRAY_SIZE]

◆ precision_values_reverse

int32_t precision_values_reverse[PRECISION_ARRAY_SIZE]

◆ temperature_compensation_value

int32_t temperature_compensation_value

◆ temperature_precision_values

double temperature_precision_values[TEMPERATURE_CORRECTION_COEFFS * FREQUENCY_RANGE_NR]
Initial value:
= {
0.09907037, -0.006107942, -0.0176689,
0.5951664, -0.409783, 0.08516236,
-0.9938435, 0.6969325, -0.168762,
0.08790697, -0.09423475, 0.01784584,
1.005991, -0.5792234, 0.08180364,
-6.526894, 4.923146, -1.258186,
6.637077, -4.713627, 1.078375,
6.637077, -4.713627, 1.078375,
6.637077, -4.713627, 1.078375,
6.637077, -4.713627, 1.078375,
-3.673048, 2.75258, -0.7360349,
}

◆ use_eeprom_calibration_data

int32_t use_eeprom_calibration_data = 0