123

Dependencies:   mbed

Fork of LG by igor Apu

DeviceISACS.h

Committer:
Diletant
Date:
2016-05-22
Revision:
166:c3c0b8a90d81
Parent:
161:efd949e8d536
Child:
167:bedc0a9d559a

File content as of revision 166:c3c0b8a90d81:

#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 _DeviceISACSInputInterpolatorSettings {
  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
} DeviceISACSInputInterpolatorSettings;

typedef struct _DeviceISACSInputInterpolator {
  DeviceISACSInputInterpolatorSettings settings;
} DeviceISACSInputInterpolator;

typedef struct _DeviceISACSInput {
  int32_t voltage;
  int32_t sum;
  int32_t average;
  DeviceISACSInputInterpolator interpolator;
  //DeviceISACSFilter filter;
} DeviceISACSInput;

//Information signal amplitude control system output ( = DAC + amplifier + control unit + hfo) typedefs
typedef struct _DeviceISACSOutputInterpolatorSettings {
  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
} DeviceISACSOutputInterpolatorSettings;

typedef struct _DeviceISACSOutputInterpolator {
  DeviceISACSOutputInterpolatorSettings settings;
} DeviceISACSOutputInterpolator;

/*
typedef struct _DeviceISACSOutputConditionSettings {
  int32_t voltage; //Output voltage in signed 16.16 fixed point format
} DeviceISACSOutputConditionSettings;

typedef struct _DeviceISACSOutputSettings {
  DeviceISACSOutputInterpolatorSettings interpolator;
  DeviceISACSOutputConditionSettings start;
  DeviceISACSOutputConditionSettings reset;
} DeviceISACSOutputSettings;
*/

typedef struct _DeviceISACSOutputStartSettings {
  uint32_t voltage;     //Output voltage
} DeviceISACSOutputStartSettings;

typedef struct _DeviceISACSOutputStart {
  DeviceISACSOutputStartSettings settings;
} DeviceISACSOutputStart;

typedef struct _DeviceISACSOutputResetSettings {
  uint32_t voltage;     //Output voltage
} DeviceISACSOutputResetSettings;

typedef struct _DeviceISACSOutputReset {
  DeviceISACSOutputResetSettings settings;
} DeviceISACSOutputReset;

typedef struct _DeviceISACSOutput {
  int32_t voltage;  //Output value - constant for measurement cycle
  DeviceISACSOutputInterpolator interpolator;
  DeviceISACSOutputStart start;
  DeviceISACSOutputReset reset;
} DeviceISACSOutput;

//Information signal amplitude control system regulator typedefs
typedef struct _DeviceISACSRegulatorConditionSettings {
  uint8_t enabled;
  uint32_t reference; //signed 16.16 format reference voltage
  uint32_t scale;     //signed 16.16 format regulator scale factor
} DeviceISACSRegulatorConditionSettings;

typedef struct _DeviceISACSRegulatorSettings {
  DeviceISACSRegulatorConditionSettings start;   //settings for PLCS system in start condition
  DeviceISACSRegulatorConditionSettings regular; //settings for PLCS system in normal condition
  DeviceISACSRegulatorConditionSettings reset;   //settings for PLCS system in reset condition
} DeviceISACSRegulatorSettings;

typedef struct _DeviceISACSRegulatorState {
  uint8_t enabled;
  uint32_t reference; //signed 16.16 format reference voltage
  uint32_t scale;     //signed 16.16 format regulator scale factor
  uint32_t error;     //signed 16.16 format regulator error
} 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;
  //DeviceISASAmplifier amplifier;
  DeviceISACSInput input;
  DeviceISACSRegulator regulator;
  DeviceISACSOutput output;
} DeviceISACS;

//Information signal amplitude stabilizer functions
void InitISACSPotentiometersWithDefaults(void);
void InitISACSPotentiometers(void);

void InitISACSOutputWithDefaults(void);
void InitISACSOutput(void);

void InitISACSRegulatorWithDefaults(void);
void InitISACSRegulator(void);

void InitISACSWithDefaults(void);
void InitISACS(void);
void StartISACS(void);

void isacsProcess(void);

#endif  /* __DEVICE_ISACS_H__ */