123
Fork of LG by
Diff: DeviceISACS.h
- Revision:
- 198:78dd6d14d108
- Parent:
- 197:7a05523bf588
diff -r 7a05523bf588 -r 78dd6d14d108 DeviceISACS.h --- a/DeviceISACS.h Wed Oct 19 10:55:05 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -#ifndef __DEVICE_ISACS_H__ -#define __DEVICE_ISACS_H__ - -#include "DeviceISACSPotentiometers.h" - -//Information signal amplitude control system -// input(photodetector - amplifier - potentiometers - amplitude detector - ADC - low pass filter - code - voltage) -// regulator -// output(voltage - code - DAC - Amplifier - control unit - hfo) - -//Information signal amplitude control system input ( = ADC - low pass filter - code - voltage) typedefs -typedef struct _DeviceISACSInputTransferFunction { - uint32_t points; //Number of actual control points (up to 16) - int32_t V[16]; //Input voltage control points - V in signed 16.16 fixed point format - int32_t raw[16]; //Input voltage control points - DAC code -} DeviceISACSInputTransferFunction; - -typedef struct _DeviceISACSInputSettings { - DeviceISACSInputTransferFunction transfer; -} DeviceISACSInputSettings; - -typedef struct _DeviceISACSInputState { - int32_t sum; //Sum of cycle current measurements - ADC code - updates 32 times per cycle - int32_t raw; //Average input - ADC code - updates 1 time per cycle - int32_t V; //Average input - volts in 16.16 format - updates 1 time per cycle -} DeviceISACSInputState; - -typedef struct _DeviceISACSInput { - DeviceISACSInputSettings settings; - DeviceISACSInputState state; -} DeviceISACSInput; - -//Information signal amplitude control system output ( = DAC + amplifier + control unit + hfo) typedefs -typedef struct _DeviceISACSOutputTransferFunction { - uint32_t points; //Number of actual control points (up to 16) - int32_t voltage[16]; //Output voltage control points - V in signed 16.16 fixed point format - int32_t code[16]; //DAC code control points -} DeviceISACSOutputTransferFunction; - -typedef struct _DeviceISACSOutputStart { - int32_t voltage; //Output - volts in 16.16 format -} DeviceISACSOutputStart; - -typedef struct _DeviceISACSOutputReset { - int32_t voltage; //Output - volts in 16.16 format -} DeviceISACSOutputReset; - -typedef struct _DeviceISACSOutputSettings { - uint32_t max; //Maximum output voltage in 16.16 format. TODO: max(temperature - uint32_t min; //Minimum output voltage in 16.16 format. TODO: max(temperature - DeviceISACSOutputTransferFunction transfer; - DeviceISACSOutputStart start; - DeviceISACSOutputReset reset; -} DeviceISACSOutputSettings; - -typedef struct _DeviceISACSOutputState { - uint32_t max; //Maximum output voltage in 16.16 format - uint32_t min; //Minimum output voltage in 16.16 format - int32_t voltage; //Output - volts in 16.16 format - updates 1 time per cycle -} DeviceISACSOutputState; - -typedef struct _DeviceISACSOutput { - DeviceISACSOutputSettings settings; - DeviceISACSOutputState state; -} DeviceISACSOutput; - -//Information signal amplitude control system regulator typedefs -typedef struct _DeviceISACSCorrectionTransferFunction { - uint32_t points; //Number of actual control points (up to 16) - int32_t error[16]; //Regulator error - V in signed 16.16 fixed point format - int32_t correction[16]; //Output correction - -1...+1 in signed 16.16 fixed point format -} DeviceISACSCorrectionTransferFunction; - -typedef struct _DeviceISACSRegulatorConditionSettings { - uint8_t enabled; - int32_t reference; //Reference input - volts in 16.16 format - int32_t scale; //Regulator scale factor - dimensionless units in signed 16.16 format -} DeviceISACSRegulatorConditionSettings; - -typedef struct _DeviceISACSRegulatorSettings { - DeviceISACSRegulatorConditionSettings start; //Regulator settings for ISACS system in start condition - DeviceISACSRegulatorConditionSettings regular; //Regulator settings for ISACS system in normal condition - DeviceISACSRegulatorConditionSettings reset; //Regulator settings for ISACS system in reset condition - DeviceISACSCorrectionTransferFunction transfer; //Regulator correction function -} DeviceISACSRegulatorSettings; - -typedef struct _DeviceISACSRegulatorState { - uint8_t enabled; - int32_t reference; //Reference input - volts in 16.16 format - int32_t error; //Regulator error - volts in signed 16.16 format - int32_t scale; //Regulator scale factor - dimensionless units in signed 16.16 format - int32_t correction; //Output correction - V in signed 16.16 fixed point format -} DeviceISACSRegulatorState; - -typedef struct _DeviceISACSRegulator { - DeviceISACSRegulatorSettings settings; - DeviceISACSRegulatorState state; -} DeviceISACSRegulator; - -//Information signal amplitude control system typedefs -// Information signal amplitude ADC: device.controller.SSP.ADC[4] -// Information signal amplitude control system DAC: device.controller.SSP.DAC[0] -typedef struct _DeviceISACS { - DeviceISACSPotentiometers potentiometers; - DeviceISACSInput input; - DeviceISACSRegulator regulator; - DeviceISACSOutput output; -} DeviceISACS; - -//Information signal amplitude stabilizer functions -void InitISACSOutputDefaultSettings(void); -void InitISACSOutputState(void); -void DeviceStartISACSOutput(void); - -void InitISACSRegulatorDefaultSettings(void); -void InitISACSRegulatorState(void); -void DeviceStartISACSRegulator(void); - -void InitISACSDefaultSettings(void); -void InitISACSState(void); -void DeviceStartISACS(void); - -void isacsProcess(void); - -//Compatibility functions section -//HF_reg dac ttf: DAC code in HFO channel; value: voltage of HFO; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V -int16_t var_HF_reg(void); - -//HF_dif = HF_ref - HF_out -int16_t var_HF_dif(void); - -//HF_ref s16 value of the reference -uint16_t param_HF_ref(void); - -//HF_scl s16 HFO gain factor -uint16_t param_HF_scl(void); - -//HF_min dac ttf:minimum DAC code in HFO channel; value:maximal voltage of HFO; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V -uint16_t param_HF_min(void); - -//HF_max dac ttf:maximum DAC code in HFO channel; value:minimal voltage of HFO; value=(ttf>>4)/2048*(-12)-1.3; Range -13.2V...10.7V -uint16_t param_HF_max(void); - -#endif /* __DEVICE_ISACS_H__ */ \ No newline at end of file