Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LGstaandart by
DevicePLCS.h@186:c7a9c309086c, 2016-07-31 (annotated)
- Committer:
- Diletant
- Date:
- Sun Jul 31 06:19:02 2016 +0000
- Revision:
- 186:c7a9c309086c
- Parent:
- 178:672ef279c8e0
Device&... update. More AskGld&Techno functionality.NotFinal!!!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Diletant | 149:abbf7663d27d | 1 | #ifndef __DEVICE_PLCS_H__ |
| Diletant | 149:abbf7663d27d | 2 | #define __DEVICE_PLCS_H__ |
| Diletant | 149:abbf7663d27d | 3 | |
| Diletant | 167:bedc0a9d559a | 4 | //Path length control system phase feedback typedefs |
| Diletant | 167:bedc0a9d559a | 5 | typedef struct _DevicePLCSFeedbackTransferFunction { |
| Diletant | 167:bedc0a9d559a | 6 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 7 | int32_t raw[16]; //Feedback raw value - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 8 | int32_t normalized[16];//Feedback normalized value - -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 9 | } DevicePLCSFeedbackTransferFunction; |
| Diletant | 166:c3c0b8a90d81 | 10 | |
| Diletant | 167:bedc0a9d559a | 11 | typedef struct _DevicePLCSFeedbackSettings { |
| Diletant | 167:bedc0a9d559a | 12 | uint8_t input; //Take ISACS input as feedback |
| Diletant | 167:bedc0a9d559a | 13 | uint8_t output; //Take ISACS output as feedback |
| Diletant | 167:bedc0a9d559a | 14 | DevicePLCSFeedbackTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 15 | } DevicePLCSFeedbackSettings; |
| Diletant | 167:bedc0a9d559a | 16 | |
| Diletant | 167:bedc0a9d559a | 17 | typedef struct _DevicePLCSFeedbackState { |
| Diletant | 166:c3c0b8a90d81 | 18 | uint8_t input; //Take ISACS input as feedback |
| Diletant | 166:c3c0b8a90d81 | 19 | uint8_t output; //Take ISACS output as feedback |
| Diletant | 186:c7a9c309086c | 20 | int32_t voltage; //Feedback - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 21 | } DevicePLCSFeedbackState; |
| Diletant | 167:bedc0a9d559a | 22 | |
| Diletant | 167:bedc0a9d559a | 23 | typedef struct _DevicePLCSFeedback { |
| Diletant | 167:bedc0a9d559a | 24 | DevicePLCSFeedbackSettings settings; |
| Diletant | 167:bedc0a9d559a | 25 | DevicePLCSFeedbackState state; |
| Diletant | 167:bedc0a9d559a | 26 | } DevicePLCSFeedback; |
| Diletant | 167:bedc0a9d559a | 27 | |
| Diletant | 167:bedc0a9d559a | 28 | //Path length control system reference typedefs |
| Diletant | 167:bedc0a9d559a | 29 | typedef struct _DevicePLCSReferenceSettings { |
| Diletant | 167:bedc0a9d559a | 30 | uint8_t sequencer; //Take sequencer as reference (and ISACS amplitude/output as feedback) |
| Diletant | 167:bedc0a9d559a | 31 | uint8_t delta; //Take delta as reference (and ISACS amplitude/output delta as feedback) |
| Diletant | 167:bedc0a9d559a | 32 | } DevicePLCSReferenceSettings; |
| Diletant | 167:bedc0a9d559a | 33 | |
| Diletant | 167:bedc0a9d559a | 34 | typedef struct _DevicePLCSReferenceState { |
| Diletant | 166:c3c0b8a90d81 | 35 | uint8_t sequencer; //Take sequencer as reference (and ISACS amplitude/output as feedback) |
| Diletant | 166:c3c0b8a90d81 | 36 | uint8_t delta; //Take delta as reference (and ISACS amplitude/output delta as feedback) |
| Diletant | 167:bedc0a9d559a | 37 | } DevicePLCSReferenceState; |
| Diletant | 167:bedc0a9d559a | 38 | |
| Diletant | 167:bedc0a9d559a | 39 | typedef struct _DevicePLCSReference { |
| Diletant | 167:bedc0a9d559a | 40 | DevicePLCSReferenceSettings settings; |
| Diletant | 167:bedc0a9d559a | 41 | DevicePLCSReferenceState state; |
| Diletant | 167:bedc0a9d559a | 42 | } DevicePLCSReference; |
| Diletant | 167:bedc0a9d559a | 43 | |
| Diletant | 167:bedc0a9d559a | 44 | //Path length control system detector typedefs |
| Diletant | 167:bedc0a9d559a | 45 | typedef struct _DevicePLCSDetectorState { |
| Diletant | 167:bedc0a9d559a | 46 | int32_t in[2]; //Detector inputs: reference, feedback -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 47 | int32_t out; //Detector output: -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 48 | } DevicePLCSDetectorState; |
| Diletant | 167:bedc0a9d559a | 49 | |
| Diletant | 167:bedc0a9d559a | 50 | typedef struct _DevicePLCSDetector { |
| Diletant | 167:bedc0a9d559a | 51 | DevicePLCSDetectorState state; |
| Diletant | 167:bedc0a9d559a | 52 | } DevicePLCSDetector; |
| Diletant | 167:bedc0a9d559a | 53 | |
| Diletant | 167:bedc0a9d559a | 54 | //Path length control system bias typedefs |
| Diletant | 167:bedc0a9d559a | 55 | typedef struct _DevicePLCSBiasTransferFunction { |
| Diletant | 167:bedc0a9d559a | 56 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 57 | int32_t raw[16]; //Raw bias value - dimensionless units |
| Diletant | 167:bedc0a9d559a | 58 | int32_t normalized[16]; //Normalized bias value - -0.5...+0.5 of lambda in 16.16 format |
| Diletant | 167:bedc0a9d559a | 59 | } DevicePLCSBiasTransferFunction; |
| Diletant | 167:bedc0a9d559a | 60 | |
| Diletant | 167:bedc0a9d559a | 61 | typedef struct _DevicePLCSBiasSettings { |
| Diletant | 167:bedc0a9d559a | 62 | DevicePLCSBiasTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 63 | } DevicePLCSBiasSettings; |
| Diletant | 167:bedc0a9d559a | 64 | |
| Diletant | 167:bedc0a9d559a | 65 | typedef struct _DevicePLCSBiasState { |
| Diletant | 167:bedc0a9d559a | 66 | uint32_t raw; //Raw bias value - -0.5...+0.5 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 67 | int32_t sum; |
| Diletant | 167:bedc0a9d559a | 68 | int32_t counter; |
| Diletant | 167:bedc0a9d559a | 69 | int32_t average; //Average bias value - -0.5...+0.5 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 70 | } DevicePLCSBiasState; |
| Diletant | 167:bedc0a9d559a | 71 | |
| Diletant | 167:bedc0a9d559a | 72 | typedef struct _DevicePLCSBias { |
| Diletant | 167:bedc0a9d559a | 73 | DevicePLCSBiasSettings settings; |
| Diletant | 167:bedc0a9d559a | 74 | DevicePLCSBiasState state; |
| Diletant | 167:bedc0a9d559a | 75 | } DevicePLCSBias; |
| Diletant | 166:c3c0b8a90d81 | 76 | |
| Diletant | 167:bedc0a9d559a | 77 | //Path length control system regulator typedefs |
| Diletant | 167:bedc0a9d559a | 78 | typedef struct _DevicePLCSCorrectionTransferFunction { |
| Diletant | 178:672ef279c8e0 | 79 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 178:672ef279c8e0 | 80 | int32_t error[16]; //Regulator error value - degrees in 16.16 format |
| Diletant | 178:672ef279c8e0 | 81 | int32_t correction[16]; //Regulator correction value - -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 82 | } DevicePLCSCorrectionTransferFunction; |
| Diletant | 167:bedc0a9d559a | 83 | |
| Diletant | 167:bedc0a9d559a | 84 | typedef struct _DevicePLCSRegulatorSettings { |
| Diletant | 167:bedc0a9d559a | 85 | uint8_t enabled; |
| Diletant | 178:672ef279c8e0 | 86 | int32_t reference; //Reference bias - signed 16.16 format |
| Diletant | 178:672ef279c8e0 | 87 | int32_t scale; //Regulator scale factor - signed 16.16 format |
| Diletant | 167:bedc0a9d559a | 88 | DevicePLCSCorrectionTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 89 | } DevicePLCSRegulatorSettings; |
| Diletant | 167:bedc0a9d559a | 90 | |
| Diletant | 167:bedc0a9d559a | 91 | typedef struct _DevicePLCSRegulatorState { |
| Diletant | 167:bedc0a9d559a | 92 | uint8_t enabled; |
| Diletant | 178:672ef279c8e0 | 93 | int32_t reference; //Reference bias - signed 16.16 format |
| Diletant | 178:672ef279c8e0 | 94 | int32_t scale; //Regulator scale factor - signed 16.16 format |
| Diletant | 178:672ef279c8e0 | 95 | int32_t error; //Regulator error - signed 16.16 format |
| Diletant | 178:672ef279c8e0 | 96 | int32_t correction;//Output correction - signed 16.16 format |
| Diletant | 167:bedc0a9d559a | 97 | } DevicePLCSRegulatorState; |
| Diletant | 156:e68ee0bcdcda | 98 | |
| Diletant | 167:bedc0a9d559a | 99 | typedef struct _DevicePLCSRegulator { |
| Diletant | 167:bedc0a9d559a | 100 | DevicePLCSRegulatorSettings settings; |
| Diletant | 167:bedc0a9d559a | 101 | DevicePLCSRegulatorState state; |
| Diletant | 167:bedc0a9d559a | 102 | } DevicePLCSRegulator; |
| Diletant | 167:bedc0a9d559a | 103 | |
| Diletant | 167:bedc0a9d559a | 104 | //Path length control reset typedefs |
| Diletant | 167:bedc0a9d559a | 105 | typedef struct _DevicePLCSResetTemperatureFunction { |
| Diletant | 167:bedc0a9d559a | 106 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 107 | int32_t temperature[16]; //Output reset temperature value - centigrade, 16.16 format |
| Diletant | 186:c7a9c309086c | 108 | int32_t trigger[16]; //Output reset trigger level value - volts, 16.16 format |
| Diletant | 186:c7a9c309086c | 109 | int32_t voltage[16]; //Output reset target level value - volts, 16.16 format - Delete this!!! |
| Diletant | 186:c7a9c309086c | 110 | int32_t target[16]; //Output reset target level value - volts, 16.16 format - Use this!!! |
| Diletant | 186:c7a9c309086c | 111 | int32_t duration[16]; //Output reset duration value - seconds, 16.16 format |
| Diletant | 167:bedc0a9d559a | 112 | } DevicePLCSResetTemperatureFunction; |
| Diletant | 167:bedc0a9d559a | 113 | |
| Diletant | 186:c7a9c309086c | 114 | typedef struct _DevicePLCSResetDirectionSettings { |
| Diletant | 186:c7a9c309086c | 115 | DevicePLCSResetTemperatureFunction environment; |
| Diletant | 186:c7a9c309086c | 116 | } DevicePLCSResetDirectionSettings; |
| Diletant | 186:c7a9c309086c | 117 | |
| Diletant | 186:c7a9c309086c | 118 | typedef struct _DevicePLCSResetDirectionState { |
| Diletant | 186:c7a9c309086c | 119 | int32_t trigger; //Output reset trigger level value - volts, 16.16 format |
| Diletant | 186:c7a9c309086c | 120 | int32_t target; //Output reset target level value - volts, 16.16 format |
| Diletant | 186:c7a9c309086c | 121 | int32_t duration; //Output reset duration value - seconds, 16.16 format |
| Diletant | 186:c7a9c309086c | 122 | } DevicePLCSResetDirectionState; |
| Diletant | 186:c7a9c309086c | 123 | |
| Diletant | 186:c7a9c309086c | 124 | typedef struct _DevicePLCSResetDirection { |
| Diletant | 186:c7a9c309086c | 125 | DevicePLCSResetDirectionSettings settings; |
| Diletant | 186:c7a9c309086c | 126 | DevicePLCSResetDirectionState state; |
| Diletant | 186:c7a9c309086c | 127 | } DevicePLCSResetDirection; |
| Diletant | 167:bedc0a9d559a | 128 | |
| Diletant | 167:bedc0a9d559a | 129 | typedef struct _DevicePLCSResetState { |
| Diletant | 186:c7a9c309086c | 130 | int32_t countdown; //Output reset countdown - seconds, 16.16 format |
| Diletant | 186:c7a9c309086c | 131 | int32_t voltage; //Output reset target level value - volts, 16.16 format |
| Diletant | 167:bedc0a9d559a | 132 | } DevicePLCSResetState; |
| Diletant | 167:bedc0a9d559a | 133 | |
| Diletant | 167:bedc0a9d559a | 134 | typedef struct _DevicePLCSReset { |
| Diletant | 186:c7a9c309086c | 135 | //DevicePLCSResetSettings settings; //Delete this!!! |
| Diletant | 186:c7a9c309086c | 136 | DevicePLCSResetDirection up; |
| Diletant | 186:c7a9c309086c | 137 | DevicePLCSResetDirection down; |
| Diletant | 167:bedc0a9d559a | 138 | DevicePLCSResetState state; |
| Diletant | 167:bedc0a9d559a | 139 | } DevicePLCSReset; |
| Diletant | 166:c3c0b8a90d81 | 140 | |
| Diletant | 166:c3c0b8a90d81 | 141 | //Path length control system output ( = DAC + amplifier + control unit + heater/piezo) typedefs |
| Diletant | 167:bedc0a9d559a | 142 | typedef struct _DevicePLCSOutputStart { |
| Diletant | 167:bedc0a9d559a | 143 | int32_t voltage; //Output voltage in signed 16.16 fixed point format |
| Diletant | 167:bedc0a9d559a | 144 | } DevicePLCSOutputStart; |
| Diletant | 167:bedc0a9d559a | 145 | |
| Diletant | 167:bedc0a9d559a | 146 | typedef struct _DevicePLCSOutputTransferFunction { |
| Diletant | 166:c3c0b8a90d81 | 147 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 166:c3c0b8a90d81 | 148 | int32_t voltage[16]; //Output voltage control points in signed 16.16 fixed point format |
| Diletant | 166:c3c0b8a90d81 | 149 | int32_t code[16]; //DAC code control points |
| Diletant | 167:bedc0a9d559a | 150 | } DevicePLCSOutputTransferFunction; |
| Diletant | 166:c3c0b8a90d81 | 151 | |
| Diletant | 166:c3c0b8a90d81 | 152 | typedef struct _DevicePLCSOutputSettings { |
| Diletant | 166:c3c0b8a90d81 | 153 | uint8_t enabled; //Enable DAC output |
| Diletant | 173:7f938afb0447 | 154 | uint8_t sequencer; //Enable sequencer output summation |
| Diletant | 167:bedc0a9d559a | 155 | DevicePLCSOutputStart start; |
| Diletant | 167:bedc0a9d559a | 156 | DevicePLCSOutputTransferFunction transfer; |
| Diletant | 166:c3c0b8a90d81 | 157 | } DevicePLCSOutputSettings; |
| Diletant | 166:c3c0b8a90d81 | 158 | |
| Diletant | 166:c3c0b8a90d81 | 159 | typedef struct _DevicePLCSOutputState { |
| Diletant | 166:c3c0b8a90d81 | 160 | uint8_t enabled; //Enable DAC output |
| Diletant | 173:7f938afb0447 | 161 | uint8_t sequencer; //Enable sequencer output summation |
| Diletant | 186:c7a9c309086c | 162 | int32_t voltage; //Voltage output |
| Diletant | 167:bedc0a9d559a | 163 | uint32_t code; //Code output |
| Diletant | 166:c3c0b8a90d81 | 164 | } DevicePLCSOutputState; |
| Diletant | 166:c3c0b8a90d81 | 165 | |
| Diletant | 166:c3c0b8a90d81 | 166 | typedef struct _DevicePLCSOutput { |
| Diletant | 166:c3c0b8a90d81 | 167 | DevicePLCSOutputSettings settings; |
| Diletant | 166:c3c0b8a90d81 | 168 | DevicePLCSOutputState state; |
| Diletant | 166:c3c0b8a90d81 | 169 | } DevicePLCSOutput; |
| Diletant | 156:e68ee0bcdcda | 170 | |
| Diletant | 161:efd949e8d536 | 171 | //Path length control system typedefs |
| Diletant | 166:c3c0b8a90d81 | 172 | // Information signal amplitude ADC: device.controller.SSP.ADC[4] |
| Diletant | 161:efd949e8d536 | 173 | // Path length control system DAC: device.controller.SSP.DAC[1] |
| Diletant | 149:abbf7663d27d | 174 | typedef struct _DevicePathLengthControlSystem { |
| Diletant | 167:bedc0a9d559a | 175 | DevicePLCSFeedback feedback; |
| Diletant | 167:bedc0a9d559a | 176 | DevicePLCSReference reference; |
| Diletant | 167:bedc0a9d559a | 177 | DevicePLCSDetector detector; |
| Diletant | 167:bedc0a9d559a | 178 | DevicePLCSBias bias; |
| Diletant | 167:bedc0a9d559a | 179 | DevicePLCSRegulator regulator; |
| Diletant | 167:bedc0a9d559a | 180 | DevicePLCSReset reset; |
| Diletant | 166:c3c0b8a90d81 | 181 | DevicePLCSOutput output; |
| Diletant | 149:abbf7663d27d | 182 | } DevicePathLengthControlSystem; |
| Diletant | 149:abbf7663d27d | 183 | |
| Diletant | 161:efd949e8d536 | 184 | //Path length control system functions |
| Diletant | 167:bedc0a9d559a | 185 | void InitPathLengthControlSystemDefaultSettings(void); |
| Diletant | 167:bedc0a9d559a | 186 | void InitPathLengthControlSystemState(void); |
| Diletant | 167:bedc0a9d559a | 187 | void DeviceStartPLCS(void); |
| Diletant | 149:abbf7663d27d | 188 | |
| Diletant | 166:c3c0b8a90d81 | 189 | void plcsProcess(void); |
| Diletant | 166:c3c0b8a90d81 | 190 | |
| Diletant | 186:c7a9c309086c | 191 | //Compatibility functions section |
| Diletant | 186:c7a9c309086c | 192 | //WP_reg dac ttf: DAC code in PLCS channel; value: voltage of PLCS; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V |
| Diletant | 186:c7a9c309086c | 193 | int16_t var_WP_reg(void); |
| Diletant | 186:c7a9c309086c | 194 | |
| Diletant | 186:c7a9c309086c | 195 | //WP_pll = WP_PhaseDetectorRate( WP_Phase_Det, time_1_Sec) |
| Diletant | 186:c7a9c309086c | 196 | int16_t var_WP_pll(void); |
| Diletant | 186:c7a9c309086c | 197 | |
| Diletant | 186:c7a9c309086c | 198 | //WP_ref s16 PLCS reference |
| Diletant | 186:c7a9c309086c | 199 | uint16_t param_WP_ref(void); |
| Diletant | 186:c7a9c309086c | 200 | |
| Diletant | 186:c7a9c309086c | 201 | //WP_scl s16 PLCS gain factor (1.15) 5..20 |
| Diletant | 186:c7a9c309086c | 202 | uint16_t param_WP_scl(void); |
| Diletant | 186:c7a9c309086c | 203 | |
| Diletant | 186:c7a9c309086c | 204 | //WP_mdy s16 PLCS reset delay in 10kHz cycles |
| Diletant | 186:c7a9c309086c | 205 | uint16_t param_WP_mdy(void); |
| Diletant | 186:c7a9c309086c | 206 | |
| Diletant | 186:c7a9c309086c | 207 | //WP_rup dac ttf:PLCS maximum DAC code in heater channel; value:minimal voltage on the heater; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V |
| Diletant | 186:c7a9c309086c | 208 | uint16_t param_WP_rup(void); |
| Diletant | 186:c7a9c309086c | 209 | |
| Diletant | 186:c7a9c309086c | 210 | //WP_rdw dac ttf:PLCS minimum DAC code in heater channel; value:maximal voltage on the heater; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V |
| Diletant | 186:c7a9c309086c | 211 | uint16_t param_WP_rdw(void); |
| Diletant | 186:c7a9c309086c | 212 | |
| Diletant | 186:c7a9c309086c | 213 | //WP_reset dac ttf:PLCS DAC code after reset at heating; value:heater voltage after reset at heating; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V |
| Diletant | 186:c7a9c309086c | 214 | uint16_t param_WP_reset(void); |
| Diletant | 186:c7a9c309086c | 215 | |
| Diletant | 186:c7a9c309086c | 216 | //WP_reset2 dac ttf:PLCS DAC code after reset at cooling; value:heater voltage after reset at cooling; value=(ttf>>4)/2048*(-12)-1.3 |
| Diletant | 186:c7a9c309086c | 217 | uint16_t param_WP_reset2(void); |
| Diletant | 186:c7a9c309086c | 218 | |
| Diletant | 149:abbf7663d27d | 219 | #endif /* __DEVICE_PLCS_H__ */ |
