123

Dependencies:   mbed

Fork of LG by igor Apu

DevicePLCS.h

Committer:
Diletant
Date:
2016-07-03
Revision:
177:672ef279c8e0
Parent:
173:7f938afb0447
Child:
183:c7a9c309086c

File content as of revision 177:672ef279c8e0:

#ifndef __DEVICE_PLCS_H__
#define __DEVICE_PLCS_H__

//Path length control system phase feedback typedefs
typedef struct _DevicePLCSFeedbackTransferFunction {
  uint32_t points;     //Number of actual control points (up to 16)
  int32_t raw[16]; //Feedback raw value - volts in 16.16 format
  int32_t normalized[16];//Feedback normalized value - -1...+1 in 16.16 format
} DevicePLCSFeedbackTransferFunction;

typedef struct _DevicePLCSFeedbackSettings {
  uint8_t input;      //Take ISACS input as feedback
  uint8_t output;     //Take ISACS output as feedback
  DevicePLCSFeedbackTransferFunction transfer;
} DevicePLCSFeedbackSettings;

typedef struct _DevicePLCSFeedbackState {
  uint8_t input;      //Take ISACS input as feedback
  uint8_t output;     //Take ISACS output as feedback
  uint32_t voltage;   //Feedback - volts in 16.16 format
} DevicePLCSFeedbackState;

typedef struct _DevicePLCSFeedback {
  DevicePLCSFeedbackSettings settings;
  DevicePLCSFeedbackState state;
} DevicePLCSFeedback;

//Path length control system reference typedefs
typedef struct _DevicePLCSReferenceSettings {
  uint8_t sequencer;  //Take sequencer as reference (and ISACS amplitude/output as feedback)
  uint8_t delta;      //Take delta as reference (and ISACS amplitude/output delta as feedback)
} DevicePLCSReferenceSettings;

typedef struct _DevicePLCSReferenceState {
  uint8_t sequencer;  //Take sequencer as reference (and ISACS amplitude/output as feedback)
  uint8_t delta;      //Take delta as reference (and ISACS amplitude/output delta as feedback)
} DevicePLCSReferenceState;

typedef struct _DevicePLCSReference {
  DevicePLCSReferenceSettings settings;
  DevicePLCSReferenceState state;
} DevicePLCSReference;

//Path length control system detector typedefs
typedef struct _DevicePLCSDetectorState {
  int32_t in[2]; //Detector inputs: reference, feedback -1...+1 in 16.16 format
  int32_t out;   //Detector output: -1...+1 in 16.16 format
} DevicePLCSDetectorState;

typedef struct _DevicePLCSDetector {
  DevicePLCSDetectorState state;
} DevicePLCSDetector;

//Path length control system bias typedefs
typedef struct _DevicePLCSBiasTransferFunction {
  uint32_t points;    //Number of actual control points (up to 16)
  int32_t raw[16];    //Raw bias value - dimensionless units
  int32_t normalized[16]; //Normalized bias value - -0.5...+0.5 of lambda in 16.16 format
} DevicePLCSBiasTransferFunction;

typedef struct _DevicePLCSBiasSettings {
  DevicePLCSBiasTransferFunction transfer;
} DevicePLCSBiasSettings;

typedef struct _DevicePLCSBiasState {
  uint32_t raw;       //Raw bias value - -0.5...+0.5 in 16.16 format
  int32_t sum;
  int32_t counter;
  int32_t average;    //Average bias value - -0.5...+0.5 in 16.16 format
} DevicePLCSBiasState;

typedef struct _DevicePLCSBias {
  DevicePLCSBiasSettings settings;
  DevicePLCSBiasState state;
} DevicePLCSBias;

//Path length control system regulator typedefs
typedef struct _DevicePLCSCorrectionTransferFunction {
  uint32_t points;        //Number of actual control points (up to 16)
  int32_t error[16];      //Regulator error value - degrees in 16.16 format
  int32_t correction[16]; //Regulator correction value - -1...+1 in 16.16 format
} DevicePLCSCorrectionTransferFunction;

