Scarab  v3.4.0
Project 8 C++ Utility Library
digital.cc
Go to the documentation of this file.
1 /*
2  * digital.c
3  *
4  * written by jared kofron <jared.kofron@gmail.com>
5  *
6  * documented prototypes are in digital.h
7  */
8 
9 #define SCARAB_API_EXPORTS
10 
11 #include "digital.hh"
12 
13 #include <cstdio>
14 
15 namespace scarab
16 {
17 
18  void get_calib_params( unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, bool bits_r_aligned, dig_calib_params *params )
19  {
20  params->bit_depth = n_bits;
21  params->levels = 1 << n_bits;
22  params->data_type_size = data_type_size;
23  params->v_range = v_range;
24  params->v_offset = v_offset;
25  params->inv_levels = 1. / (double)params->levels;
26  params->inv_v_range = 1. / params->v_range;
27  params->dac_gain = params->v_range * params->inv_levels;
28  params->bits_right_aligned = bits_r_aligned;
29  return;
30  }
31 
32  void get_calib_params2( unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, double dac_gain, bool bits_r_aligned, dig_calib_params *params )
33  {
34  params->bit_depth = n_bits;
35  params->levels = 1 << n_bits;
36  params->data_type_size = data_type_size;
37  params->v_range = v_range;
38  params->v_offset = v_offset;
39  params->inv_levels = 1. / ( double )params->levels;
40  params->inv_v_range = 1. / params->v_range;
41  params->dac_gain = dac_gain;
42  params->bits_right_aligned = bits_r_aligned;
43  return;
44  }
45 
46 }
void get_calib_params2(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, double dac_gain, bool bits_r_aligned, dig_calib_params *params)
Calculate the digitizer calibration parameters when given the DAC gain (e.g. from a digitizer&#39;s own c...
Definition: digital.cc:32
Collection of parameters used for converting between analog and digital data.
Definition: digital.hh:43
void get_calib_params(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, bool bits_r_aligned, dig_calib_params *params)
Calculate the digitizer calibration parameters with basic parameters: number of bits, Voffset, and Vrange.
Definition: digital.cc:18