123
Fork of LG by
DeviceISACS.h@177:672ef279c8e0, 2016-07-03 (annotated)
- Committer:
- Diletant
- Date:
- Sun Jul 03 13:40:48 2016 +0000
- Revision:
- 177:672ef279c8e0
- Parent:
- 173:7f938afb0447
- Child:
- 183:c7a9c309086c
Device&... update. Some Ask_Gld functionality. Not final!!!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Diletant | 161:efd949e8d536 | 1 | #ifndef __DEVICE_ISACS_H__ |
Diletant | 161:efd949e8d536 | 2 | #define __DEVICE_ISACS_H__ |
Diletant | 161:efd949e8d536 | 3 | |
Diletant | 161:efd949e8d536 | 4 | #include "DeviceISACSPotentiometers.h" |
Diletant | 161:efd949e8d536 | 5 | |
Diletant | 161:efd949e8d536 | 6 | //Information signal amplitude control system |
Diletant | 161:efd949e8d536 | 7 | // input(photodetector - amplifier - potentiometers - amplitude detector - ADC - low pass filter - code - voltage) |
Diletant | 161:efd949e8d536 | 8 | // regulator |
Diletant | 161:efd949e8d536 | 9 | // output(voltage - code - DAC - Amplifier - control unit - hfo) |
Diletant | 161:efd949e8d536 | 10 | |
Diletant | 166:c3c0b8a90d81 | 11 | //Information signal amplitude control system input ( = ADC - low pass filter - code - voltage) typedefs |
Diletant | 167:bedc0a9d559a | 12 | typedef struct _DeviceISACSInputTransferFunction { |
Diletant | 166:c3c0b8a90d81 | 13 | uint32_t points; //Number of actual control points (up to 16) |
Diletant | 177:672ef279c8e0 | 14 | int32_t V[16]; //Input voltage control points - V in signed 16.16 fixed point format |
Diletant | 177:672ef279c8e0 | 15 | int32_t raw[16]; //Input voltage control points - DAC code |
Diletant | 167:bedc0a9d559a | 16 | } DeviceISACSInputTransferFunction; |
Diletant | 166:c3c0b8a90d81 | 17 | |
Diletant | 167:bedc0a9d559a | 18 | typedef struct _DeviceISACSInputSettings { |
Diletant | 167:bedc0a9d559a | 19 | DeviceISACSInputTransferFunction transfer; |
Diletant | 167:bedc0a9d559a | 20 | } DeviceISACSInputSettings; |
Diletant | 167:bedc0a9d559a | 21 | |
Diletant | 167:bedc0a9d559a | 22 | typedef struct _DeviceISACSInputState { |
Diletant | 177:672ef279c8e0 | 23 | int32_t sum; //Sum of cycle current measurements - ADC code - updates 32 times per cycle |
Diletant | 177:672ef279c8e0 | 24 | int32_t raw; //Average input - ADC code - updates 1 time per cycle |
Diletant | 177:672ef279c8e0 | 25 | int32_t V; //Average input - volts in 16.16 format - updates 1 time per cycle |
Diletant | 167:bedc0a9d559a | 26 | } DeviceISACSInputState; |
Diletant | 167:bedc0a9d559a | 27 | |
Diletant | 167:bedc0a9d559a | 28 | typedef struct _DeviceISACSInput { |
Diletant | 167:bedc0a9d559a | 29 | DeviceISACSInputSettings settings; |
Diletant | 167:bedc0a9d559a | 30 | DeviceISACSInputState state; |
Diletant | 166:c3c0b8a90d81 | 31 | } DeviceISACSInput; |
Diletant | 166:c3c0b8a90d81 | 32 | |
Diletant | 161:efd949e8d536 | 33 | //Information signal amplitude control system output ( = DAC + amplifier + control unit + hfo) typedefs |
Diletant | 167:bedc0a9d559a | 34 | typedef struct _DeviceISACSOutputTransferFunction { |
Diletant | 173:7f938afb0447 | 35 | uint32_t points; //Number of actual control points (up to 16) |
Diletant | 177:672ef279c8e0 | 36 | int32_t voltage[16]; //Output voltage control points - V in signed 16.16 fixed point format |
Diletant | 166:c3c0b8a90d81 | 37 | int32_t code[16]; //DAC code control points |
Diletant | 167:bedc0a9d559a | 38 | } DeviceISACSOutputTransferFunction; |
Diletant | 166:c3c0b8a90d81 | 39 | |
Diletant | 167:bedc0a9d559a | 40 | typedef struct _DeviceISACSOutputStart { |
Diletant | 177:672ef279c8e0 | 41 | int32_t voltage; //Output - volts in 16.16 format |
Diletant | 167:bedc0a9d559a | 42 | } DeviceISACSOutputStart; |
Diletant | 166:c3c0b8a90d81 | 43 | |
Diletant | 167:bedc0a9d559a | 44 | typedef struct _DeviceISACSOutputReset { |
Diletant | 177:672ef279c8e0 | 45 | int32_t voltage; //Output - volts in 16.16 format |
Diletant | 167:bedc0a9d559a | 46 | } DeviceISACSOutputReset; |
Diletant | 166:c3c0b8a90d81 | 47 | |
Diletant | 166:c3c0b8a90d81 | 48 | typedef struct _DeviceISACSOutputSettings { |
Diletant | 177:672ef279c8e0 | 49 | uint32_t max; //Maximum output voltage in 16.16 format. TODO: max(temperature |
Diletant | 177:672ef279c8e0 | 50 | uint32_t min; //Minimum output voltage in 16.16 format. TODO: max(temperature |
Diletant | 167:bedc0a9d559a | 51 | DeviceISACSOutputTransferFunction transfer; |
Diletant | 167:bedc0a9d559a | 52 | DeviceISACSOutputStart start; |
Diletant | 167:bedc0a9d559a | 53 | DeviceISACSOutputReset reset; |
Diletant | 161:efd949e8d536 | 54 | } DeviceISACSOutputSettings; |
Diletant | 166:c3c0b8a90d81 | 55 | |
Diletant | 167:bedc0a9d559a | 56 | typedef struct _DeviceISACSOutputState { |
Diletant | 177:672ef279c8e0 | 57 | uint32_t max; //Maximum output voltage in 16.16 format |
Diletant | 177:672ef279c8e0 | 58 | uint32_t min; //Minimum output voltage in 16.16 format |
Diletant | 177:672ef279c8e0 | 59 | int32_t voltage; //Output - volts in 16.16 format - updates 1 time per cycle |
Diletant | 167:bedc0a9d559a | 60 | } DeviceISACSOutputState; |
Diletant | 161:efd949e8d536 | 61 | |
Diletant | 161:efd949e8d536 | 62 | typedef struct _DeviceISACSOutput { |
Diletant | 167:bedc0a9d559a | 63 | DeviceISACSOutputSettings settings; |
Diletant | 167:bedc0a9d559a | 64 | DeviceISACSOutputState state; |
Diletant | 161:efd949e8d536 | 65 | } DeviceISACSOutput; |
Diletant | 161:efd949e8d536 | 66 | |
Diletant | 161:efd949e8d536 | 67 | //Information signal amplitude control system regulator typedefs |
Diletant | 177:672ef279c8e0 | 68 | typedef struct _DeviceISACSCorrectionTransferFunction { |
Diletant | 177:672ef279c8e0 | 69 | uint32_t points; //Number of actual control points (up to 16) |
Diletant | 177:672ef279c8e0 | 70 | int32_t error[16]; //Regulator error - V in signed 16.16 fixed point format |
Diletant | 177:672ef279c8e0 | 71 | int32_t correction[16]; //Output correction - -1...+1 in signed 16.16 fixed point format |
Diletant | 177:672ef279c8e0 | 72 | } DeviceISACSCorrectionTransferFunction; |
Diletant | 177:672ef279c8e0 | 73 | |
Diletant | 161:efd949e8d536 | 74 | typedef struct _DeviceISACSRegulatorConditionSettings { |
Diletant | 166:c3c0b8a90d81 | 75 | uint8_t enabled; |
Diletant | 177:672ef279c8e0 | 76 | int32_t reference; //Reference input - volts in 16.16 format |
Diletant | 177:672ef279c8e0 | 77 | int32_t scale; //Regulator scale factor - dimensionless units in signed 16.16 format |
Diletant | 161:efd949e8d536 | 78 | } DeviceISACSRegulatorConditionSettings; |
Diletant | 161:efd949e8d536 | 79 | |
Diletant | 161:efd949e8d536 | 80 | typedef struct _DeviceISACSRegulatorSettings { |
Diletant | 177:672ef279c8e0 | 81 | DeviceISACSRegulatorConditionSettings start; //Regulator settings for ISACS system in start condition |
Diletant | 177:672ef279c8e0 | 82 | DeviceISACSRegulatorConditionSettings regular; //Regulator settings for ISACS system in normal condition |
Diletant | 177:672ef279c8e0 | 83 | DeviceISACSRegulatorConditionSettings reset; //Regulator settings for ISACS system in reset condition |
Diletant | 177:672ef279c8e0 | 84 | DeviceISACSCorrectionTransferFunction transfer; //Regulator correction function |
Diletant | 161:efd949e8d536 | 85 | } DeviceISACSRegulatorSettings; |
Diletant | 161:efd949e8d536 | 86 | |
Diletant | 161:efd949e8d536 | 87 | typedef struct _DeviceISACSRegulatorState { |
Diletant | 161:efd949e8d536 | 88 | uint8_t enabled; |
Diletant | 177:672ef279c8e0 | 89 | int32_t reference; //Reference input - volts in 16.16 format |
Diletant | 177:672ef279c8e0 | 90 | int32_t error; //Regulator error - volts in signed 16.16 format |
Diletant | 177:672ef279c8e0 | 91 | int32_t scale; //Regulator scale factor - dimensionless units in signed 16.16 format |
Diletant | 177:672ef279c8e0 | 92 | int32_t correction; //Output correction - V in signed 16.16 fixed point format |
Diletant | 161:efd949e8d536 | 93 | } DeviceISACSRegulatorState; |
Diletant | 161:efd949e8d536 | 94 | |
Diletant | 161:efd949e8d536 | 95 | typedef struct _DeviceISACSRegulator { |
Diletant | 161:efd949e8d536 | 96 | DeviceISACSRegulatorSettings settings; |
Diletant | 161:efd949e8d536 | 97 | DeviceISACSRegulatorState state; |
Diletant | 161:efd949e8d536 | 98 | } DeviceISACSRegulator; |
Diletant | 161:efd949e8d536 | 99 | |
Diletant | 161:efd949e8d536 | 100 | //Information signal amplitude control system typedefs |
Diletant | 166:c3c0b8a90d81 | 101 | // Information signal amplitude ADC: device.controller.SSP.ADC[4] |
Diletant | 161:efd949e8d536 | 102 | // Information signal amplitude control system DAC: device.controller.SSP.DAC[0] |
Diletant | 161:efd949e8d536 | 103 | typedef struct _DeviceISACS { |
Diletant | 161:efd949e8d536 | 104 | DeviceISACSPotentiometers potentiometers; |
Diletant | 166:c3c0b8a90d81 | 105 | DeviceISACSInput input; |
Diletant | 166:c3c0b8a90d81 | 106 | DeviceISACSRegulator regulator; |
Diletant | 161:efd949e8d536 | 107 | DeviceISACSOutput output; |
Diletant | 161:efd949e8d536 | 108 | } DeviceISACS; |
Diletant | 161:efd949e8d536 | 109 | |
Diletant | 161:efd949e8d536 | 110 | //Information signal amplitude stabilizer functions |
Diletant | 167:bedc0a9d559a | 111 | void InitISACSOutputDefaultSettings(void); |
Diletant | 167:bedc0a9d559a | 112 | void InitISACSOutputState(void); |
Diletant | 167:bedc0a9d559a | 113 | void DeviceStartISACSOutput(void); |
Diletant | 161:efd949e8d536 | 114 | |
Diletant | 167:bedc0a9d559a | 115 | void InitISACSRegulatorDefaultSettings(void); |
Diletant | 167:bedc0a9d559a | 116 | void InitISACSRegulatorState(void); |
Diletant | 167:bedc0a9d559a | 117 | void DeviceStartISACSRegulator(void); |
Diletant | 161:efd949e8d536 | 118 | |
Diletant | 167:bedc0a9d559a | 119 | void InitISACSDefaultSettings(void); |
Diletant | 167:bedc0a9d559a | 120 | void InitISACSState(void); |
Diletant | 167:bedc0a9d559a | 121 | void DeviceStartISACS(void); |
Diletant | 161:efd949e8d536 | 122 | |
Diletant | 166:c3c0b8a90d81 | 123 | void isacsProcess(void); |
Diletant | 166:c3c0b8a90d81 | 124 | |
Diletant | 161:efd949e8d536 | 125 | #endif /* __DEVICE_ISACS_H__ */ |