-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththorax_digital.hh
More file actions
90 lines (75 loc) · 2.97 KB
/
Copy paththorax_digital.hh
File metadata and controls
90 lines (75 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* digital.h
*
* written by jared kofron <jared.kofron@gmail.com>
*
* functions for converting from D2A and A2D. prototypes are declared in
* digital.h. versions are included for both floats and doubles. there are
* two styles of the functions inspired by the GSL way of doing things - a
* normal version which returns the simple type of interest, and an 'error'
* version which can return information about bad arguments.
*/
#ifndef THORAX_DIGITAL_H_
#define THORAX_DIGITAL_H_
#include "thorax_types.hh"
#include <ostream>
namespace thorax
{
/*
* the signatec PX1500 is an 8 bit digitizer
*/
#define px1500_bits 8
#define px1500_data_type_size 1
#define px1500_min_val -0.25
#define px1500_max_val 0.25
#define px1500_range (px1500_max_val - px1500_min_val)
/*
* the signatec PX14400 is an 14 bit digitizer
*/
#define px14400_bits 14
#define px14400_data_type_size 2
#define px14400_min_val -0.25
#define px14400_max_val 0.25
#define px14400_range (px1500_max_val - px1500_min_val)
struct dig_calib_params
{
unsigned bit_depth;
unsigned levels;
unsigned data_type_size;
double v_range;
double v_offset;
double inv_levels;
double inv_v_range;
double dac_gain;
bool bits_right_aligned;
};
/*
* the Keysight U1084A is an 8 bit digitizer
*/
#define u1084a_bits 8
#define u1084a_data_type_size 1
#define u1084a_min_val -0.25
#define u1084a_max_val 0.25
#define u1084a_range (u1084a_max_val - u1084a_min_val)
THORAX_API void get_calib_params( unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, bool bits_r_aligned, struct dig_calib_params *params );
THORAX_API void get_calib_params2( unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, double dac_gain, bool bits_r_aligned, struct dig_calib_params *params );
THORAX_API void get_px1500_calib_params( struct dig_calib_params *params );
THORAX_API void get_px14400_calib_params( struct dig_calib_params *params );
THORAX_API void get_u1084a_calib_params( struct dig_calib_params *params );
/*
* convert a digital <=64 bit value to a double or float.
*/
THORAX_API float d2a_uf( uint64_t dig, const struct dig_calib_params* params );
THORAX_API double d2a_ud( uint64_t dig, const struct dig_calib_params* params );
THORAX_API float d2a_if( int64_t dig, const struct dig_calib_params* params );
THORAX_API double d2a_id( int64_t dig, const struct dig_calib_params* params );
// fd2a and dd2a are deprecated; use d2a_uf and d2a_ud instead
THORAX_API float fd2a( uint64_t dig, const struct dig_calib_params* params );
THORAX_API double dd2a( uint64_t dig, const struct dig_calib_params* params );
/*
* convert an analog val;ue to a digital value.
*/
THORAX_API uint64_t a2d( double analog, const struct dig_calib_params* params );
THORAX_API std::ostream& operator<<( std::ostream& out, const dig_calib_params& params );
}
#endif // THORAX_DIGITAL_H_