versadac  1
versadac - Scalable Recorder Firmware
eio_tp.h
1 /*******************************************************************************
2 FILE : eio_tp.h
3 VERSION : $Id: eio_tp.h 30319 2010-03-10 18:43:56Z davec $
4 AUTHOR : Richard Hine
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : This file contains the eio time proportioning algorithm as used
7  in fast digital outputs. Tha algorithm is initially lifted from the
8  E3K range of controllers.
9  For more details of the initial algoritm see ????
10 *******************************************************************************/
11 #ifndef __EIO_TP_H
12 #define __EIO_TP_H
13 
14 #include "eio.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 
22 {
23  public:
25  virtual ~EioTimeProportioningOutput();
26 
27  void update(bool *output){dioc_Tick(); *output = m_op;};
28  void setDemandPercentage(float z_demand){DIOC_CodedVal = dioc_encode_TPO_value(z_demand);};
29  bool setMinimumOnTime(EioUint32 minOnTimeuS){DIOC_MinOnT = minOnTimeuS; return(dioc_calc_hysteresis());};
30  void setTickRate(EioUint32 tickRate){DIOC_TickRate = tickRate; dioc_calc_hysteresis();};
31  void reset(){dioc_Initialise();};
32 
33  protected:
34 
35  private:
36  // does the current cycle require us to raise or lower the valve
37  bool m_op;
38 
39  // Original E3K functions
40  void dioc_Tick();
41  void dioc_calc_m_x_plus_c();
42  bool dioc_calc_hysteresis();
43  EioSint32 dioc_encode_TPO_value(float DIOC_Value);
44  void dioc_Initialise();
45 
46  // below are all of the identifiers required by the original E3K code
47  EioUint32 DIOC_TickRate; /* Tick rate that dioc_tick will be called at */
48  EioUint32 DIOC_MinOnT;
49  float DIOC_ValH; /* Highest possible demand (100%) */
50  float DIOC_ValL; /* lowest possible demand (-100%) */
51  float DIOC_OutH; /* Highest possible output (100%) */
52  float DIOC_OutL; /* lowest possible output (-100%) */
53 
54  EioSint32 DIOC_CodedVal; /* demand velocity mapped to -8192 to 8192 */
55  EioSint32 DIOC_Integrator;
56  EioSint32 DIOC_Hysteresis;
57  float DIOC_m;
58  float DIOC_c;
59 };
60 
61 #ifdef __cplusplus
62 } /* extern "C" */
63 #endif
64 #endif /*__EIO_TP_H */
65 
Definition: eio_tp.h:21