123

Dependencies:   mbed

Fork of LG by igor Apu

DeviceISACS.h

Committer:
Diletant
Date:
2016-06-19
Revision:
173:7f938afb0447
Parent:
167:bedc0a9d559a
Child:
177:672ef279c8e0

File content as of revision 173:7f938afb0447:

#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 voltage[16]; //Output voltage control points in signed 16.16 fixed point format
  int32_t code[16];    //DAC code control points
} DeviceISACSInputTransferFunction;

typedef struct _DeviceISACSInputSettings {
  DeviceISACSInputTransferFunction transfer;
} DeviceISACSInputSettings;

typedef struct _DeviceISACSInputState {
  int32_t voltage;
  int32_t sum;
  int32_t average;
} 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 in signed 16.16 fixed point format
  int32_t code[16];    //DAC code control points
} DeviceISACSOutputTransferFunction;

typedef struct _DeviceISACSOutputStart {
  uint32_t voltage;    //Output voltage
} DeviceISACSOutputStart;

typedef struct _DeviceISACSOutputReset {
  uint32_t voltage;    //Output voltage
} DeviceISACSOutputReset;

typedef struct _DeviceISACSOutputSettings {
  DeviceISACSOutputTransferFunction transfer;
  DeviceISACSOutputStart start;
  DeviceISACSOutputReset reset;
} DeviceISACSOutputSettings;

typedef struct _DeviceISACSOutputState {
  int32_t voltage;     //Output value - constant for measurement cycle
} DeviceISACSOutputState;

typedef struct _DeviceISACSOutput {
  DeviceISACSOutputSettings settings;
  DeviceISACSOutputState state;
} 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 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);

#endif  /* __DEVICE_ISACS_H__ */