Data Structures | Macros | Functions
example_vibration.c File Reference
`#include <complex.h>`
`#include <float.h>`
`#include <inttypes.h>`
`#include <math.h>`
`#include <stdbool.h>`
`#include <stddef.h>`
`#include <stdint.h>`
`#include "acc_alg_basic_utils.h"`
`#include "acc_algorithm.h"`
`#include "acc_config.h"`
`#include "acc_config_subsweep.h"`
`#include "acc_integration.h"`
`#include "acc_integration_log.h"`
`#include "acc_processing.h"`
`#include "example_vibration.h"`

Go to the source code of this file.

## Data Structures
struct | circular_float_buffer_t
struct | acc_vibration_handle

## Macros
#define | MODULE "example_vibration"
#define | RADIANS_TO_DISPLACEMENT_FACTOR (394.32604621792916f)
#define | NUM_POINTS (1U)
#define | CFAR_WINDOW_LENGTH (10U)
#define | CFAR_HALF_GUARD_LENGTH (5U)
#define | CFAR_MARGIN (CFAR_WINDOW_LENGTH + CFAR_HALF_GUARD_LENGTH)
#define | IS_POWER_OF_TWO(x) (((x) & ((x) - 1)) == 0)
#define | BOOL_TO_STR(b) (b ? "true" : "false")

## Functions
static void | circular_float_buffer_write_angle (circular_float_buffer_t *cb, float new_element)
| Write an angle (in rads) to the circular buffer. The angle will be "unwrapped" before write. More...
static float | circular_float_buffer_get (const circular_float_buffer_t *cb, uint16_t chronological_idx)
| Get an element of the circular buffer given its "age". A chronological index of 0 returns the oldest element in the buffer. More...
static bool | validate_config (const acc_vibration_config_t *config)
static bool | translate_config (const acc_vibration_config_t *config, acc_config_t *sensor_config)
static void | setup_rfft_bounds (acc_vibration_handle_t *handle, const acc_vibration_config_t *config)
static void | setup_sample_frequencies (acc_vibration_handle_t *handle, float sweep_rate)
static void | update_vibration_result (acc_vibration_handle_t *handle, acc_vibration_config_t *config, acc_vibration_result_t *result)
static float * | get_zero_mean_time_series (acc_vibration_handle_t *handle)
static void | calculate_threshold (acc_vibration_handle_t *handle, acc_vibration_config_t *config)
void | acc_vibration_preset_set (acc_vibration_config_t *config, acc_vibration_preset_t preset)
void | acc_vibration_config_log (const acc_vibration_config_t *config)
acc_vibration_handle_t * | acc_vibration_handle_create (const acc_vibration_config_t *config)
const acc_config_t * | acc_vibration_handle_sensor_config_get (acc_vibration_handle_t *handle)
const float * | acc_vibration_handle_displacement_history_get (acc_vibration_handle_t *handle, uint16_t *num_elem)
bool | acc_vibration_handle_continuous_data_acquisition_get (acc_vibration_handle_t *handle, bool *continuous_data_acquisition)
void | acc_vibration_handle_destroy (acc_vibration_handle_t *handle)
void | acc_vibration_process (acc_processing_result_t *proc_result, acc_vibration_handle_t *handle, acc_vibration_config_t *config, acc_vibration_result_t *result)

## Macro Definition Documentation

## ◆ BOOL_TO_STR

#define BOOL_TO_STR | ( |  | b | ) | (b ? "true" : "false")

Definition at line 40 of file example_vibration.c.

## ◆ CFAR_HALF_GUARD_LENGTH

#define CFAR_HALF_GUARD_LENGTH (5U)

Definition at line 36 of file example_vibration.c.

## ◆ CFAR_MARGIN

#define CFAR_MARGIN (CFAR_WINDOW_LENGTH + CFAR_HALF_GUARD_LENGTH)

Definition at line 37 of file example_vibration.c.

## ◆ CFAR_WINDOW_LENGTH

#define CFAR_WINDOW_LENGTH (10U)

Definition at line 35 of file example_vibration.c.

## ◆ IS_POWER_OF_TWO

#define IS_POWER_OF_TWO | ( |  | x | ) | (((x) & ((x) - 1)) == 0)

Definition at line 39 of file example_vibration.c.

## ◆ MODULE

#define MODULE "example_vibration"

Definition at line 24 of file example_vibration.c.

## ◆ NUM_POINTS

#define NUM_POINTS (1U)

Definition at line 34 of file example_vibration.c.

## ◆ RADIANS_TO_DISPLACEMENT_FACTOR

#define RADIANS_TO_DISPLACEMENT_FACTOR (394.32604621792916f)

/ c/f \ | ----— | * 1e6 with c = 299792458 m/s,

## \ 2 / f = 60.5 GHz

2 pi

Definition at line 32 of file example_vibration.c.

## Function Documentation

## ◆ acc_vibration_config_log()

void acc_vibration_config_log | ( | const acc_vibration_config_t * | config | ) |

