versadac  1
versadac - Scalable Recorder Firmware
eiot2srzi2.h
1 /*******************************************************************************
2 FILE : eiot2srzi2.h
3 VERSION : $Id$
4 AUTHOR : David Cozens
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : This file contains The t2500 module classes
7 
8  Modification for 8Hz execution (for Scalable Recorder)
9 
10 *******************************************************************************/
11 
12 #ifndef __EIOT2SRZI2_H
13 #define __EIOT2SRZI2_H
14 /* The following section is needed by eio_t25sr.c */
15 #include "eiot2srai2.h"
16 
17 #define ZAIC_MV_RANGE_LOW (-150.0) /* -150mV */
18 #define ZAIC_MV_RANGE_HIGH (150.0) /* 150mV */
19 
20 #define ZAIC_HIZ_RANGE_LOW (0.0) /* 0.0V */
21 #define ZAIC_HIZ_RANGE_HIGH (1800.0) /* 1.8V */
22 
23 /* Capability discovery functions use ZI2_NUMBER_OF_CALIBRATION_RANGES */
24 enum Zi2CalibrationRangeEnum
25 {
26  ZI2_CALIBRATION_RANGE_VOLTS,
27  ZI2_CALIBRATION_RANGE_MILLIVOLTS,
28  ZI2_CALIBRATION_RANGE_HiZ_VOLTS,
29  ZI2_CALIBRATION_RANGE_RTD_OHMS,
30  ZI2_CALIBRATION_RANGE_RTD_OHMS_HIGH,
31  ZI2_NUMBER_OF_CALIBRATION_RANGES
32 };
33 
34 
35 /* Capability discovery functions use ZI2_NUMBER_OF_CHANNELS */
36 enum Zi2Channels
37 {
38  ZI2_CHANNEL_1,
39  ZI2_CHANNEL_2,
40  ZI2_NUMBER_OF_CHANNELS
41 };
42 
43 #ifdef __cplusplus
44 
45 /* This section must never be included from C */
46 
47 
48 #include "eio_t25srm.h"
49 #include "dfc_ssm.h"
50 #include "rst_ssm.h"
51 #include "led_ssm.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 // All ranges are polled on a basic 125mS update cycle. Ancilliary readings
58 // such as CJ measurement are interleaved with zero reference measurements on alternate
59 // 125mS cycles. A variable of this type is maintained and toggled on each 125mS
60 // cycle to identify what we are doing.
61 enum Zi2UpdateCycles
62 {
63  ZI2_UPDATE_CYCLE_62_5mS,
64  ZI2_UPDATE_CYCLE_125mS,
65  ZI2_UPDATE_CYCLE_187_5mS,
66  ZI2_UPDATE_CYCLE_250mS,
67  ZI2_UPDATE_CYCLE_312_5mS,
68  ZI2_UPDATE_CYCLE_375mS,
69  ZI2_NUMBER_OF_UPDATE_CYCLES,
70 };
71 
72 enum Zi2FilterTypeEnum
73 {
74  ZI2_FILTER_TYPE_MAIN,
75  ZI2_FILTER_TYPE_AUX,
76  ZI2_NUMBER_OF_FILTER_TYPES
77 };
78 
79 enum Zi2OperatingRanges
80 {
81  /*
82  * The following is a list of the different input modes which are
83  * supported by the module.
84  * Note the suffexes BL, and BH determine which way the MeasuredValue drifts
85  * on a input wire break. This does not always correspond with the VWIRE setting
86  */
87  ZAIC_MODE_OFF, /* +/- 150 milliVolt range is used, output is ignored */
88 
89  /* HiZ only for channel 2 */
90  ZAIC_MODE_HIGHZ, /* High impedence 0.0..1.8 Volt input */
91 
92  /* The TC ranges are only to be used on channel 1 */
93  ZAIC_MODE_TC_BL, /* Thermocouple for CJC (Break Low) */
94  ZAIC_MODE_TC, /* Thermocouple for CJC */
95  ZAIC_MODE_TC_BH, /* Thermocouple for CJC (Break High) */
96 
97  ZAIC_MODE_UNSUPPORTED,/* +/- 150 millivolt range is used, PV is forced to a fault condition */
98  NUMBER_OF_ZAIC_MODES,
99 
100 };
101 
102 
103 enum Zi2RunStates
104 {
105  EIO_T2500ZI2_STATE_MODULE_NEEDS_RESET,
106  EIO_T2500ZI2_STATE_INITIALISING,
107  EIO_T2500ZI2_STATE_RUNTIME,
108  EIO_T2500ZI2_STATE_DELETE,
109  EIO_T2500ZI2_STATE_SECONDARY,
110  EIO_T2500ZI2_STATE_BECOMING_PRIMARY_1,
111  EIO_T2500ZI2_STATE_BECOMING_PRIMARY_2,
112 };
113 
114 enum Zi2EepromAccessState
115 {
116  ZI2_EEPROM_RESET_STATE,
117  ZI2_EEPROM_READ_CHANNEL_1_USER_CALIBRATION,
118  ZI2_EEPROM_READ_CHANNEL_2_USER_CALIBRATION,
119  ZI2_EEPROM_READ_CHANNEL_1_FACTORY_CALIBRATION,
120  ZI2_EEPROM_READ_CHANNEL_2_FACTORY_CALIBRATION,
121  ZI2_EEPROM_IDLE,
122  ZI2_EEPROM_WRITE,
123  ZI2_EEPROM_WRITE_DONE
124 };
125 
126 // internal states of the calibration state machine
127 enum Zi2CalibrationState
128 {
129  ZI2_CAL_STATE_IDLE,
130  ZI2_CAL_STATE_WAIT_FOR_RANGE,
131  ZI2_CAL_STATE_INIT,
132  ZI2_CAL_STATE_RUNNING,
133  ZI2_CAL_STATE_DATA_GATHERED,
134  ZI2_CAL_STATE_WAIT_FOR_VALUE,
135  ZI2_CAL_STATE_POINT_DONE,
136  ZI2_CAL_STATE_SAVE,
137  ZI2_CAL_STATE_SAVE_LOW_POINT,
138  ZI2_CAL_STATE_SAVE_HIGH_POINT,
139  ZI2_CAL_STATE_DATA_SAVED,
140  ZI2_CAL_STATE_RESTORE,
141  ZI2_CAL_STATE_END_CAL
142 };
143 
144 enum Zi2CalibrationPoints
145 {
146  ZI2_CAL_POINT_LOW,
147  ZI2_CAL_POINT_HIGH,
148  ZI2_NUMBER_OF_CALIBRATION_POINTS
149 };
150 
151 typedef struct
152 {
153  DsmTotalConfigDataType m_cycleData[ZI2_NUMBER_OF_UPDATE_CYCLES];
154 }Zi2RangeTotalConfig;
155 
156 class EioT2500ZI2Module:public EioT2500Module
157 {
158  public:
159  EioT2500ZI2Module(unsigned char moduleNumber, EioT2500CycleEnum z_expectedCycleNumber);
160  virtual ~EioT2500ZI2Module();
161 
162  protected:
163  virtual void update62_5mS();
164  virtual void update125mS();
165  virtual void updateBuffers125ms();
166  EioBoolean getCalibrated(EioUint8 channel, EioAICalType calType, EioUint8 rangeNumber);
167 
168  private:
169  void decipherCalibration();
170  void checkUserCalibration();
171 
172  Zi2OperatingRanges getOperatingRange(EioUint8 channel);
173  EioUint8 eeCheckBits( EioUint8 *bytePtr);
174  static void secondaryFilter( float sample, float *polep, float divisor, EioSint8 *resetp );
175  void driveChannelLeds();
176  void updateEepromImage125mS();
177  void disableAll62_5mS();
178  void disableAll125mS();
179  void updateCalibrationState();
180  void updateSensorMonitorDemand();
181 
182  Zi2RunStates m_state;
183  Zi2EepromAccessState m_eepromState;
184  Zi2CalibrationState m_calibrationState[ZI2_NUMBER_OF_CHANNELS];
185  float m_calibrationCoefficient1[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
186  float m_calibrationCoefficient2[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
187  bool m_rangeCalibrated[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
188  EioBoolean m_rangeFactoryCalibrated[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
189  EioBoolean m_rangeUserCalibrated[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
190  float m_oldCalCoefficient1[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
191  float m_oldCalCoefficient2[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
192  bool m_oldRangeCalibrated[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_RANGES];
193  bool m_factoryCalRead;
194  EioUint8 m_calCounter[ZI2_NUMBER_OF_CHANNELS];
195  EioUint32 m_calReading[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_POINTS];
196  EioUint32 m_deltaCounts[ZI2_NUMBER_OF_CHANNELS];
197  Zi2CalibrationPoints m_calPointIndex[ZI2_NUMBER_OF_CHANNELS];
198  float m_actualCalValue[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_CALIBRATION_POINTS];
199 
200  static float m_calScaleFactor;
201  static float m_calibrationRefLow[ZI2_NUMBER_OF_CALIBRATION_RANGES];
202  static float m_calibrationRefHigh[ZI2_NUMBER_OF_CALIBRATION_RANGES];
203  static Ai2CalibrationTypeEnum m_calType[ZI2_NUMBER_OF_CALIBRATION_RANGES];
204  static Zi2RangeTotalConfig m_rangeTotalConfig[NUMBER_OF_ZAIC_MODES];
205  static EioUint8 m_rangeRepeatCycles[NUMBER_OF_ZAIC_MODES];
206  static Zi2CalibrationRangeEnum m_calibrationRange[NUMBER_OF_ZAIC_MODES];
207  static Zi2OperatingRanges m_calOperatingRange[ZI2_NUMBER_OF_CALIBRATION_RANGES];
208  static char m_zi2Ident[];
209 
210 
211  // recovery messages
212  DfcDelaySpiScheduledMessage * m_delayMessage;
213  ResetSpiScheduledMessage * m_resetMessage;
214  DfcVWireDataReadySpiScheduledMessage * m_channelLedMessage;
215  DfcTotalConfigSpiScheduledMessage * m_dfcTotalConfigMessage;
216 
217  EEReadSpiScheduledMessage * m_eereadCalibration;
218  EEWriteEnableSpiScheduledMessage * m_eeenableWriteCalibration;
219  EEWriteSpiScheduledMessage * m_eewriteCalibration;
220 
221  EEWriteSpiScheduledMessage * m_eewriteIdent;
222 
223 
224  DfcDsmTotalConfigSpiScheduledMessage * m_totalConfig62_5mS[ZI2_NUMBER_OF_CHANNELS];
225  DfcDsmTotalConfigSpiScheduledMessage * m_totalConfig125mS[ZI2_NUMBER_OF_CHANNELS];
226 
227  DsmMuxEnum m_currentMux[ZI2_NUMBER_OF_CHANNELS];
228 
229  DfcReadFilterCountSpiScheduledMessage * m_readFilter62_5mS[ZI2_NUMBER_OF_CHANNELS];
230  DfcReadFilterCountSpiScheduledMessage * m_readFilter125mS[ZI2_NUMBER_OF_CHANNELS];
231 
232  LedSpiScheduledMessage * m_moduleLed;
233 
234  bool m_messagesScheduled;
235  EioUint8 m_eepromImage[256];
236 
237  EioSint32 m_filterCount[ZI2_NUMBER_OF_CHANNELS][NUMBER_OF_DSM_MUX];
238  EioUint8 m_filterStatus[ZI2_NUMBER_OF_CHANNELS][NUMBER_OF_DSM_MUX];
239  EioUint8 m_lastHeartBeat[ZI2_NUMBER_OF_CHANNELS];
240  float m_divisor[ZI2_NUMBER_OF_CHANNELS];
241  EioSint8 m_filterReset[ZI2_NUMBER_OF_CHANNELS][ZI2_NUMBER_OF_FILTER_TYPES];
242  EioUint8 m_rangingCount[ZI2_NUMBER_OF_CHANNELS];
243  float m_sensorBreakValue[ZI2_NUMBER_OF_CHANNELS];
244 
245  EioAIMeasuredValueData m_measuredValueData[ZI2_NUMBER_OF_CHANNELS];
246  EioAIPointConfig m_pointConfig[ZI2_NUMBER_OF_CHANNELS];
247  EioAICalibrationData m_calData[ZI2_NUMBER_OF_CHANNELS];
248  bool m_zirconiaSensorMonitor;
249 
250  Zi2OperatingRanges m_currentRange[ZI2_NUMBER_OF_CHANNELS];
251 
252  Zi2UpdateCycles m_updateCycle;
253 
254  EioUint8 m_hideAuxilliaryErrors;
255  EioUint8 m_dfcConfigAttempts;
256  EioUint8 m_ignoreCJorZeroCount;
257 };
258 #ifdef __cplusplus
259 } /* extern "C" */
260 #endif
261 #endif /* __cplusplus */
262 #endif /*__EIOT2SRZI2_H */
Definition: eio_t25srm.h:58
Definition: eio_ai.h:44
Definition: dfc_ssm.h:198
Definition: ee_ssm.h:113
Definition: rst_ssm.h:14
Definition: eiot2cal.h:36
Definition: eio_ai.h:76
Definition: dfc_ssm.h:233
Definition: dfc_ssm.h:266
Definition: led_ssm.h:12
Definition: dfc_ssm.h:206
Definition: dfc_ssm.h:306
Definition: ee_ssm.h:126
Definition: ee_ssm.h:59
Definition: dfc_ssm.h:174