WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
REVPH.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "hal/Types.h"
10
11/**
12 * @defgroup hal_rev_ph REV Pneumatic Hub (PH) Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17/**
18 * The compressor configuration type
19 */
30
31/**
32 * Storage for REV PH Version
33 */
35 /** The firmware major version. */
36 uint32_t firmwareMajor;
37 /** The firmware minor version. */
38 uint32_t firmwareMinor;
39 /** The firmware fix version. */
40 uint32_t firmwareFix;
41 /** The hardware minor version. */
42 uint32_t hardwareMinor;
43 /** The hardware major version. */
44 uint32_t hardwareMajor;
45 /** The device's unique ID. */
46 uint32_t uniqueId;
47};
48
49/**
50 * Storage for compressor config
51 */
58
59/**
60 * Storage for REV PH Faults
61 */
63 /** Fault on channel 0. */
64 uint32_t channel0Fault : 1;
65 /** Fault on channel 1. */
66 uint32_t channel1Fault : 1;
67 /** Fault on channel 2. */
68 uint32_t channel2Fault : 1;
69 /** Fault on channel 3. */
70 uint32_t channel3Fault : 1;
71 /** Fault on channel 4. */
72 uint32_t channel4Fault : 1;
73 /** Fault on channel 5. */
74 uint32_t channel5Fault : 1;
75 /** Fault on channel 6. */
76 uint32_t channel6Fault : 1;
77 /** Fault on channel 7. */
78 uint32_t channel7Fault : 1;
79 /** Fault on channel 8. */
80 uint32_t channel8Fault : 1;
81 /** Fault on channel 9. */
82 uint32_t channel9Fault : 1;
83 /** Fault on channel 10. */
84 uint32_t channel10Fault : 1;
85 /** Fault on channel 11. */
86 uint32_t channel11Fault : 1;
87 /** Fault on channel 12. */
88 uint32_t channel12Fault : 1;
89 /** Fault on channel 13. */
90 uint32_t channel13Fault : 1;
91 /** Fault on channel 14. */
92 uint32_t channel14Fault : 1;
93 /** Fault on channel 15. */
94 uint32_t channel15Fault : 1;
95 /** An overcurrent event occurred on the compressor output. */
97 /** The compressor output has an open circuit. */
98 uint32_t compressorOpen : 1;
99 /** An overcurrent event occurred on a solenoid output. */
101 /** The input voltage is below the minimum voltage. */
102 uint32_t brownout : 1;
103 /** A warning was raised by the device's CAN controller. */
104 uint32_t canWarning : 1;
105 /** The hardware on the device has malfunctioned. */
106 uint32_t hardwareFault : 1;
107};
108
109/**
110 * Storage for REV PH Sticky Faults
111 */
113 /** An overcurrent event occurred on the compressor output. */
115 /** The compressor output has an open circuit. */
116 uint32_t compressorOpen : 1;
117 /** An overcurrent event occurred on a solenoid output. */
119 /** The input voltage is below the minimum voltage. */
120 uint32_t brownout : 1;
121 /** A warning was raised by the device's CAN controller. */
122 uint32_t canWarning : 1;
123 /** The device's CAN controller experienced a "Bus Off" event. */
124 uint32_t canBusOff : 1;
125 /** The hardware on the device has malfunctioned. */
126 uint32_t hardwareFault : 1;
127 /** The firmware on the device has malfunctioned. */
128 uint32_t firmwareFault : 1;
129 /** The device has rebooted. */
130 uint32_t hasReset : 1;
131};
132
133#ifdef __cplusplus
134extern "C" {
135#endif
136
137/**
138 * Initializes a PH.
139 *
140 * @param[in] module the CAN ID to initialize
141 * @param[in] allocationLocation the location where the allocation is occurring
142 * (can be null)
143 * @param[out] status Error status variable. 0 on success.
144 * @return the created PH handle
145 */
147 const char* allocationLocation,
148 int32_t* status);
149
150/**
151 * Frees a PH handle.
152 *
153 * @param[in] handle the PH handle
154 */
156
157/**
158 * Checks if a solenoid channel number is valid.
159 *
160 * @param[in] channel the channel to check
161 * @return true if the channel is valid, otherwise false
162 */
164
165/**
166 * Checks if a PH module (CAN ID) is valid.
167 *
168 * @param[in] module the module to check
169 * @return true if the module is valid, otherwise false
170 */
172
173/**
174 * Get whether compressor is turned on.
175 *
176 * @param[in] handle the PH handle
177 * @param[out] status Error status variable. 0 on success.
178 * @return true if the compressor is turned on
179 */
181
182/**
183 * Send compressor configuration to the PH.
184 *
185 * @param[in] handle the PH handle
186 * @param[in] config compressor configuration
187 * @param[out] status Error status variable. 0 on success.
188 */
190 const HAL_REVPHCompressorConfig* config,
191 int32_t* status);
192
193/**
194 * Disable Compressor.
195 *
196 * @param[in] handle the PH handle
197 * @param[out] status Error status variable. 0 on success.
198 */
200 int32_t* status);
201
202/**
203 * Enables the compressor in digital mode using the digital pressure switch. The
204 * compressor will turn on when the pressure switch indicates that the system is
205 * not full, and will turn off when the pressure switch indicates that the
206 * system is full.
207 *
208 * @param[in] handle the PH handle
209 * @param[out] status Error status variable. 0 on success.
210 */
212 int32_t* status);
213
214/**
215 * Enables the compressor in analog mode. This mode uses an analog
216 * pressure sensor connected to analog channel 0 to cycle the compressor. The
217 * compressor will turn on when the pressure drops below minAnalogVoltage and
218 * will turn off when the pressure reaches maxAnalogVoltage. This mode is only
219 * supported by the REV PH with the REV Analog Pressure Sensor connected to
220 * analog channel 0.
221 * @param[in] handle the PH handle
222 * @param[in] minAnalogVoltage The compressor will turn on when the analog
223 * pressure sensor voltage drops below this value
224 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
225 * pressure sensor reaches this value.
226 * @param[out] status Error status variable. 0 on success.
227 */
229 double minAnalogVoltage,
230 double maxAnalogVoltage,
231 int32_t* status);
232
233/**
234 * Enables the compressor in hybrid mode. This mode uses both a digital
235 * pressure switch and an analog pressure sensor connected to analog channel 0
236 * to cycle the compressor.
237 *
238 * The compressor will turn on when \a both:
239 *
240 * - The digital pressure switch indicates the system is not full AND
241 * - The analog pressure sensor indicates that the pressure in the system is
242 * below the specified minimum pressure.
243 *
244 * The compressor will turn off when \a either:
245 *
246 * - The digital pressure switch is disconnected or indicates that the system
247 * is full OR
248 * - The pressure detected by the analog sensor is greater than the specified
249 * maximum pressure.
250 *
251 * @param[in] handle the PH handle
252 * @param[in] minAnalogVoltage The compressor will turn on when the analog
253 * pressure sensor voltage drops below this value and the pressure switch
254 * indicates that the system is not full.
255 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
256 * pressure sensor reaches this value or the pressure switch is disconnected or
257 * indicates that the system is full.
258 * @param[out] status Error status variable. 0 on success.
259 */
261 double minAnalogVoltage,
262 double maxAnalogVoltage,
263 int32_t* status);
264
265/**
266 * Get compressor configuration from the PH.
267 *
268 * @param[in] handle the PH handle
269 * @param[out] status Error status variable. 0 on success.
270 * @return compressor configuration
271 */
273 HAL_REVPHHandle handle, int32_t* status);
274
275/**
276 * Returns the state of the digital pressure switch.
277 *
278 * @param[in] handle the PH handle
279 * @param[out] status Error status variable. 0 on success.
280 * @return True if pressure switch indicates that the system is full,
281 * otherwise false.
282 */
284
285/**
286 * Returns the current drawn by the compressor.
287 *
288 * @param[in] handle the PH handle
289 * @param[out] status Error status variable. 0 on success.
290 * @return The current drawn by the compressor in amps.
291 */
292double HAL_GetREVPHCompressorCurrent(HAL_REVPHHandle handle, int32_t* status);
293
294/**
295 * Returns the raw voltage of the specified analog
296 * input channel.
297 *
298 * @param[in] handle the PH handle
299 * @param[in] channel The analog input channel to read voltage from.
300 * @param[out] status Error status variable. 0 on success.
301 * @return The voltage of the specified analog input channel in volts.
302 */
303double HAL_GetREVPHAnalogVoltage(HAL_REVPHHandle handle, int32_t channel,
304 int32_t* status);
305
306/**
307 * Returns the current input voltage for the PH.
308 *
309 * @param[in] handle the PH handle
310 * @param[out] status Error status variable. 0 on success.
311 * @return The input voltage in volts.
312 */
313double HAL_GetREVPHVoltage(HAL_REVPHHandle handle, int32_t* status);
314
315/**
316 * Returns the current voltage of the regulated 5v supply.
317 *
318 * @param[in] handle the PH handle
319 * @param[out] status Error status variable. 0 on success.
320 * @return The current voltage of the 5v supply in volts.
321 */
322double HAL_GetREVPH5VVoltage(HAL_REVPHHandle handle, int32_t* status);
323
324/**
325 * Returns the total current drawn by all solenoids.
326 *
327 * @param[in] handle the PH handle
328 * @param[out] status Error status variable. 0 on success.
329 * @return Total current drawn by all solenoids in amps.
330 */
331double HAL_GetREVPHSolenoidCurrent(HAL_REVPHHandle handle, int32_t* status);
332
333/**
334 * Returns the current voltage of the solenoid power supply.
335 *
336 * @param[in] handle the PH handle
337 * @param[out] status Error status variable. 0 on success.
338 * @return The current voltage of the solenoid power supply in volts.
339 */
340double HAL_GetREVPHSolenoidVoltage(HAL_REVPHHandle handle, int32_t* status);
341
342/**
343 * Returns the hardware and firmware versions of the PH.
344 *
345 * @param[in] handle the PH handle
346 * @param[out] version The hardware and firmware versions.
347 * @param[out] status Error status variable. 0 on success.
348 */
350 int32_t* status);
351
352/**
353 * Gets a bitmask of solenoid values.
354 *
355 * @param[in] handle the PH handle
356 * @param[out] status Error status variable. 0 on success.
357 * @return Bitmask containing the state of the solenoids. The LSB represents
358 * solenoid 0.
359 */
360int32_t HAL_GetREVPHSolenoids(HAL_REVPHHandle handle, int32_t* status);
361
362/**
363 * Sets solenoids on a PH.
364 *
365 * @param[in] handle the PH handle
366 * @param[in] mask Bitmask indicating which solenoids to set. The LSB represents
367 * solenoid 0.
368 * @param[in] values Bitmask indicating the desired states of the solenoids. The
369 * LSB represents solenoid 0.
370 * @param[out] status Error status variable. 0 on success.
371 */
372void HAL_SetREVPHSolenoids(HAL_REVPHHandle handle, int32_t mask, int32_t values,
373 int32_t* status);
374
375/**
376 * Fire a single solenoid shot for the specified duration.
377 *
378 * @param[in] handle the PH handle
379 * @param[in] index solenoid index
380 * @param[in] durMs shot duration in ms
381 * @param[out] status Error status variable. 0 on success.
382 */
383void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs,
384 int32_t* status);
385
386/**
387 * Returns the faults currently active on the PH.
388 *
389 * @param[in] handle the PH handle
390 * @param[out] faults The faults.
391 * @param[out] status Error status variable. 0 on success.
392 */
394 int32_t* status);
395
396/**
397 * Returns the sticky faults currently active on this device.
398 *
399 * @param[in] handle the PH handle
400 * @param[out] stickyFaults The sticky faults.
401 * @param[out] status Error status variable. 0 on success.
402 */
404 HAL_REVPHStickyFaults* stickyFaults,
405 int32_t* status);
406
407/**
408 * Clears the sticky faults.
409 *
410 * @param[in] handle the PH handle
411 * @param[out] status Error status variable. 0 on success.
412 */
413void HAL_ClearREVPHStickyFaults(HAL_REVPHHandle handle, int32_t* status);
414
415/**
416 * Get a bitmask of disabled solenoids.
417 *
418 * @param[in] handle the PH handle
419 * @param[out] status Error status variable. 0 on success.
420 * @return Bitmask indicating disabled solenoids. The LSB represents solenoid 0.
421 */
423 int32_t* status);
424
425#ifdef __cplusplus
426} // extern "C"
427#endif
428/** @} */
void HAL_GetREVPHFaults(HAL_REVPHHandle handle, HAL_REVPHFaults *faults, int32_t *status)
Returns the faults currently active on the PH.
HAL_REVPHCompressorConfigType
The compressor configuration type.
Definition REVPH.h:20
int32_t HAL_GetREVPHSolenoidDisabledList(HAL_REVPHHandle handle, int32_t *status)
Get a bitmask of disabled solenoids.
HAL_REVPHCompressorConfigType HAL_GetREVPHCompressorConfig(HAL_REVPHHandle handle, int32_t *status)
Get compressor configuration from the PH.
double HAL_GetREVPHSolenoidVoltage(HAL_REVPHHandle handle, int32_t *status)
Returns the current voltage of the solenoid power supply.
double HAL_GetREVPHSolenoidCurrent(HAL_REVPHHandle handle, int32_t *status)
Returns the total current drawn by all solenoids.
void HAL_GetREVPHStickyFaults(HAL_REVPHHandle handle, HAL_REVPHStickyFaults *stickyFaults, int32_t *status)
Returns the sticky faults currently active on this device.
double HAL_GetREVPH5VVoltage(HAL_REVPHHandle handle, int32_t *status)
Returns the current voltage of the regulated 5v supply.
void HAL_FreeREVPH(HAL_REVPHHandle handle)
Frees a PH handle.
void HAL_SetREVPHClosedLoopControlDisabled(HAL_REVPHHandle handle, int32_t *status)
Disable Compressor.
HAL_REVPHHandle HAL_InitializeREVPH(int32_t module, const char *allocationLocation, int32_t *status)
Initializes a PH.
void HAL_GetREVPHVersion(HAL_REVPHHandle handle, HAL_REVPHVersion *version, int32_t *status)
Returns the hardware and firmware versions of the PH.
int32_t HAL_GetREVPHSolenoids(HAL_REVPHHandle handle, int32_t *status)
Gets a bitmask of solenoid values.
void HAL_ClearREVPHStickyFaults(HAL_REVPHHandle handle, int32_t *status)
Clears the sticky faults.
void HAL_SetREVPHClosedLoopControlDigital(HAL_REVPHHandle handle, int32_t *status)
Enables the compressor in digital mode using the digital pressure switch.
void HAL_SetREVPHClosedLoopControlAnalog(HAL_REVPHHandle handle, double minAnalogVoltage, double maxAnalogVoltage, int32_t *status)
Enables the compressor in analog mode.
double HAL_GetREVPHVoltage(HAL_REVPHHandle handle, int32_t *status)
Returns the current input voltage for the PH.
HAL_Bool HAL_GetREVPHPressureSwitch(HAL_REVPHHandle handle, int32_t *status)
Returns the state of the digital pressure switch.
void HAL_SetREVPHClosedLoopControlHybrid(HAL_REVPHHandle handle, double minAnalogVoltage, double maxAnalogVoltage, int32_t *status)
Enables the compressor in hybrid mode.
double HAL_GetREVPHCompressorCurrent(HAL_REVPHHandle handle, int32_t *status)
Returns the current drawn by the compressor.
double HAL_GetREVPHAnalogVoltage(HAL_REVPHHandle handle, int32_t channel, int32_t *status)
Returns the raw voltage of the specified analog input channel.
HAL_Bool HAL_CheckREVPHSolenoidChannel(int32_t channel)
Checks if a solenoid channel number is valid.
HAL_Bool HAL_CheckREVPHModuleNumber(int32_t module)
Checks if a PH module (CAN ID) is valid.
void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs, int32_t *status)
Fire a single solenoid shot for the specified duration.
void HAL_SetREVPHSolenoids(HAL_REVPHHandle handle, int32_t mask, int32_t values, int32_t *status)
Sets solenoids on a PH.
HAL_Bool HAL_GetREVPHCompressor(HAL_REVPHHandle handle, int32_t *status)
Get whether compressor is turned on.
void HAL_SetREVPHCompressorConfig(HAL_REVPHHandle handle, const HAL_REVPHCompressorConfig *config, int32_t *status)
Send compressor configuration to the PH.
@ HAL_REVPHCompressorConfigType_kDisabled
Disabled.
Definition REVPH.h:22
@ HAL_REVPHCompressorConfigType_kAnalog
Analog.
Definition REVPH.h:26
@ HAL_REVPHCompressorConfigType_kHybrid
Hybrid.
Definition REVPH.h:28
@ HAL_REVPHCompressorConfigType_kDigital
Digital.
Definition REVPH.h:24
int32_t HAL_Bool
Definition Types.h:73
HAL_Handle HAL_REVPHHandle
Definition Types.h:71
#define HAL_ENUM(name)
Definition Types.h:76
Storage for compressor config.
Definition REVPH.h:52
double maxAnalogVoltage
Definition REVPH.h:54
double minAnalogVoltage
Definition REVPH.h:53
HAL_Bool useDigital
Definition REVPH.h:56
HAL_Bool forceDisable
Definition REVPH.h:55
Storage for REV PH Faults.
Definition REVPH.h:62
uint32_t brownout
The input voltage is below the minimum voltage.
Definition REVPH.h:102
uint32_t channel1Fault
Fault on channel 1.
Definition REVPH.h:66
uint32_t channel4Fault
Fault on channel 4.
Definition REVPH.h:72
uint32_t solenoidOverCurrent
An overcurrent event occurred on a solenoid output.
Definition REVPH.h:100
uint32_t compressorOverCurrent
An overcurrent event occurred on the compressor output.
Definition REVPH.h:96
uint32_t channel0Fault
Fault on channel 0.
Definition REVPH.h:64
uint32_t channel14Fault
Fault on channel 14.
Definition REVPH.h:92
uint32_t compressorOpen
The compressor output has an open circuit.
Definition REVPH.h:98
uint32_t canWarning
A warning was raised by the device's CAN controller.
Definition REVPH.h:104
uint32_t channel5Fault
Fault on channel 5.
Definition REVPH.h:74
uint32_t channel3Fault
Fault on channel 3.
Definition REVPH.h:70
uint32_t hardwareFault
The hardware on the device has malfunctioned.
Definition REVPH.h:106
uint32_t channel13Fault
Fault on channel 13.
Definition REVPH.h:90
uint32_t channel10Fault
Fault on channel 10.
Definition REVPH.h:84
uint32_t channel15Fault
Fault on channel 15.
Definition REVPH.h:94
uint32_t channel9Fault
Fault on channel 9.
Definition REVPH.h:82
uint32_t channel2Fault
Fault on channel 2.
Definition REVPH.h:68
uint32_t channel12Fault
Fault on channel 12.
Definition REVPH.h:88
uint32_t channel8Fault
Fault on channel 8.
Definition REVPH.h:80
uint32_t channel11Fault
Fault on channel 11.
Definition REVPH.h:86
uint32_t channel7Fault
Fault on channel 7.
Definition REVPH.h:78
uint32_t channel6Fault
Fault on channel 6.
Definition REVPH.h:76
Storage for REV PH Sticky Faults.
Definition REVPH.h:112
uint32_t brownout
The input voltage is below the minimum voltage.
Definition REVPH.h:120
uint32_t solenoidOverCurrent
An overcurrent event occurred on a solenoid output.
Definition REVPH.h:118
uint32_t hardwareFault
The hardware on the device has malfunctioned.
Definition REVPH.h:126
uint32_t compressorOverCurrent
An overcurrent event occurred on the compressor output.
Definition REVPH.h:114
uint32_t hasReset
The device has rebooted.
Definition REVPH.h:130
uint32_t compressorOpen
The compressor output has an open circuit.
Definition REVPH.h:116
uint32_t canWarning
A warning was raised by the device's CAN controller.
Definition REVPH.h:122
uint32_t firmwareFault
The firmware on the device has malfunctioned.
Definition REVPH.h:128
uint32_t canBusOff
The device's CAN controller experienced a "Bus Off" event.
Definition REVPH.h:124
Storage for REV PH Version.
Definition REVPH.h:34
uint32_t uniqueId
The device's unique ID.
Definition REVPH.h:46
uint32_t hardwareMinor
The hardware minor version.
Definition REVPH.h:42
uint32_t firmwareMinor
The firmware minor version.
Definition REVPH.h:38
uint32_t firmwareFix
The firmware fix version.
Definition REVPH.h:40
uint32_t hardwareMajor
The hardware major version.
Definition REVPH.h:44
uint32_t firmwareMajor
The firmware major version.
Definition REVPH.h:36