typedef struct _DevicePLCSRegulatorSettings {
  uint8_t enabled;
  int32_t reference; //Reference bias - signed 16.16 format
  int32_t scale;     //Regulator scale factor - signed 16.16 format
  DevicePLCSCorrectionTransferFunction transfer;
} DevicePLCSRegulatorSettings;

typedef struct _DevicePLCSRegulatorState {
  uint8_t enabled;
  int32_t reference; //Reference bias - signed 16.16 format
  int32_t scale;     //Regulator scale factor - signed 16.16 format
  int32_t error;     //Regulator error - signed 16.16 format
  int32_t correction;//Output correction - signed 16.16 format 
} DevicePLCSRegulatorState;

typedef struct _DevicePLCSRegulator {
  DevicePLCSRegulatorSettings settings;
  DevicePLCSRegulatorState state;
} DevicePLCSRegulator;

//Path length control reset typedefs
typedef struct _DevicePLCSResetTemperatureFunction {
  uint32_t points;         //Number of actual control points (up to 16)
  int32_t temperature[16]; //Output reset temperature value - centigrade, 16.16 format
  int32_t voltage[16];     //Output reset level value - volts, 16.16 format
  uint32_t duration[16];   //Output reset duration value - seconds, 16.16 format
} DevicePLCSResetTemperatureFunction;

typedef struct _DevicePLCSResetLevels {
  int32_t upper; //Upper reset level output voltage
  int32_t lower; //Lower reset level output voltage
} DevicePLCSResetLevels;

typedef struct _DevicePLCSResetState {
  int32_t countdown; //reset countdown - seconds, 16.16 format
  int32_t voltage;
} DevicePLCSResetState;

typedef struct _DevicePLCSReset {
  DevicePLCSResetLevels levels;
  DevicePLCSResetTemperatureFunction up;
  DevicePLCSResetTemperatureFunction down;
  DevicePLCSResetState state;
} DevicePLCSReset;

//Path length control system output ( = DAC + amplifier + control unit + heater/piezo) typedefs
typedef struct _DevicePLCSOutputStart {
  int32_t voltage;     //Output voltage in signed 16.16 fixed point format
} DevicePLCSOutputStart;

typedef struct _DevicePLCSOutputTransferFunction {
  uint32_t points;     //Number of actual control points (up to 16)
  int32_t voltage[16]; //Output voltage control points in signed 16.16 fixed point format
  int32_t code[16];    //DAC code control points
} DevicePLCSOutputTransferFunction;

typedef struct _DevicePLCSOutputSettings {
  uint8_t enabled;     //Enable DAC output
  uint8_t sequencer;   //Enable sequencer output summation
  DevicePLCSOutputStart start;
  DevicePLCSOutputTransferFunction transfer;
} DevicePLCSOutputSettings;

typedef struct _DevicePLCSOutputState {
  uint8_t enabled;     //Enable DAC output
  uint8_t sequencer;   //Enable sequencer output summation
  uint32_t voltage;    //Voltage output 
  uint32_t code;       //Code output 
} DevicePLCSOutputState;

typedef struct _DevicePLCSOutput {
  DevicePLCSOutputSettings settings;
  DevicePLCSOutputState state;
} DevicePLCSOutput;

//Path length control system typedefs
//  Information signal amplitude ADC: device.controller.SSP.ADC[4]
//  Path length control system DAC: device.controller.SSP.DAC[1]
typedef struct _DevicePathLengthControlSystem {
  //DevicePLCSSequencer sequencer;
  DevicePLCSFeedback feedback;
  DevicePLCSReference reference;
  DevicePLCSDetector detector;
  DevicePLCSBias bias;
  DevicePLCSRegulator regulator;
  DevicePLCSReset reset;
  DevicePLCSOutput output;
} DevicePathLengthControlSystem;

//Path length control system functions
void InitPathLengthControlSystemDefaultSettings(void);
void InitPathLengthControlSystemState(void);
void DeviceStartPLCS(void);

void plcsProcess(void);

#endif  /* __DEVICE_PLCS_H__ */