WPILibC++ 2027.0.0-alpha-2
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] busId the bus id
141 * @param[in] module the CAN ID to initialize
142 * @param[in] allocationLocation the location where the allocation is occurring
143 * (can be null)
144 * @param[out] status Error status variable. 0 on success.
145 * @return the created PH handle
146 */
147HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
148 const char* allocationLocation,
149 int32_t* status);
150
151/**
152 * Frees a PH handle.
153 *
154 * @param[in] handle the PH handle
155 */
157
158/**
159 * Checks if a solenoid channel number is valid.
160 *
161 * @param[in] channel the channel to check
162 * @return true if the channel is valid, otherwise false
163 */
165
166/**
167 * Checks if a PH module (CAN ID) is valid.
168 *
169 * @param[in] module the module to check
170 * @return true if the module is valid, otherwise false
171 */
173
174/**
175 * Get whether compressor is turned on.
176 *
177 * @param[in] handle the PH handle
178 * @param[out] status Error status variable. 0 on success.
179 * @return true if the compressor is turned on
180 */
182
183/**
184 * Send compressor configuration to the PH.
185 *
186 * @param[in] handle the PH handle
187 * @param[in] config compressor configuration
188 * @param[out] status Error status variable. 0 on success.
189 */
191 const HAL_REVPHCompressorConfig* config,
192 int32_t* status);
193
194/**
195 * Disable Compressor.
196 *
197 * @param[in] handle the PH handle
198 * @param[out] status Error status variable. 0 on success.
199 */
201 int32_t* status);
202
203/**
204 * Enables the compressor in digital mode using the digital pressure switch. The
205 * compressor will turn on when the pressure switch indicates that the system is
206 * not full, and will turn off when the pressure switch indicates that the
207 * system is full.
208 *
209 * @param[in] handle the PH handle
210 * @param[out] status Error status variable. 0 on success.
211 */
213 int32_t* status);
214
215/**
216 * Enables the compressor in analog mode. This mode uses an analog
217 * pressure sensor connected to analog channel 0 to cycle the compressor. The
218 * compressor will turn on when the pressure drops below minAnalogVoltage and
219 * will turn off when the pressure reaches maxAnalogVoltage. This mode is only
220 * supported by the REV PH with the REV Analog Pressure Sensor connected to
221 * analog channel 0.
222 * @param[in] handle the PH handle
223 * @param[in] minAnalogVoltage The compressor will turn on when the analog
224 * pressure sensor voltage drops below this value
225 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
226 * pressure sensor reaches this value.
227 * @param[out] status Error status variable. 0 on success.
228 */
230 double minAnalogVoltage,
231 double maxAnalogVoltage,
232 int32_t* status);
233
234/**
235 * Enables the compressor in hybrid mode. This mode uses both a digital
236 * pressure switch and an analog pressure sensor connected to analog channel 0
237 * to cycle the compressor.
238 *
239 * The compressor will turn on when \a both:
240 *
241 * - The digital pressure switch indicates the system is not full AND
242 * - The analog pressure sensor indicates that the pressure in the system is
243 * below the specified minimum pressure.
244 *
245 * The compressor will turn off when \a either:
246 *
247 * - The digital pressure switch is disconnected or indicates that the system
248 * is full OR
249 * - The pressure detected by the analog sensor is greater than the specified
250 * maximum pressure.
251 *
252 * @param[in] handle the PH handle
253 * @param[in] minAnalogVoltage The compressor will turn on when the analog
254 * pressure sensor voltage drops below this value and the pressure switch
255 * indicates that the system is not full.
256 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
257 * pressure sensor reaches this value or the pressure switch is disconnected or
258 * indicates that the system is full.
259 * @param[out] status Error status variable. 0 on success.
260 */
262 double minAnalogVoltage,
263 double maxAnalogVoltage,
264 int32_t* status);
265
266/**
267 * Get compressor configuration from the PH.
268 *
269 * @param[in] handle the PH handle
270 * @param[out] status Error status variable. 0 on success.
271 * @return compressor configuration
272 */
274 HAL_REVPHHandle handle, int32_t* status);
275
276/**
277 * Returns the state of the digital pressure switch.
278 *
279 * @param[in] handle the PH handle
280 * @param[out] status Error status variable. 0 on success.
281 * @return True if pressure switch indicates that the system is full,
282 * otherwise false.
283 */
285
286/**
287 * Returns the current drawn by the compressor.
288 *
289 * @param[in] handle the PH handle
290 * @param[out] status Error status variable. 0 on success.
291 * @return The current drawn by the compressor in amps.
292 */
293double HAL_GetREVPHCompressorCurrent(HAL_REVPHHandle handle, int32_t* status);
294
295/**
296 * Returns the raw voltage of the specified analog
297 * input channel.
298 *
299 * @param[in] handle the PH handle
300 * @param[in] channel The analog input channel to read voltage from.
301 * @param[out] status Error status variable. 0 on success.
302 * @return The voltage of the specified analog input channel in volts.
303 */
304double HAL_GetREVPHAnalogVoltage(HAL_REVPHHandle handle, int32_t channel,
305 int32_t* status);
306
307/**
308 * Returns the current input voltage for the PH.
309 *
310 * @param[in] handle the PH handle
311 * @param[out] status Error status variable. 0 on success.
312 * @return The input voltage in volts.
313 */
314double HAL_GetREVPHVoltage(HAL_REVPHHandle handle, int32_t* status);
315
316/**
317 * Returns the current voltage of the regulated 5v supply.
318 *
319 * @param[in] handle the PH handle
320 * @param[out] status Error status variable. 0 on success.
321 * @return The current voltage of the 5v supply in volts.
322 */
323double HAL_GetREVPH5VVoltage(HAL_REVPHHandle handle, int32_t* status);
324
325/**
326 * Returns the total current drawn by all solenoids.
327 *
328 * @param[in] handle the PH handle
329 * @param[out] status Error status variable. 0 on success.
330 * @return Total current drawn by all solenoids in amps.
331 */
332double HAL_GetREVPHSolenoidCurrent(HAL_REVPHHandle handle, int32_t* status);
333
334/**
335 * Returns the current voltage of the solenoid power supply.
336 *
337 * @param[in] handle the PH handle
338 * @param[out] status Error status variable. 0 on success.
339 * @return The current voltage of the solenoid power supply in volts.
340 */
341double HAL_GetREVPHSolenoidVoltage(HAL_REVPHHandle handle, int32_t* status);
342
343/**
344 * Returns the hardware and firmware versions of the PH.
345 *
346 * @param[in] handle the PH handle
347 * @param[out] version The hardware and firmware versions.
348 * @param[out] status Error status variable. 0 on success.
349 */
351 int32_t* status);
352
353/**
354 * Gets a bitmask of solenoid values.
355 *
356 * @param[in] handle the PH handle
357 * @param[out] status Error status variable. 0 on success.
358 * @return Bitmask containing the state of the solenoids. The LSB represents
359 * solenoid 0.
360 */
361int32_t HAL_GetREVPHSolenoids(HAL_REVPHHandle handle, int32_t* status);
362
363/**
364 * Sets solenoids on a PH.
365 *
366 * @param[in] handle the PH handle
367 * @param[in] mask Bitmask indicating which solenoids to set. The LSB represents
368 * solenoid 0.
369 * @param[in] values Bitmask indicating the desired states of the solenoids. The
370 * LSB represents solenoid 0.
371 * @param[out] status Error status variable. 0 on success.
372 */
373void HAL_SetREVPHSolenoids(HAL_REVPHHandle handle, int32_t mask, int32_t values,
374 int32_t* status);
375
376/**
377 * Fire a single solenoid shot for the specified duration.
378 *
379 * @param[in] handle the PH handle
380 * @param[in] index solenoid index
381 * @param[in] durMs shot duration in ms
382 * @param[out] status Error status variable. 0 on success.
383 */
384void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs,
385 int32_t* status);
386
387/**
388 * Returns the faults currently active on the PH.
389 *
390 * @param[in] handle the PH handle
391 * @param[out] faults The faults.
392 * @param[out] status Error status variable. 0 on success.
393 */
395 int32_t* status);
396
397/**
398 * Returns the sticky faults currently active on this device.
399 *
400 * @param[in] handle the PH handle
401 * @param[out] stickyFaults The sticky faults.
402 * @param[out] status Error status variable. 0 on success.
403 */
405 HAL_REVPHStickyFaults* stickyFaults,
406 int32_t* status);
407
408/**
409 * Clears the sticky faults.
410 *
411 * @param[in] handle the PH handle
412 * @param[out] status Error status variable. 0 on success.
413 */
414void HAL_ClearREVPHStickyFaults(HAL_REVPHHandle handle, int32_t* status);
415
416/**
417 * Get a bitmask of disabled solenoids.
418 *
419 * @param[in] handle the PH handle
420 * @param[out] status Error status variable. 0 on success.
421 * @return Bitmask indicating disabled solenoids. The LSB represents solenoid 0.
422 */
424 int32_t* status);
425
426#ifdef __cplusplus
427} // extern "C"
428#endif
429/** @} */
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.
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.
HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module, const char *allocationLocation, int32_t *status)
Initializes a PH.
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:69
#define HAL_ENUM(name)
Definition Types.h:88
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