WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
PCM.h
1 #ifndef PCM_H_
2 #define PCM_H_
3 #include "ctre.h" //BIT Defines + Typedefs
4 #include "CtreCanNode.h"
5 class PCM : public CtreCanNode
6 {
7 public:
8  PCM(UINT8 deviceNumber=0);
9  ~PCM();
10 
11  /* Set PCM solenoid state
12  *
13  * @Return - CTR_Code - Error code (if any) for setting solenoid
14  * @Param - idx - ID of solenoid (0-7)
15  * @Param - en - Enable / Disable identified solenoid
16  */
17  CTR_Code SetSolenoid(unsigned char idx, bool en);
18 
19  /* Enables PCM Closed Loop Control of Compressor via pressure switch
20  * @Return - CTR_Code - Error code (if any) for setting solenoid
21  * @Param - en - Enable / Disable Closed Loop Control
22  */
23  CTR_Code SetClosedLoopControl(bool en);
24 
25  /* Clears PCM sticky faults (indicators of past faults
26  * @Return - CTR_Code - Error code (if any) for setting solenoid
27  */
28  CTR_Code ClearStickyFaults();
29 
30  /* Get solenoid state
31  *
32  * @Return - CTR_Code - Error code (if any)
33  * @Param - idx - ID of solenoid (0-7) to return if solenoid is on.
34  * @Param - status - true if solenoid enabled, false otherwise
35  */
36  CTR_Code GetSolenoid(UINT8 idx, bool &status);
37 
38  /* Get state of all solenoids
39  *
40  * @Return - CTR_Code - Error code (if any)
41  * @Param - status - bitfield of solenoid states
42  */
43  CTR_Code GetAllSolenoids(UINT8 &status);
44 
45  /* Get pressure switch state
46  * @Return - CTR_Code - Error code (if any)
47  * @Param - status - True if pressure adequate, false if low
48  */
49  CTR_Code GetPressure(bool &status);
50 
51  /* Get compressor state
52  * @Return - CTR_Code - Error code (if any)
53  * @Param - status - True if compress ouput is on, false if otherwise
54  */
55  CTR_Code GetCompressor(bool &status);
56 
57  /* Get closed loop control state
58  * @Return - CTR_Code - Error code (if any)
59  * @Param - status - True if closed loop enabled, false if otherwise
60  */
61  CTR_Code GetClosedLoopControl(bool &status);
62 
63  /* Get compressor current draw
64  * @Return - CTR_Code - Error code (if any)
65  * @Param - status - Compressor current returned in Amperes (A)
66  */
67  CTR_Code GetCompressorCurrent(float &status);
68 
69  /* Get voltage across solenoid rail
70  * @Return - CTR_Code - Error code (if any)
71  * @Param - status - Voltage across solenoid rail in Volts (V)
72  */
73  CTR_Code GetSolenoidVoltage(float &status);
74 
75  /* Get hardware fault value
76  * @Return - CTR_Code - Error code (if any)
77  * @Param - status - True if hardware failure detected, false if otherwise
78  */
79  CTR_Code GetHardwareFault(bool &status);
80 
81  /* Get compressor fault value
82  * @Return - CTR_Code - Error code (if any)
83  * @Param - status - True if abnormally high compressor current detected, false if otherwise
84  */
85  CTR_Code GetCompressorCurrentTooHighFault(bool &status);
86 
87  /* Get solenoid fault value
88  * @Return - CTR_Code - Error code (if any)
89  * @Param - status - True if shorted solenoid detected, false if otherwise
90  */
91  CTR_Code GetSolenoidFault(bool &status);
92 
93  /* Get compressor sticky fault value
94  * @Return - CTR_Code - Error code (if any)
95  * @Param - status - True if solenoid had previously been shorted
96  * (and sticky fault was not cleared), false if otherwise
97  */
98  CTR_Code GetCompressorCurrentTooHighStickyFault(bool &status);
99  /* Get compressor shorted sticky fault value
100  * @Return - CTR_Code - Error code (if any)
101  * @Param - status - True if compressor output is shorted, false if otherwise
102  */
103  CTR_Code GetCompressorShortedStickyFault(bool &status);
104  /* Get compressor shorted fault value
105  * @Return - CTR_Code - Error code (if any)
106  * @Param - status - True if compressor output is shorted, false if otherwise
107  */
108  CTR_Code GetCompressorShortedFault(bool &status);
109  /* Get compressor is not connected sticky fault value
110  * @Return - CTR_Code - Error code (if any)
111  * @Param - status - True if compressor current is too low,
112  * indicating compressor is not connected, false if otherwise
113  */
114  CTR_Code GetCompressorNotConnectedStickyFault(bool &status);
115  /* Get compressor is not connected fault value
116  * @Return - CTR_Code - Error code (if any)
117  * @Param - status - True if compressor current is too low,
118  * indicating compressor is not connected, false if otherwise
119  */
120  CTR_Code GetCompressorNotConnectedFault(bool &status);
121 
122  /* Get solenoid sticky fault value
123  * @Return - CTR_Code - Error code (if any)
124  * @Param - status - True if compressor had previously been shorted
125  * (and sticky fault was not cleared), false if otherwise
126  */
127  CTR_Code GetSolenoidStickyFault(bool &status);
128 
129  /* Get battery voltage
130  * @Return - CTR_Code - Error code (if any)
131  * @Param - status - Voltage across PCM power ports in Volts (V)
132  */
133  CTR_Code GetBatteryVoltage(float &status);
134 
135  /* Set PCM Device Number and according CAN frame IDs
136  * @Return - void
137  * @Param - deviceNumber - Device number of PCM to control
138  */
139  void SetDeviceNumber(UINT8 deviceNumber);
140  /* Get number of total failed PCM Control Frame
141  * @Return - CTR_Code - Error code (if any)
142  * @Param - status - Number of failed control frames (tokenization fails)
143  * @WARNING - Return only valid if [SeekDebugFrames] is enabled
144  * See function SeekDebugFrames
145  * See function EnableSeekDebugFrames
146  */
147  CTR_Code GetNumberOfFailedControlFrames(UINT16 &status);
148 
149  /* Get raw Solenoid Blacklist
150  * @Return - CTR_Code - Error code (if any)
151  * @Param - status - Raw binary breakdown of Solenoid Blacklist
152  * BIT7 = Solenoid 1, BIT6 = Solenoid 2, etc.
153  * @WARNING - Return only valid if [SeekStatusFaultFrames] is enabled
154  * See function SeekStatusFaultFrames
155  * See function EnableSeekStatusFaultFrames
156  */
157  CTR_Code GetSolenoidBlackList(UINT8 &status);
158 
159  /* Get solenoid Blacklist status
160  * - Blacklisted solenoids cannot be enabled until PCM is power cycled
161  * @Return - CTR_Code - Error code (if any)
162  * @Param - idx - ID of solenoid [0,7]
163  * @Param - status - True if Solenoid is blacklisted, false if otherwise
164  * @WARNING - Return only valid if [SeekStatusFaultFrames] is enabled
165  * See function SeekStatusFaultFrames
166  * See function EnableSeekStatusFaultFrames
167  */
168  CTR_Code IsSolenoidBlacklisted(UINT8 idx, bool &status);
169 
170  /* Return status of module enable/disable
171  * @Return - CTR_Code - Error code (if any)
172  * @Param - status - Returns TRUE if PCM is enabled, FALSE if disabled
173  */
174  CTR_Code isModuleEnabled(bool &status);
175 
176  /* Get solenoid Blacklist status
177  * @Return - CTR_Code - Error code (if any)
178  * @Param - idx - ID of solenoid [0,7] to fire one shot pulse.
179  */
180  CTR_Code FireOneShotSolenoid(UINT8 idx);
181 
182  /* Configure the pulse width of a solenoid channel for one-shot pulse.
183  * Preprogrammed pulsewidth is 10ms resolute and can be between 20ms and 5.1s.
184  * @Return - CTR_Code - Error code (if any)
185  * @Param - idx - ID of solenoid [0,7] to configure.
186  * @Param - durMs - pulse width in ms.
187  */
188  CTR_Code SetOneShotDurationMs(UINT8 idx,uint32_t durMs);
189 
190 };
191 //------------------ C interface --------------------------------------------//
192 extern "C" {
193  void * c_PCM_Init(void);
194  CTR_Code c_SetSolenoid(void * handle,unsigned char idx,INT8 param);
195  CTR_Code c_SetClosedLoopControl(void * handle,INT8 param);
196  CTR_Code c_ClearStickyFaults(void * handle,INT8 param);
197  CTR_Code c_GetSolenoid(void * handle,UINT8 idx,INT8 * status);
198  CTR_Code c_GetAllSolenoids(void * handle,UINT8 * status);
199  CTR_Code c_GetPressure(void * handle,INT8 * status);
200  CTR_Code c_GetCompressor(void * handle,INT8 * status);
201  CTR_Code c_GetClosedLoopControl(void * handle,INT8 * status);
202  CTR_Code c_GetCompressorCurrent(void * handle,float * status);
203  CTR_Code c_GetSolenoidVoltage(void * handle,float*status);
204  CTR_Code c_GetHardwareFault(void * handle,INT8*status);
205  CTR_Code c_GetCompressorFault(void * handle,INT8*status);
206  CTR_Code c_GetSolenoidFault(void * handle,INT8*status);
207  CTR_Code c_GetCompressorStickyFault(void * handle,INT8*status);
208  CTR_Code c_GetSolenoidStickyFault(void * handle,INT8*status);
209  CTR_Code c_GetBatteryVoltage(void * handle,float*status);
210  void c_SetDeviceNumber_PCM(void * handle,UINT8 deviceNumber);
211  void c_EnableSeekStatusFrames(void * handle,INT8 enable);
212  void c_EnableSeekStatusFaultFrames(void * handle,INT8 enable);
213  void c_EnableSeekDebugFrames(void * handle,INT8 enable);
214  CTR_Code c_GetNumberOfFailedControlFrames(void * handle,UINT16*status);
215  CTR_Code c_GetSolenoidBlackList(void * handle,UINT8 *status);
216  CTR_Code c_IsSolenoidBlacklisted(void * handle,UINT8 idx,INT8*status);
217 }
218 #endif
Common header for all CTRE HAL modules.
Definition: CtreCanNode.h:7
CTR_Code
Definition: ctre.h:44
Definition: PCM.h:5