The project is a fast lock in amplifier (LIA) which can update its output at rate of 1000 measurements/s. It performs digital dual mixing and filtering to obtain a DC value proportional to the AC input signal.
main.h@5:68719e34a4ce, 2017-09-22 (annotated)
- Committer:
- Nikollao
- Date:
- Fri Sep 22 09:28:39 2017 +0000
- Revision:
- 5:68719e34a4ce
- Parent:
- 3:dd4eb355f8d9
Fast Lock In Amplifier published code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nikollao | 0:4e20939af8bb | 1 | /** |
Nikollao | 0:4e20939af8bb | 2 | @file main.h |
Nikollao | 0:4e20939af8bb | 3 | @brief Header file contains functions and variables |
Nikollao | 0:4e20939af8bb | 4 | @brief Fast Lock-In Amplifier - AC to DC converter |
Nikollao | 0:4e20939af8bb | 5 | @brief Revision 1.0 |
Nikollao | 0:4e20939af8bb | 6 | @author Nikollao Sulollari |
Nikollao | 0:4e20939af8bb | 7 | @Date 16/08/2017 |
Nikollao | 0:4e20939af8bb | 8 | */ |
Nikollao | 0:4e20939af8bb | 9 | |
Nikollao | 0:4e20939af8bb | 10 | #ifndef MAIN_H |
Nikollao | 0:4e20939af8bb | 11 | #define MAIN_H |
Nikollao | 0:4e20939af8bb | 12 | #include "mbed.h" |
Nikollao | 1:bf693859586c | 13 | #include "N5110.h" |
Nikollao | 0:4e20939af8bb | 14 | |
Nikollao | 0:4e20939af8bb | 15 | #define DIRECTION_TOLERANCE 0.05 |
Nikollao | 0:4e20939af8bb | 16 | |
Nikollao | 0:4e20939af8bb | 17 | /** |
Nikollao | 0:4e20939af8bb | 18 | @namespace aout |
Nikollao | 0:4e20939af8bb | 19 | @brief Analog output DC filtered value |
Nikollao | 0:4e20939af8bb | 20 | */ |
Nikollao | 0:4e20939af8bb | 21 | AnalogOut aout(DAC0_OUT); |
Nikollao | 0:4e20939af8bb | 22 | |
Nikollao | 0:4e20939af8bb | 23 | /** |
Nikollao | 0:4e20939af8bb | 24 | @namespace gpo |
Nikollao | 0:4e20939af8bb | 25 | @brief Digital output set the D0 pin High/Low |
Nikollao | 0:4e20939af8bb | 26 | */ |
Nikollao | 0:4e20939af8bb | 27 | DigitalOut gpo(D0); |
Nikollao | 0:4e20939af8bb | 28 | |
Nikollao | 0:4e20939af8bb | 29 | /** |
Nikollao | 0:4e20939af8bb | 30 | @namespace ain |
Nikollao | 0:4e20939af8bb | 31 | @brief analog input which is the signal from the bolometer (THz detector) |
Nikollao | 0:4e20939af8bb | 32 | */ |
Nikollao | 1:bf693859586c | 33 | AnalogIn ain(A5); |
Nikollao | 0:4e20939af8bb | 34 | |
Nikollao | 0:4e20939af8bb | 35 | /** |
Nikollao | 0:4e20939af8bb | 36 | @namespace dref |
Nikollao | 0:4e20939af8bb | 37 | @brief event triggered interrupt used to calculate the reference frequency |
Nikollao | 0:4e20939af8bb | 38 | */ |
Nikollao | 0:4e20939af8bb | 39 | InterruptIn dref(D6); |
Nikollao | 0:4e20939af8bb | 40 | |
Nikollao | 0:4e20939af8bb | 41 | /** |
Nikollao | 2:c9b24787d5e1 | 42 | @namespace menu_ticker |
Nikollao | 2:c9b24787d5e1 | 43 | @brief time-triggered interrupt to update the menu of the LIA |
Nikollao | 2:c9b24787d5e1 | 44 | */ |
Nikollao | 2:c9b24787d5e1 | 45 | Ticker menu_ticker; |
Nikollao | 2:c9b24787d5e1 | 46 | |
Nikollao | 2:c9b24787d5e1 | 47 | /** |
Nikollao | 0:4e20939af8bb | 48 | @namespace amp_ticker |
Nikollao | 1:bf693859586c | 49 | @brief time-triggered interrupt calculates the offset of the input signal |
Nikollao | 0:4e20939af8bb | 50 | */ |
Nikollao | 0:4e20939af8bb | 51 | Ticker offset_ticker; |
Nikollao | 0:4e20939af8bb | 52 | |
Nikollao | 0:4e20939af8bb | 53 | /** |
Nikollao | 0:4e20939af8bb | 54 | @namespace sample_ticker |
Nikollao | 0:4e20939af8bb | 55 | @brief time-triggered interrupt samples internal sine and cosine signals |
Nikollao | 0:4e20939af8bb | 56 | */ |
Nikollao | 0:4e20939af8bb | 57 | Ticker sample_ticker; |
Nikollao | 0:4e20939af8bb | 58 | |
Nikollao | 0:4e20939af8bb | 59 | /** |
Nikollao | 0:4e20939af8bb | 60 | @namespace output_ticker |
Nikollao | 0:4e20939af8bb | 61 | @brief time-triggered interrupt updates the output of Fast LIA |
Nikollao | 0:4e20939af8bb | 62 | */ |
Nikollao | 0:4e20939af8bb | 63 | Ticker output_ticker; |
Nikollao | 0:4e20939af8bb | 64 | |
Nikollao | 0:4e20939af8bb | 65 | /** |
Nikollao | 0:4e20939af8bb | 66 | @namespace period_timer |
Nikollao | 0:4e20939af8bb | 67 | @brief timer is used to calculate the frequency of the input square wave |
Nikollao | 0:4e20939af8bb | 68 | */ |
Nikollao | 0:4e20939af8bb | 69 | Timer period_timer; |
Nikollao | 0:4e20939af8bb | 70 | |
Nikollao | 0:4e20939af8bb | 71 | |
Nikollao | 0:4e20939af8bb | 72 | /** |
Nikollao | 0:4e20939af8bb | 73 | @namespace period_timer |
Nikollao | 0:4e20939af8bb | 74 | @brief timer updates the output of the LIA depending on the time constant |
Nikollao | 0:4e20939af8bb | 75 | */ |
Nikollao | 0:4e20939af8bb | 76 | Timer output_timer; |
Nikollao | 0:4e20939af8bb | 77 | /** |
Nikollao | 0:4e20939af8bb | 78 | @namespace lcd |
Nikollao | 0:4e20939af8bb | 79 | @brief object of the N5110 class |
Nikollao | 0:4e20939af8bb | 80 | */ |
Nikollao | 1:bf693859586c | 81 | N5110 lcd(PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3); |
Nikollao | 0:4e20939af8bb | 82 | |
Nikollao | 0:4e20939af8bb | 83 | |
Nikollao | 0:4e20939af8bb | 84 | /** |
Nikollao | 0:4e20939af8bb | 85 | @namespace pc |
Nikollao | 0:4e20939af8bb | 86 | @brief serial connection between mbed and pc |
Nikollao | 0:4e20939af8bb | 87 | */ |
Nikollao | 0:4e20939af8bb | 88 | Serial pc(USBTX,USBRX); |
Nikollao | 0:4e20939af8bb | 89 | |
Nikollao | 0:4e20939af8bb | 90 | /** |
Nikollao | 2:c9b24787d5e1 | 91 | @namespace xPot |
Nikollao | 2:c9b24787d5e1 | 92 | @brief read x-axis position from the value of the joystick |
Nikollao | 2:c9b24787d5e1 | 93 | */ |
Nikollao | 2:c9b24787d5e1 | 94 | AnalogIn xPot(PTB2); |
Nikollao | 2:c9b24787d5e1 | 95 | |
Nikollao | 2:c9b24787d5e1 | 96 | /** |
Nikollao | 2:c9b24787d5e1 | 97 | @namespace yPot |
Nikollao | 2:c9b24787d5e1 | 98 | @brief read y-axis position from the value of the joystick |
Nikollao | 2:c9b24787d5e1 | 99 | */ |
Nikollao | 2:c9b24787d5e1 | 100 | AnalogIn yPot(PTB3); |
Nikollao | 2:c9b24787d5e1 | 101 | |
Nikollao | 2:c9b24787d5e1 | 102 | /** |
Nikollao | 3:dd4eb355f8d9 | 103 | @namespace joyButton |
Nikollao | 3:dd4eb355f8d9 | 104 | @brief interrupt executes an event triggered task when joyButton is pressed |
Nikollao | 2:c9b24787d5e1 | 105 | */ |
Nikollao | 3:dd4eb355f8d9 | 106 | InterruptIn joyButton(PTB11); |
Nikollao | 3:dd4eb355f8d9 | 107 | |
Nikollao | 3:dd4eb355f8d9 | 108 | /** |
Nikollao | 3:dd4eb355f8d9 | 109 | @namespace swButton |
Nikollao | 3:dd4eb355f8d9 | 110 | @brief interrupt executes an event triggered task |
Nikollao | 3:dd4eb355f8d9 | 111 | */ |
Nikollao | 3:dd4eb355f8d9 | 112 | InterruptIn swButton(PTB18); |
Nikollao | 2:c9b24787d5e1 | 113 | |
Nikollao | 2:c9b24787d5e1 | 114 | /** |
Nikollao | 0:4e20939af8bb | 115 | @namespace DirectionName |
Nikollao | 0:4e20939af8bb | 116 | @brief define joystick's direction based on its x,y values |
Nikollao | 0:4e20939af8bb | 117 | */ |
Nikollao | 0:4e20939af8bb | 118 | enum DirectionName { |
Nikollao | 0:4e20939af8bb | 119 | UP, |
Nikollao | 0:4e20939af8bb | 120 | DOWN, |
Nikollao | 0:4e20939af8bb | 121 | LEFT, |
Nikollao | 0:4e20939af8bb | 122 | RIGHT, |
Nikollao | 0:4e20939af8bb | 123 | CENTRE, |
Nikollao | 0:4e20939af8bb | 124 | }; |
Nikollao | 0:4e20939af8bb | 125 | |
Nikollao | 0:4e20939af8bb | 126 | /** |
Nikollao | 0:4e20939af8bb | 127 | @namespace Joystick |
Nikollao | 0:4e20939af8bb | 128 | @brief create strcut Joystick |
Nikollao | 0:4e20939af8bb | 129 | */ |
Nikollao | 0:4e20939af8bb | 130 | typedef struct JoyStick Joystick; |
Nikollao | 0:4e20939af8bb | 131 | struct JoyStick { |
Nikollao | 0:4e20939af8bb | 132 | double x; /// current x value |
Nikollao | 0:4e20939af8bb | 133 | double x0; /// 'centred' x value |
Nikollao | 0:4e20939af8bb | 134 | double y; /// current y value |
Nikollao | 0:4e20939af8bb | 135 | double y0; /// 'centred' y value |
Nikollao | 0:4e20939af8bb | 136 | int button; /// button state (assume pull-down used, so 1 = pressed, 0 = unpressed) |
Nikollao | 0:4e20939af8bb | 137 | DirectionName direction; // current direction |
Nikollao | 0:4e20939af8bb | 138 | }; |
Nikollao | 0:4e20939af8bb | 139 | /// create struct variable |
Nikollao | 0:4e20939af8bb | 140 | Joystick joystick; |
Nikollao | 0:4e20939af8bb | 141 | |
Nikollao | 0:4e20939af8bb | 142 | /** |
Nikollao | 2:c9b24787d5e1 | 143 | update position of joystick |
Nikollao | 2:c9b24787d5e1 | 144 | */ |
Nikollao | 2:c9b24787d5e1 | 145 | void updateJoystick(); |
Nikollao | 2:c9b24787d5e1 | 146 | |
Nikollao | 2:c9b24787d5e1 | 147 | /** |
Nikollao | 2:c9b24787d5e1 | 148 | set origin of joystick |
Nikollao | 2:c9b24787d5e1 | 149 | */ |
Nikollao | 2:c9b24787d5e1 | 150 | void calibrateJoystick(); |
Nikollao | 2:c9b24787d5e1 | 151 | |
Nikollao | 2:c9b24787d5e1 | 152 | /** |
Nikollao | 0:4e20939af8bb | 153 | set-up serial port |
Nikollao | 0:4e20939af8bb | 154 | */ |
Nikollao | 0:4e20939af8bb | 155 | void init_serial(); |
Nikollao | 0:4e20939af8bb | 156 | |
Nikollao | 0:4e20939af8bb | 157 | /** |
Nikollao | 2:c9b24787d5e1 | 158 | initialise lcd |
Nikollao | 2:c9b24787d5e1 | 159 | */ |
Nikollao | 2:c9b24787d5e1 | 160 | void lcd_intro(); |
Nikollao | 2:c9b24787d5e1 | 161 | |
Nikollao | 2:c9b24787d5e1 | 162 | /** |
Nikollao | 2:c9b24787d5e1 | 163 | configure settings of the LIA, sensitivity (gain) and update output (speed) |
Nikollao | 0:4e20939af8bb | 164 | */ |
Nikollao | 2:c9b24787d5e1 | 165 | void settings_menu(); |
Nikollao | 2:c9b24787d5e1 | 166 | |
Nikollao | 2:c9b24787d5e1 | 167 | /** |
Nikollao | 3:dd4eb355f8d9 | 168 | setup the position of the menu selector (circle) |
Nikollao | 3:dd4eb355f8d9 | 169 | */ |
Nikollao | 3:dd4eb355f8d9 | 170 | void setup_selector(); |
Nikollao | 3:dd4eb355f8d9 | 171 | |
Nikollao | 3:dd4eb355f8d9 | 172 | |
Nikollao | 3:dd4eb355f8d9 | 173 | /** |
Nikollao | 3:dd4eb355f8d9 | 174 | init the LIA menu |
Nikollao | 3:dd4eb355f8d9 | 175 | */ |
Nikollao | 3:dd4eb355f8d9 | 176 | void init_LIA_menu(); |
Nikollao | 3:dd4eb355f8d9 | 177 | |
Nikollao | 3:dd4eb355f8d9 | 178 | /** |
Nikollao | 3:dd4eb355f8d9 | 179 | joystick button pressed |
Nikollao | 3:dd4eb355f8d9 | 180 | */ |
Nikollao | 3:dd4eb355f8d9 | 181 | void confirmationJoyButton(); |
Nikollao | 3:dd4eb355f8d9 | 182 | |
Nikollao | 3:dd4eb355f8d9 | 183 | /** |
Nikollao | 2:c9b24787d5e1 | 184 | set a timeout interrupt to implement power-efficient delays |
Nikollao | 2:c9b24787d5e1 | 185 | */ |
Nikollao | 2:c9b24787d5e1 | 186 | void timeout_isr(); |
Nikollao | 2:c9b24787d5e1 | 187 | |
Nikollao | 2:c9b24787d5e1 | 188 | /** |
Nikollao | 2:c9b24787d5e1 | 189 | set a timeout interrupt to update the menu on screen |
Nikollao | 2:c9b24787d5e1 | 190 | */ |
Nikollao | 2:c9b24787d5e1 | 191 | void menu_isr(); |
Nikollao | 0:4e20939af8bb | 192 | |
Nikollao | 0:4e20939af8bb | 193 | /** |
Nikollao | 3:dd4eb355f8d9 | 194 | Event-triggered interrupt executes ISR when joystick button is pressed |
Nikollao | 3:dd4eb355f8d9 | 195 | */ |
Nikollao | 3:dd4eb355f8d9 | 196 | void joyButton_isr(); |
Nikollao | 3:dd4eb355f8d9 | 197 | |
Nikollao | 3:dd4eb355f8d9 | 198 | /** |
Nikollao | 3:dd4eb355f8d9 | 199 | Event-triggered interrupt executes ISR when joystick button is pressed |
Nikollao | 3:dd4eb355f8d9 | 200 | */ |
Nikollao | 3:dd4eb355f8d9 | 201 | void swButton_isr(); |
Nikollao | 3:dd4eb355f8d9 | 202 | |
Nikollao | 3:dd4eb355f8d9 | 203 | /** |
Nikollao | 0:4e20939af8bb | 204 | use MCU in High Power Mode and set Core, ADC, and BUS clocks at max |
Nikollao | 0:4e20939af8bb | 205 | */ |
Nikollao | 2:c9b24787d5e1 | 206 | |
Nikollao | 0:4e20939af8bb | 207 | void setupK64Fclocks(); |
Nikollao | 0:4e20939af8bb | 208 | |
Nikollao | 0:4e20939af8bb | 209 | /** |
Nikollao | 0:4e20939af8bb | 210 | initialise DAC pin, otherwise AnalogOut (dac0_out) does not work |
Nikollao | 0:4e20939af8bb | 211 | */ |
Nikollao | 0:4e20939af8bb | 212 | void initDAC(); |
Nikollao | 0:4e20939af8bb | 213 | |
Nikollao | 0:4e20939af8bb | 214 | /** |
Nikollao | 0:4e20939af8bb | 215 | find the amplitude of the analog bolometer signal |
Nikollao | 0:4e20939af8bb | 216 | */ |
Nikollao | 0:4e20939af8bb | 217 | double max(int points); |
Nikollao | 0:4e20939af8bb | 218 | |
Nikollao | 0:4e20939af8bb | 219 | double mavg_filter(int filt_points); |
Nikollao | 0:4e20939af8bb | 220 | |
Nikollao | 0:4e20939af8bb | 221 | /** |
Nikollao | 0:4e20939af8bb | 222 | performs digital mixing with refX and refY components |
Nikollao | 0:4e20939af8bb | 223 | */ |
Nikollao | 0:4e20939af8bb | 224 | void digitalMix(double remove_offset); |
Nikollao | 0:4e20939af8bb | 225 | |
Nikollao | 0:4e20939af8bb | 226 | /** |
Nikollao | 0:4e20939af8bb | 227 | ISR calculates the DigitalIn signal frequency |
Nikollao | 0:4e20939af8bb | 228 | */ |
Nikollao | 0:4e20939af8bb | 229 | void voltageRise(); |
Nikollao | 0:4e20939af8bb | 230 | |
Nikollao | 0:4e20939af8bb | 231 | /** |
Nikollao | 0:4e20939af8bb | 232 | ISR calculates the offset of the bolometer signal |
Nikollao | 0:4e20939af8bb | 233 | */ |
Nikollao | 0:4e20939af8bb | 234 | void offset_isr(); |
Nikollao | 0:4e20939af8bb | 235 | |
Nikollao | 1:bf693859586c | 236 | /** |
Nikollao | 1:bf693859586c | 237 | ISR updates the output of the LIA |
Nikollao | 1:bf693859586c | 238 | */ |
Nikollao | 0:4e20939af8bb | 239 | void output_isr(); |
Nikollao | 0:4e20939af8bb | 240 | |
Nikollao | 1:bf693859586c | 241 | //double calculate_constant(double freq_ref); |
Nikollao | 0:4e20939af8bb | 242 | |
Nikollao | 0:4e20939af8bb | 243 | /*!< used to assign the amplitude of the bolometer signal */ |
Nikollao | 0:4e20939af8bb | 244 | volatile double amplitude = 0; |
Nikollao | 0:4e20939af8bb | 245 | |
Nikollao | 0:4e20939af8bb | 246 | /*!< stores the period of the input digital signal */ |
Nikollao | 0:4e20939af8bb | 247 | volatile double ref_period = 0; |
Nikollao | 0:4e20939af8bb | 248 | |
Nikollao | 0:4e20939af8bb | 249 | /*!< stores the frequency of the input digital signal */ |
Nikollao | 0:4e20939af8bb | 250 | volatile double ref_freq = 0; |
Nikollao | 0:4e20939af8bb | 251 | |
Nikollao | 0:4e20939af8bb | 252 | /*!< counter is used to find take between two rises of digital signal*/ |
Nikollao | 0:4e20939af8bb | 253 | volatile int g_counter = 1; |
Nikollao | 0:4e20939af8bb | 254 | |
Nikollao | 0:4e20939af8bb | 255 | /*!< flag is set from ISR to find offset of the bolometer signal */ |
Nikollao | 0:4e20939af8bb | 256 | volatile int g_offset_flag = 0; |
Nikollao | 0:4e20939af8bb | 257 | |
Nikollao | 0:4e20939af8bb | 258 | /*!< sampling period to take n samples and find bolometer signal amplitude */ |
Nikollao | 0:4e20939af8bb | 259 | volatile double amplitude_delay = 0; |
Nikollao | 0:4e20939af8bb | 260 | |
Nikollao | 0:4e20939af8bb | 261 | /*!< flag used to update output */ |
Nikollao | 0:4e20939af8bb | 262 | volatile int g_output_flag = 0; |
Nikollao | 0:4e20939af8bb | 263 | |
Nikollao | 2:c9b24787d5e1 | 264 | /*!< flag used to update menu */ |
Nikollao | 2:c9b24787d5e1 | 265 | volatile int g_menu_flag = 0; |
Nikollao | 2:c9b24787d5e1 | 266 | |
Nikollao | 3:dd4eb355f8d9 | 267 | /*!< flag is set when joystick button is pressed */ |
Nikollao | 3:dd4eb355f8d9 | 268 | volatile int g_joyButton_flag = 0; |
Nikollao | 3:dd4eb355f8d9 | 269 | |
Nikollao | 3:dd4eb355f8d9 | 270 | /*!< flag is set when joystick button is pressed */ |
Nikollao | 3:dd4eb355f8d9 | 271 | volatile int g_swButton_flag = 0; |
Nikollao | 3:dd4eb355f8d9 | 272 | |
Nikollao | 0:4e20939af8bb | 273 | /*!< flag used to sample internal sine/cosine signals */ |
Nikollao | 0:4e20939af8bb | 274 | volatile int g_sample_flag = 0; |
Nikollao | 0:4e20939af8bb | 275 | |
Nikollao | 3:dd4eb355f8d9 | 276 | /*!< variable used to move the menu selector */ |
Nikollao | 3:dd4eb355f8d9 | 277 | volatile int menu_option = 0; |
Nikollao | 3:dd4eb355f8d9 | 278 | |
Nikollao | 3:dd4eb355f8d9 | 279 | /*!< variable used to move the continue selector */ |
Nikollao | 3:dd4eb355f8d9 | 280 | volatile int save_option = 0; |
Nikollao | 3:dd4eb355f8d9 | 281 | |
Nikollao | 2:c9b24787d5e1 | 282 | /*!< var is set to exit the menu */ |
Nikollao | 2:c9b24787d5e1 | 283 | volatile int exit_menu = 0; |
Nikollao | 2:c9b24787d5e1 | 284 | |
Nikollao | 2:c9b24787d5e1 | 285 | /*!< var is used to set the output gain */ |
Nikollao | 3:dd4eb355f8d9 | 286 | volatile double var_gain = 1.0; |
Nikollao | 2:c9b24787d5e1 | 287 | |
Nikollao | 2:c9b24787d5e1 | 288 | /*!< var is used to set the output speed */ |
Nikollao | 3:dd4eb355f8d9 | 289 | volatile double var_speed = 1.0; |
Nikollao | 2:c9b24787d5e1 | 290 | |
Nikollao | 0:4e20939af8bb | 291 | /*!< array stores the square root of X^2 and Y^2 */ |
Nikollao | 0:4e20939af8bb | 292 | volatile double R[16]; |
Nikollao | 0:4e20939af8bb | 293 | |
Nikollao | 0:4e20939af8bb | 294 | /*!< store the bolometer signal and find max value */ |
Nikollao | 0:4e20939af8bb | 295 | double bolometer_signal[8]; |
Nikollao | 0:4e20939af8bb | 296 | |
Nikollao | 0:4e20939af8bb | 297 | /*!< store the bolometer signal and find max value */ |
Nikollao | 0:4e20939af8bb | 298 | double bol_signal; |
Nikollao | 0:4e20939af8bb | 299 | //int size = 16; |
Nikollao | 0:4e20939af8bb | 300 | |
Nikollao | 0:4e20939af8bb | 301 | /*!< variable used if a sine/cosine of 8 discrete values is used */ |
Nikollao | 0:4e20939af8bb | 302 | int samples8 = 8; |
Nikollao | 0:4e20939af8bb | 303 | |
Nikollao | 0:4e20939af8bb | 304 | /*!< variable used if a sine/cosine of 17 discrete values is used */ |
Nikollao | 0:4e20939af8bb | 305 | int samples16 = 16; |
Nikollao | 0:4e20939af8bb | 306 | |
Nikollao | 0:4e20939af8bb | 307 | /*!< variable used if a sine/cosine of 32 discrete values is used */ |
Nikollao | 0:4e20939af8bb | 308 | int samples32 = 32; |
Nikollao | 0:4e20939af8bb | 309 | |
Nikollao | 0:4e20939af8bb | 310 | /*!< sampling frequency of the internal sine/cosine waves */ |
Nikollao | 0:4e20939af8bb | 311 | double sample_freq = 0; |
Nikollao | 0:4e20939af8bb | 312 | |
Nikollao | 0:4e20939af8bb | 313 | /*!< variable used to sample the internal sine/cosine waves */ |
Nikollao | 0:4e20939af8bb | 314 | double sample_time = 0; |
Nikollao | 0:4e20939af8bb | 315 | |
Nikollao | 0:4e20939af8bb | 316 | /*!< number of samples for the amplitude of the bolometer signal */ |
Nikollao | 0:4e20939af8bb | 317 | int amp_points = 32; |
Nikollao | 0:4e20939af8bb | 318 | |
Nikollao | 0:4e20939af8bb | 319 | /*!< sampling freq to find the amplitude of the bolomter signal */ |
Nikollao | 0:4e20939af8bb | 320 | double delay_freq = 0; |
Nikollao | 0:4e20939af8bb | 321 | |
Nikollao | 0:4e20939af8bb | 322 | /*!< read the timer and if it is equal to the time constant update output */ |
Nikollao | 0:4e20939af8bb | 323 | double time_out = 0; |
Nikollao | 0:4e20939af8bb | 324 | |
Nikollao | 0:4e20939af8bb | 325 | int filter_points = 500; |
Nikollao | 0:4e20939af8bb | 326 | |
Nikollao | 0:4e20939af8bb | 327 | double offset = 0; |
Nikollao | 0:4e20939af8bb | 328 | |
Nikollao | 0:4e20939af8bb | 329 | /*!< sine wave array with 32 values */ |
Nikollao | 0:4e20939af8bb | 330 | static double sin_array32[32] = {0, 0.1951, 0.3827, 0.5556, 0.7071, 0.8315, 0.9239, |
Nikollao | 0:4e20939af8bb | 331 | 0.9808, 1, 0.9808, 0.9239, 0.8315, 0.7071, 0.5556, |
Nikollao | 0:4e20939af8bb | 332 | 0.3827, 0.1951, 0, -0.1951, -0.3827, -0.5556, -0.7071, |
Nikollao | 0:4e20939af8bb | 333 | -0.8315, -0.9239, -0.9808, -1, -0.9808, -0.9239, -0.8315, |
Nikollao | 0:4e20939af8bb | 334 | -0.7071, -0.5556, -0.3827, -0.1951 |
Nikollao | 0:4e20939af8bb | 335 | }; |
Nikollao | 0:4e20939af8bb | 336 | |
Nikollao | 0:4e20939af8bb | 337 | /*!< cosine wave array with 32 values */ |
Nikollao | 0:4e20939af8bb | 338 | static double cos_array32[32] = {1, 0.9808, 0.9239, 0.8315, 0.7071, 0.5556, |
Nikollao | 0:4e20939af8bb | 339 | 0.3827, 0.1951, 0, -0.1951, -0.3827, -0.5556, -0.7071, |
Nikollao | 0:4e20939af8bb | 340 | -0.8315, -0.9239, -0.9808, -1, -0.9808, -0.9239, -0.8315, |
Nikollao | 0:4e20939af8bb | 341 | -0.7071, -0.5556, -0.3827, -0.1951, 0, 0.1951, 0.3827, |
Nikollao | 0:4e20939af8bb | 342 | 0.5556, 0.7071, 0.8315, 0.9239, 0.9808 |
Nikollao | 0:4e20939af8bb | 343 | }; |
Nikollao | 0:4e20939af8bb | 344 | |
Nikollao | 0:4e20939af8bb | 345 | /*!< sine wave array with 17 values */ |
Nikollao | 0:4e20939af8bb | 346 | static double sin_array16[16] = {0, 0.3827, 0.7071, 0.9239, 1, 0.9239, 0.7071, |
Nikollao | 0:4e20939af8bb | 347 | 0.3827, 0, -0.3827, -0.7071, -0.9239, -1, -0.9239 |
Nikollao | 0:4e20939af8bb | 348 | ,-0.7071, -0.3827, |
Nikollao | 0:4e20939af8bb | 349 | }; |
Nikollao | 0:4e20939af8bb | 350 | |
Nikollao | 0:4e20939af8bb | 351 | /*!< sine wave array with delay and 16 values, used for testing output */ |
Nikollao | 0:4e20939af8bb | 352 | static double sin_array16delay[16] = {0.7071, 0.9239, 1, 0.9239, 0.7071, |
Nikollao | 0:4e20939af8bb | 353 | 0.3827, 0, -0.3827, -0.7071, -0.9239, -1, -0.9239 |
Nikollao | 0:4e20939af8bb | 354 | ,-0.7071, -0.3827, 0, 0.3827 |
Nikollao | 0:4e20939af8bb | 355 | }; |
Nikollao | 0:4e20939af8bb | 356 | |
Nikollao | 0:4e20939af8bb | 357 | /*!< cosine wave array with 17 values */ |
Nikollao | 0:4e20939af8bb | 358 | static double cos_array16[16] = {1, 0.9239, 0.7071, |
Nikollao | 0:4e20939af8bb | 359 | 0.3827, 0, -0.3827, -0.7071, -0.9239, -1, -0.9239 |
Nikollao | 0:4e20939af8bb | 360 | ,-0.7071, -0.3827, 0, 0.3827, 0.7071, 0.9239, |
Nikollao | 0:4e20939af8bb | 361 | }; |
Nikollao | 0:4e20939af8bb | 362 | |
Nikollao | 0:4e20939af8bb | 363 | /*!< sine wave array with 8 values */ |
Nikollao | 0:4e20939af8bb | 364 | static double sin_array8[8] = {0, 0.7071, 1, 0.7071, 0, -0.7071, -1, -0.7071}; |
Nikollao | 0:4e20939af8bb | 365 | |
Nikollao | 0:4e20939af8bb | 366 | /*!< cosine wave array with 8 values */ |
Nikollao | 0:4e20939af8bb | 367 | static double cos_array8[8] = {1, 0.7071, 0, -0.7071, -1, -0.7071, 0, 0.7071}; |
Nikollao | 0:4e20939af8bb | 368 | |
Nikollao | 0:4e20939af8bb | 369 | #endif |