versadac  1
versadac - Scalable Recorder Firmware
eio_vp.h
1 /*******************************************************************************
2 FILE : eio_vp.h
3 VERSION : $Id: eio_vp.h 10363 2007-07-25 15:05:21Z davec $
4 AUTHOR : David Cozens
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : This file contains the eio Valve positioning algorithm as used
7  in digital outputs. Tha algorithm is initially lifted from the
8  E3K range of controllers.
9  This class encapsulates a Time proportioning algorithm that is
10  used to drive two digital outputs - one for valve raise and
11  another for valve lower. The input to this algorithm is a demand
12  velocity with a valid range of +/-100%.
13  For more details of the initial algoritm see DEV1235 ds5.2.4.3
14 *******************************************************************************/
15 #ifndef __EIO_VP_H
16 #define __EIO_VP_H
17 
18 #include "eio.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
26 {
27  public:
29  virtual ~EioValvePositioningOutput();
30 
31  void update(bool *raise, bool *lower){dioc_Tick();*raise = m_raise;*lower = m_lower;};
32  void setDemandVelocityPercentage(float z_demand){DIOC_CodedVal = dioc_encode_TPO_value(z_demand);};
33  void setInertiauS(EioUint32 inertiauS){DIOC_Inertia_Time = ((float)inertiauS)/1000000;};
34  void setBacklashuS(EioUint32 backlashuS){DIOC_Backlash_Ticks = (((float)backlashuS)/1000000)/DIOC_TickRate;};
35  void setMinimumOnTime(EioUint32 minOnTimeuS){DIOC_MinOnT = ((float)minOnTimeuS)/1000000;};
36  void setTickRate(EioUint32 tickRate){DIOC_TickRate = ((float)tickRate)/1000000;};
37  void reset(){dioc_Initialise();};
38 
39  protected:
40 
41  private:
42  // does the current cycle require us to raise or lower the valve
43  bool m_raise;
44  bool m_lower;
45 
46  // Original E3K functions
47  void dioc_Tick();
48  void dioc_calc_m_x_plus_c();
49  void dioc_calc_hysteresis();
50  EioSint32 dioc_encode_TPO_value(float DIOC_Value);
51  void dioc_Initialise( );
52 
53  // below are all of the identifiers required by the original E3K code
54  float DIOC_TickRate; /* Tick rate that dioc_tick will be called at */
55  float DIOC_MinOnT;
56  float DIOC_ValH; /* Highest possible demand (100%) */
57  float DIOC_ValL; /* lowest possible demand (-100%) */
58  float DIOC_OutH; /* Highest possible output (100%) */
59  float DIOC_OutL; /* lowest possible output (-100%) */
60  float DIOC_Inertia_Time; /* Inertia time in seconds */
61 
62  EioSint32 DIOC_CodedVal; /* demand velocity mapped to -8192 to 8192 */
63  EioSint32 DIOC_Integrator;
64  EioSint32 DIOC_Hysteresis;
65  EioSint32 DIOC_Hyst_Low;
66  float DIOC_m;
67  float DIOC_c;
68  EioUint32 DIOC_CompensationTicks;
69  EioSint32 DIOC_Backlash_Ticks;
70 
71  EioSint8 DIOC_OldDirection;
72  EioSint8 DIOC_ValveOP;
73  EioSint8 DIOC_OldValveOP;
74 };
75 
76 #ifdef __cplusplus
77 } /* extern "C" */
78 #endif
79 #endif /*__EIO_VP_H */
80 
Definition: eio_vp.h:25