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@167:bedc0a9d559a, 2016-06-05 (annotated)
- Committer:
- Diletant
- Date:
- Sun Jun 05 11:03:33 2016 +0000
- Revision:
- 167:bedc0a9d559a
- Parent:
- 166:c3c0b8a90d81
- Child:
- 173:7f938afb0447
Device & ... update. Not final!!!
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 | 166:c3c0b8a90d81 | 4 | //Path length control system sequencer typedefs |
| Diletant | 166:c3c0b8a90d81 | 5 | typedef struct _DevicePLCSSequencerSettings { |
| Diletant | 167:bedc0a9d559a | 6 | uint8_t enabled; //Enable sequence generation |
| Diletant | 167:bedc0a9d559a | 7 | uint8_t analog; //Modulate analog (voltage) output |
| Diletant | 167:bedc0a9d559a | 8 | uint8_t logic; //Modulate logic (GPIO pin) output |
| Diletant | 167:bedc0a9d559a | 9 | int32_t amplitude; //Generator analog output amplitude - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 10 | int32_t sequence[64]; //Generator sequence - dimensionless units -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 11 | uint8_t position[2]; //Sequence position |
| Diletant | 166:c3c0b8a90d81 | 12 | } DevicePLCSSequencerSettings; |
| Diletant | 166:c3c0b8a90d81 | 13 | |
| Diletant | 166:c3c0b8a90d81 | 14 | typedef struct _DevicePLCSSequencerState { |
| Diletant | 167:bedc0a9d559a | 15 | uint8_t enabled; //Enable sequence generation |
| Diletant | 167:bedc0a9d559a | 16 | //uint8_t counter; //Sequence counter: sequence position = device.measurement.counter + device.measurement.length * device.plcs.sequencer.counter |
| Diletant | 167:bedc0a9d559a | 17 | uint8_t analog; //Modulate analog (voltage) output |
| Diletant | 167:bedc0a9d559a | 18 | uint8_t logic; //Modulate logic (GPIO pin) output |
| Diletant | 167:bedc0a9d559a | 19 | uint32_t amplitude; //Generator analog output amplitude - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 20 | uint8_t position[2]; //Sequence position |
| Diletant | 167:bedc0a9d559a | 21 | uint32_t sample[2]; //Sequencer analog output = sequence[]: current/delayed - dimensionless units -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 22 | uint32_t voltage; //Sequencer analog output = sequence[] * amplitude - volts in 16.16 format |
| Diletant | 166:c3c0b8a90d81 | 23 | } DevicePLCSSequencerState; |
| Diletant | 166:c3c0b8a90d81 | 24 | |
| Diletant | 166:c3c0b8a90d81 | 25 | typedef struct _DevicePLCSSequencer { |
| Diletant | 166:c3c0b8a90d81 | 26 | DevicePLCSSequencerSettings settings; |
| Diletant | 166:c3c0b8a90d81 | 27 | DevicePLCSSequencerState state; |
| Diletant | 166:c3c0b8a90d81 | 28 | } DevicePLCSSequencer; |
| Diletant | 166:c3c0b8a90d81 | 29 | |
| Diletant | 167:bedc0a9d559a | 30 | //Path length control system phase feedback typedefs |
| Diletant | 167:bedc0a9d559a | 31 | typedef struct _DevicePLCSFeedbackTransferFunction { |
| Diletant | 167:bedc0a9d559a | 32 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 33 | int32_t raw[16]; //Feedback raw value - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 34 | int32_t normalized[16];//Feedback normalized value - -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 35 | } DevicePLCSFeedbackTransferFunction; |
| Diletant | 166:c3c0b8a90d81 | 36 | |
| Diletant | 167:bedc0a9d559a | 37 | typedef struct _DevicePLCSFeedbackSettings { |
| Diletant | 167:bedc0a9d559a | 38 | uint8_t input; //Take ISACS input as feedback |
| Diletant | 167:bedc0a9d559a | 39 | uint8_t output; //Take ISACS output as feedback |
| Diletant | 167:bedc0a9d559a | 40 | DevicePLCSFeedbackTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 41 | } DevicePLCSFeedbackSettings; |
| Diletant | 167:bedc0a9d559a | 42 | |
| Diletant | 167:bedc0a9d559a | 43 | typedef struct _DevicePLCSFeedbackState { |
| Diletant | 166:c3c0b8a90d81 | 44 | uint8_t input; //Take ISACS input as feedback |
| Diletant | 166:c3c0b8a90d81 | 45 | uint8_t output; //Take ISACS output as feedback |
| Diletant | 167:bedc0a9d559a | 46 | uint32_t voltage; //Feedback - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 47 | } DevicePLCSFeedbackState; |
| Diletant | 167:bedc0a9d559a | 48 | |
| Diletant | 167:bedc0a9d559a | 49 | typedef struct _DevicePLCSFeedback { |
| Diletant | 167:bedc0a9d559a | 50 | DevicePLCSFeedbackSettings settings; |
| Diletant | 167:bedc0a9d559a | 51 | DevicePLCSFeedbackState state; |
| Diletant | 167:bedc0a9d559a | 52 | } DevicePLCSFeedback; |
| Diletant | 167:bedc0a9d559a | 53 | |
| Diletant | 167:bedc0a9d559a | 54 | //Path length control system reference typedefs |
| Diletant | 167:bedc0a9d559a | 55 | typedef struct _DevicePLCSReferenceSettings { |
| Diletant | 167:bedc0a9d559a | 56 | uint8_t sequencer; //Take sequencer as reference (and ISACS amplitude/output as feedback) |
| Diletant | 167:bedc0a9d559a | 57 | uint8_t delta; //Take delta as reference (and ISACS amplitude/output delta as feedback) |
| Diletant | 167:bedc0a9d559a | 58 | } DevicePLCSReferenceSettings; |
| Diletant | 167:bedc0a9d559a | 59 | |
| Diletant | 167:bedc0a9d559a | 60 | typedef struct _DevicePLCSReferenceState { |
| Diletant | 166:c3c0b8a90d81 | 61 | uint8_t sequencer; //Take sequencer as reference (and ISACS amplitude/output as feedback) |
| Diletant | 166:c3c0b8a90d81 | 62 | uint8_t delta; //Take delta as reference (and ISACS amplitude/output delta as feedback) |
| Diletant | 167:bedc0a9d559a | 63 | } DevicePLCSReferenceState; |
| Diletant | 167:bedc0a9d559a | 64 | |
| Diletant | 167:bedc0a9d559a | 65 | typedef struct _DevicePLCSReference { |
| Diletant | 167:bedc0a9d559a | 66 | DevicePLCSReferenceSettings settings; |
| Diletant | 167:bedc0a9d559a | 67 | DevicePLCSReferenceState state; |
| Diletant | 167:bedc0a9d559a | 68 | } DevicePLCSReference; |
| Diletant | 167:bedc0a9d559a | 69 | |
| Diletant | 167:bedc0a9d559a | 70 | //Path length control system detector typedefs |
| Diletant | 167:bedc0a9d559a | 71 | typedef struct _DevicePLCSDetectorState { |
| Diletant | 167:bedc0a9d559a | 72 | int32_t in[2]; //Detector inputs: reference, feedback -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 73 | int32_t out; //Detector output: -1...+1 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 74 | } DevicePLCSDetectorState; |
| Diletant | 167:bedc0a9d559a | 75 | |
| Diletant | 167:bedc0a9d559a | 76 | typedef struct _DevicePLCSDetector { |
| Diletant | 167:bedc0a9d559a | 77 | DevicePLCSDetectorState state; |
| Diletant | 167:bedc0a9d559a | 78 | } DevicePLCSDetector; |
| Diletant | 167:bedc0a9d559a | 79 | |
| Diletant | 167:bedc0a9d559a | 80 | //Path length control system bias typedefs |
| Diletant | 167:bedc0a9d559a | 81 | typedef struct _DevicePLCSBiasTransferFunction { |
| Diletant | 167:bedc0a9d559a | 82 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 83 | int32_t raw[16]; //Raw bias value - dimensionless units |
| Diletant | 167:bedc0a9d559a | 84 | int32_t normalized[16]; //Normalized bias value - -0.5...+0.5 of lambda in 16.16 format |
| Diletant | 167:bedc0a9d559a | 85 | } DevicePLCSBiasTransferFunction; |
| Diletant | 167:bedc0a9d559a | 86 | |
| Diletant | 167:bedc0a9d559a | 87 | typedef struct _DevicePLCSBiasSettings { |
| Diletant | 167:bedc0a9d559a | 88 | DevicePLCSBiasTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 89 | } DevicePLCSBiasSettings; |
| Diletant | 167:bedc0a9d559a | 90 | |
| Diletant | 167:bedc0a9d559a | 91 | typedef struct _DevicePLCSBiasState { |
| Diletant | 167:bedc0a9d559a | 92 | uint32_t raw; //Raw bias value - -0.5...+0.5 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 93 | int32_t sum; |
| Diletant | 167:bedc0a9d559a | 94 | int32_t counter; |
| Diletant | 167:bedc0a9d559a | 95 | int32_t average; //Average bias value - -0.5...+0.5 in 16.16 format |
| Diletant | 167:bedc0a9d559a | 96 | } DevicePLCSBiasState; |
| Diletant | 167:bedc0a9d559a | 97 | |
| Diletant | 167:bedc0a9d559a | 98 | typedef struct _DevicePLCSBias { |
| Diletant | 167:bedc0a9d559a | 99 | DevicePLCSBiasSettings settings; |
| Diletant | 167:bedc0a9d559a | 100 | DevicePLCSBiasState state; |
| Diletant | 167:bedc0a9d559a | 101 | } DevicePLCSBias; |
| Diletant | 166:c3c0b8a90d81 | 102 | |
| Diletant | 167:bedc0a9d559a | 103 | //Path length control system regulator typedefs |
| Diletant | 167:bedc0a9d559a | 104 | typedef struct _DevicePLCSCorrectionTransferFunction { |
| Diletant | 167:bedc0a9d559a | 105 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 106 | int32_t error[16]; //Regulator error value - degrees in 16.16 format |
| Diletant | 167:bedc0a9d559a | 107 | int32_t correction[16]; //Regulator correction value - volts in 16.16 format |
| Diletant | 167:bedc0a9d559a | 108 | } DevicePLCSCorrectionTransferFunction; |
| Diletant | 167:bedc0a9d559a | 109 | |
| Diletant | 167:bedc0a9d559a | 110 | typedef struct _DevicePLCSRegulatorSettings { |
| Diletant | 167:bedc0a9d559a | 111 | uint8_t enabled; |
| Diletant | 167:bedc0a9d559a | 112 | uint32_t reference; //signed 16.16 format reference bias |
| Diletant | 167:bedc0a9d559a | 113 | //uint32_t scale; //signed 16.16 format regulator scale factor |
| Diletant | 167:bedc0a9d559a | 114 | DevicePLCSCorrectionTransferFunction transfer; |
| Diletant | 167:bedc0a9d559a | 115 | } DevicePLCSRegulatorSettings; |
| Diletant | 167:bedc0a9d559a | 116 | |
| Diletant | 167:bedc0a9d559a | 117 | typedef struct _DevicePLCSRegulatorState { |
| Diletant | 167:bedc0a9d559a | 118 | uint8_t enabled; |
| Diletant | 167:bedc0a9d559a | 119 | uint32_t reference; //signed 16.16 format reference bias |
| Diletant | 167:bedc0a9d559a | 120 | //uint32_t scale; //signed 16.16 format regulator scale factor |
| Diletant | 167:bedc0a9d559a | 121 | uint32_t error; //signed 16.16 format regulator error |
| Diletant | 167:bedc0a9d559a | 122 | uint32_t correction;//signed 16.16 format output correction |
| Diletant | 167:bedc0a9d559a | 123 | } DevicePLCSRegulatorState; |
| Diletant | 156:e68ee0bcdcda | 124 | |
| Diletant | 167:bedc0a9d559a | 125 | typedef struct _DevicePLCSRegulator { |
| Diletant | 167:bedc0a9d559a | 126 | DevicePLCSRegulatorSettings settings; |
| Diletant | 167:bedc0a9d559a | 127 | DevicePLCSRegulatorState state; |
| Diletant | 167:bedc0a9d559a | 128 | } DevicePLCSRegulator; |
| Diletant | 167:bedc0a9d559a | 129 | |
| Diletant | 167:bedc0a9d559a | 130 | //Path length control reset typedefs |
| Diletant | 167:bedc0a9d559a | 131 | typedef struct _DevicePLCSResetTemperatureFunction { |
| Diletant | 167:bedc0a9d559a | 132 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 167:bedc0a9d559a | 133 | int32_t temperature[16]; //Output reset temperature value - centigrade, 16.16 format |
| Diletant | 167:bedc0a9d559a | 134 | int32_t voltage[16]; //Output reset level value - volts, 16.16 format |
| Diletant | 167:bedc0a9d559a | 135 | uint32_t duration[16]; //Output reset duration value - seconds, 16.16 format |
| Diletant | 167:bedc0a9d559a | 136 | } DevicePLCSResetTemperatureFunction; |
| Diletant | 167:bedc0a9d559a | 137 | |
| Diletant | 167:bedc0a9d559a | 138 | typedef struct _DevicePLCSResetLevels { |
| Diletant | 167:bedc0a9d559a | 139 | int32_t upper; //Upper reset level output voltage |
| Diletant | 167:bedc0a9d559a | 140 | int32_t lower; //Lower reset level output voltage |
| Diletant | 167:bedc0a9d559a | 141 | } DevicePLCSResetLevels; |
| Diletant | 167:bedc0a9d559a | 142 | |
| Diletant | 167:bedc0a9d559a | 143 | typedef struct _DevicePLCSResetState { |
| Diletant | 167:bedc0a9d559a | 144 | int32_t countdown; //reset countdown - seconds, 16.16 format |
| Diletant | 167:bedc0a9d559a | 145 | int32_t voltage; |
| Diletant | 167:bedc0a9d559a | 146 | } DevicePLCSResetState; |
| Diletant | 167:bedc0a9d559a | 147 | |
| Diletant | 167:bedc0a9d559a | 148 | typedef struct _DevicePLCSReset { |
| Diletant | 167:bedc0a9d559a | 149 | DevicePLCSResetLevels levels; |
| Diletant | 167:bedc0a9d559a | 150 | DevicePLCSResetTemperatureFunction up; |
| Diletant | 167:bedc0a9d559a | 151 | DevicePLCSResetTemperatureFunction down; |
| Diletant | 167:bedc0a9d559a | 152 | DevicePLCSResetState state; |
| Diletant | 167:bedc0a9d559a | 153 | } DevicePLCSReset; |
| Diletant | 166:c3c0b8a90d81 | 154 | |
| Diletant | 166:c3c0b8a90d81 | 155 | //Path length control system output ( = DAC + amplifier + control unit + heater/piezo) typedefs |
| Diletant | 167:bedc0a9d559a | 156 | typedef struct _DevicePLCSOutputStart { |
| Diletant | 167:bedc0a9d559a | 157 | int32_t voltage; //Output voltage in signed 16.16 fixed point format |
| Diletant | 167:bedc0a9d559a | 158 | } DevicePLCSOutputStart; |
| Diletant | 167:bedc0a9d559a | 159 | |
| Diletant | 167:bedc0a9d559a | 160 | typedef struct _DevicePLCSOutputTransferFunction { |
| Diletant | 166:c3c0b8a90d81 | 161 | uint32_t points; //Number of actual control points (up to 16) |
| Diletant | 166:c3c0b8a90d81 | 162 | int32_t voltage[16]; //Output voltage control points in signed 16.16 fixed point format |
| Diletant | 166:c3c0b8a90d81 | 163 | int32_t code[16]; //DAC code control points |
| Diletant | 167:bedc0a9d559a | 164 | } DevicePLCSOutputTransferFunction; |
| Diletant | 166:c3c0b8a90d81 | 165 | |
| Diletant | 166:c3c0b8a90d81 | 166 | typedef struct _DevicePLCSOutputSettings { |
| Diletant | 166:c3c0b8a90d81 | 167 | uint8_t enabled; //Enable DAC output |
| Diletant | 167:bedc0a9d559a | 168 | DevicePLCSOutputStart start; |
| Diletant | 167:bedc0a9d559a | 169 | DevicePLCSOutputTransferFunction transfer; |
| Diletant | 166:c3c0b8a90d81 | 170 | } DevicePLCSOutputSettings; |
| Diletant | 166:c3c0b8a90d81 | 171 | |
| Diletant | 166:c3c0b8a90d81 | 172 | typedef struct _DevicePLCSOutputState { |
| Diletant | 166:c3c0b8a90d81 | 173 | uint8_t enabled; //Enable DAC output |
| Diletant | 166:c3c0b8a90d81 | 174 | uint32_t voltage; //Voltage output |
| Diletant | 167:bedc0a9d559a | 175 | uint32_t code; //Code output |
| Diletant | 166:c3c0b8a90d81 | 176 | } DevicePLCSOutputState; |
| Diletant | 166:c3c0b8a90d81 | 177 | |
| Diletant | 166:c3c0b8a90d81 | 178 | typedef struct _DevicePLCSOutput { |
| Diletant | 166:c3c0b8a90d81 | 179 | DevicePLCSOutputSettings settings; |
| Diletant | 166:c3c0b8a90d81 | 180 | DevicePLCSOutputState state; |
| Diletant | 166:c3c0b8a90d81 | 181 | } DevicePLCSOutput; |
| Diletant | 156:e68ee0bcdcda | 182 | |
| Diletant | 161:efd949e8d536 | 183 | //Path length control system typedefs |
| Diletant | 166:c3c0b8a90d81 | 184 | // Information signal amplitude ADC: device.controller.SSP.ADC[4] |
| Diletant | 161:efd949e8d536 | 185 | // Path length control system DAC: device.controller.SSP.DAC[1] |
| Diletant | 149:abbf7663d27d | 186 | typedef struct _DevicePathLengthControlSystem { |
| Diletant | 166:c3c0b8a90d81 | 187 | DevicePLCSSequencer sequencer; |
| Diletant | 167:bedc0a9d559a | 188 | DevicePLCSFeedback feedback; |
| Diletant | 167:bedc0a9d559a | 189 | DevicePLCSReference reference; |
| Diletant | 167:bedc0a9d559a | 190 | DevicePLCSDetector detector; |
| Diletant | 167:bedc0a9d559a | 191 | DevicePLCSBias bias; |
| Diletant | 167:bedc0a9d559a | 192 | DevicePLCSRegulator regulator; |
| Diletant | 167:bedc0a9d559a | 193 | DevicePLCSReset reset; |
| Diletant | 166:c3c0b8a90d81 | 194 | DevicePLCSOutput output; |
| Diletant | 149:abbf7663d27d | 195 | } DevicePathLengthControlSystem; |
| Diletant | 149:abbf7663d27d | 196 | |
| Diletant | 161:efd949e8d536 | 197 | //Path length control system functions |
| Diletant | 167:bedc0a9d559a | 198 | void InitPathLengthControlSystemDefaultSettings(void); |
| Diletant | 167:bedc0a9d559a | 199 | void InitPathLengthControlSystemState(void); |
| Diletant | 167:bedc0a9d559a | 200 | void DeviceStartPLCS(void); |
| Diletant | 149:abbf7663d27d | 201 | |
| Diletant | 166:c3c0b8a90d81 | 202 | void plcsProcess(void); |
| Diletant | 166:c3c0b8a90d81 | 203 | |
| Diletant | 149:abbf7663d27d | 204 | #endif /* __DEVICE_PLCS_H__ */ |