Parameters

  [in] | config | The config to log

Definition at line 170 of file example_vibration.c.

## ◆ acc_vibration_handle_continuous_data_acquisition_get()

bool acc_vibration_handle_continuous_data_acquisition_get | ( | acc_vibration_handle_t * | handle,
|  | bool * | continuous_data_acquisition
| ) |  |

Parameters

  [in] | handle | A handle to get the internal setting from
  [out] | continuous_data_acquisition | Wether continuous data acquisition is enabled

Returns
  True is arguments are non-NULL, false otherwise

Definition at line 369 of file example_vibration.c.

## ◆ acc_vibration_handle_create()

acc_vibration_handle_t* acc_vibration_handle_create | ( | const acc_vibration_config_t * | config | ) |

Parameters

  [in] | config | A vibration app config to set default settings to.

Returns
  A vibration processing handle

Definition at line 233 of file example_vibration.c.

## ◆ acc_vibration_handle_destroy()

void acc_vibration_handle_destroy | ( | acc_vibration_handle_t * | handle | ) |

Parameters

  [in] | handle | The vibration handle to destroy

Definition at line 381 of file example_vibration.c.

## ◆ acc_vibration_handle_displacement_history_get()

const float* acc_vibration_handle_displacement_history_get | ( | acc_vibration_handle_t * | handle,
|  | uint16_t * | num_elem
| ) |  |

Parameters

  [in] | handle | A handle to get the internal displacement history from
  [out] | num_elem | The number of elements in the returned array

Returns
  An array with displacements if arguments are non-NULL

Definition at line 355 of file example_vibration.c.

## ◆ acc_vibration_handle_sensor_config_get()

const acc_config_t* acc_vibration_handle_sensor_config_get | ( | acc_vibration_handle_t * | handle | ) |

Parameters

  [in] | handle | The handle

Returns
  pointer to a sensor config corresponding to the vibration config 'handle' was created with.

Definition at line 350 of file example_vibration.c.

## ◆ acc_vibration_preset_set()

void acc_vibration_preset_set | ( | acc_vibration_config_t * | config,
|  | acc_vibration_preset_t | preset
| ) |  |

Parameters

  [out] | config | The vibration config to set a preset for
  [in] | preset | The preset

Definition at line 115 of file example_vibration.c.

## ◆ acc_vibration_process()

void acc_vibration_process | ( | acc_processing_result_t * | proc_result,
|  | acc_vibration_handle_t * | handle,
|  | acc_vibration_config_t * | config,
|  | acc_vibration_result_t * | result
| ) |  |

Parameters

  [in] | proc_result | Input for vibration processing
  [in] | handle | The vibration processing handle
  [in] | config | The vibration app config
  [out] | result | The vibration processing result

Definition at line 437 of file example_vibration.c.

## ◆ calculate_threshold()

static void calculate_threshold | ( | acc_vibration_handle_t * | handle,
|  | acc_vibration_config_t * | config
| ) |  |
| static

Definition at line 734 of file example_vibration.c.

## ◆ circular_float_buffer_get()

static float circular_float_buffer_get | ( | const circular_float_buffer_t * | cb,
|  | uint16_t | chronological_idx
| ) |  |
| static

Get an element of the circular buffer given its "age". A chronological index of 0 returns the oldest element in the buffer.

Definition at line 568 of file example_vibration.c.

## ◆ circular_float_buffer_write_angle()

static void circular_float_buffer_write_angle | ( | circular_float_buffer_t * | cb,
|  | float | new_element
| ) |  |
| static

Write an angle (in rads) to the circular buffer. The angle will be "unwrapped" before write.

Definition at line 558 of file example_vibration.c.

## ◆ get_zero_mean_time_series()

static float * get_zero_mean_time_series | ( | acc_vibration_handle_t * | handle | ) |
| static

Definition at line 715 of file example_vibration.c.

## ◆ setup_rfft_bounds()

static void setup_rfft_bounds | ( | acc_vibration_handle_t * | handle,
|  | const acc_vibration_config_t * | config
| ) |  |
| static

Definition at line 799 of file example_vibration.c.

## ◆ setup_sample_frequencies()

static void setup_sample_frequencies | ( | acc_vibration_handle_t * | handle,
|  | float | sweep_rate
| ) |  |
| static

Definition at line 669 of file example_vibration.c.

## ◆ translate_config()

static bool translate_config | ( | const acc_vibration_config_t * | config,
|  | acc_config_t * | sensor_config
| ) |  |
| static

Definition at line 612 of file example_vibration.c.

## ◆ update_vibration_result()

static void update_vibration_result | ( | acc_vibration_handle_t * | handle,
|  | acc_vibration_config_t * | config,
|  | acc_vibration_result_t * | result
| ) |  |
| static

Definition at line 676 of file example_vibration.c.

## ◆ validate_config()

static bool validate_config | ( | const acc_vibration_config_t * | config | ) |
| static

Definition at line 580 of file example_vibration.c.