WPILibC++ 2023.4.3-108-ge5452e3
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 */
25};
26
27/**
28 * Storage for REV PH Version
29 */
37};
38
39/**
40 * Storage for compressor config
41 */
47};
48
49/**
50 * Storage for REV PH Faults
51 */
75};
76
77/**
78 * Storage for REV PH Sticky Faults
79 */
88};
89
90#ifdef __cplusplus
91extern "C" {
92#endif
93
94/**
95 * Initializes a PH.
96 *
97 * @param[in] module the CAN ID to initialize
98 * @param[in] allocationLocation the location where the allocation is occurring
99 * (can be null)
100 * @param[out] status Error status variable. 0 on success.
101 * @return the created PH handle
102 */
104 const char* allocationLocation,
105 int32_t* status);
106
107/**
108 * Frees a PH handle.
109 *
110 * @param[in] handle the PH handle
111 */
113
114/**
115 * Checks if a solenoid channel number is valid.
116 *
117 * @param[in] channel the channel to check
118 * @return true if the channel is valid, otherwise false
119 */
121
122/**
123 * Checks if a PH module (CAN ID) is valid.
124 *
125 * @param[in] module the module to check
126 * @return true if the module is valid, otherwise false
127 */
129
130/**
131 * Get whether compressor is turned on.
132 *
133 * @param[in] handle the PH handle
134 * @param[out] status Error status variable. 0 on success.
135 * @return true if the compressor is turned on
136 */
138
139/**
140 * Send compressor configuration to the PH.
141 *
142 * @param[in] handle the PH handle
143 * @param[in] config compressor configuration
144 * @param[out] status Error status variable. 0 on success.
145 */
147 const HAL_REVPHCompressorConfig* config,
148 int32_t* status);
149
150/**
151 * Disable Compressor.
152 *
153 * @param[in] handle the PH handle
154 * @param[out] status Error status variable. 0 on success.
155 */
157 int32_t* status);
158
159/**
160 * Enables the compressor in digital mode using the digital pressure switch. The
161 * compressor will turn on when the pressure switch indicates that the system is
162 * not full, and will turn off when the pressure switch indicates that the
163 * system is full.
164 *
165 * @param[in] handle the PH handle
166 * @param[out] status Error status variable. 0 on success.
167 */
169 int32_t* status);
170
171/**
172 * Enables the compressor in analog mode. This mode uses an analog
173 * pressure sensor connected to analog channel 0 to cycle the compressor. The
174 * compressor will turn on when the pressure drops below minAnalogVoltage and
175 * will turn off when the pressure reaches maxAnalogVoltage. This mode is only
176 * supported by the REV PH with the REV Analog Pressure Sensor connected to
177 * analog channel 0.
178 * @param[in] handle the PH handle
179 * @param[in] minAnalogVoltage The compressor will turn on when the analog
180 * pressure sensor voltage drops below this value
181 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
182 * pressure sensor reaches this value.
183 * @param[out] status Error status variable. 0 on success.
184 */
186 double minAnalogVoltage,
187 double maxAnalogVoltage,
188 int32_t* status);
189
190/**
191 * Enables the compressor in hybrid mode. This mode uses both a digital
192 * pressure switch and an analog pressure sensor connected to analog channel 0
193 * to cycle the compressor.
194 *
195 * The compressor will turn on when \a both:
196 *
197 * - The digital pressure switch indicates the system is not full AND
198 * - The analog pressure sensor indicates that the pressure in the system is
199 * below the specified minimum pressure.
200 *
201 * The compressor will turn off when \a either:
202 *
203 * - The digital pressure switch is disconnected or indicates that the system
204 * is full OR
205 * - The pressure detected by the analog sensor is greater than the specified
206 * maximum pressure.
207 *
208 * @param[in] handle the PH handle
209 * @param[in] minAnalogVoltage The compressor will turn on when the analog
210 * pressure sensor voltage drops below this value and the pressure switch
211 * indicates that the system is not full.
212 * @param[in] maxAnalogVoltage The compressor will turn off when the analog
213 * pressure sensor reaches this value or the pressure switch is disconnected or
214 * indicates that the system is full.
215 * @param[out] status Error status variable. 0 on success.
216 */
218 double minAnalogVoltage,
219 double maxAnalogVoltage,
220 int32_t* status);
221
222/**
223 * Get compressor configuration from the PH.
224 *
225 * @param[in] handle the PH handle
226 * @param[out] status Error status variable. 0 on success.
227 * @return compressor configuration
228 */
230 HAL_REVPHHandle handle, int32_t* status);
231
232/**
233 * Returns the state of the digital pressure switch.
234 *
235 * @param[in] handle the PH handle
236 * @param[out] status Error status variable. 0 on success.
237 * @return True if pressure switch indicates that the system is full,
238 * otherwise false.
239 */
241
242/**
243 * Returns the current drawn by the compressor.
244 *
245 * @param[in] handle the PH handle
246 * @param[out] status Error status variable. 0 on success.
247 * @return The current drawn by the compressor in amps.
248 */
250
251/**
252 * Returns the raw voltage of the specified analog
253 * input channel.
254 *
255 * @param[in] handle the PH handle
256 * @param[in] channel The analog input channel to read voltage from.
257 * @param[out] status Error status variable. 0 on success.
258 * @return The voltage of the specified analog input channel in volts.
259 */
261 int32_t* status);
262
263/**
264 * Returns the current input voltage for the PH.
265 *
266 * @param[in] handle the PH handle
267 * @param[out] status Error status variable. 0 on success.
268 * @return The input voltage in volts.
269 */
271
272/**
273 * Returns the current voltage of the regulated 5v supply.
274 *
275 * @param[in] handle the PH handle
276 * @param[out] status Error status variable. 0 on success.
277 * @return The current voltage of the 5v supply in volts.
278 */
280
281/**
282 * Returns the total current drawn by all solenoids.
283 *
284 * @param[in] handle the PH handle
285 * @param[out] status Error status variable. 0 on success.
286 * @return Total current drawn by all solenoids in amps.
287 */
289
290/**
291 * Returns the current voltage of the solenoid power supply.
292 *
293 * @param[in] handle the PH handle
294 * @param[out] status Error status variable. 0 on success.
295 * @return The current voltage of the solenoid power supply in volts.
296 */
298
299/**
300 * Returns the hardware and firmware versions of the PH.
301 *
302 * @param[in] handle the PH handle
303 * @param[out] version The hardware and firmware versions.
304 * @param[out] status Error status variable. 0 on success.
305 */
307 int32_t* status);
308
309/**
310 * Gets a bitmask of solenoid values.
311 *
312 * @param[in] handle the PH handle
313 * @param[out] status Error status variable. 0 on success.
314 * @return solenoid values
315 */
317
318/**
319 * Sets solenoids on a PH.
320 *
321 * @param[in] handle the PH handle
322 * @param[in] mask bitmask to set
323 * @param[in] values solenoid values
324 * @param[out] status Error status variable. 0 on success.
325 */
327 int32_t* status);
328
329/**
330 * Fire a single solenoid shot for the specified duration.
331 *
332 * @param[in] handle the PH handle
333 * @param[in] index solenoid index
334 * @param[in] durMs shot duration in ms
335 * @param[out] status Error status variable. 0 on success.
336 */
338 int32_t* status);
339
340/**
341 * Returns the faults currently active on the PH.
342 *
343 * @param[in] handle the PH handle
344 * @param[out] faults The faults.
345 * @param[out] status Error status variable. 0 on success.
346 */
348 int32_t* status);
349
350/**
351 * Returns the sticky faults currently active on this device.
352 *
353 * @param[in] handle the PH handle
354 * @param[out] stickyFaults The sticky faults.
355 * @param[out] status Error status variable. 0 on success.
356 */
358 HAL_REVPHStickyFaults* stickyFaults,
359 int32_t* status);
360
361/**
362 * Clears the sticky faults.
363 *
364 * @param[in] handle the PH handle
365 * @param[out] status Error status variable. 0 on success.
366 */
368
369#ifdef __cplusplus
370} // extern "C"
371#endif
372/** @} */
@ HAL_ENUM
Definition: Value.h:14
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
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
Definition: REVPH.h:21
@ HAL_REVPHCompressorConfigType_kAnalog
Definition: REVPH.h:23
@ HAL_REVPHCompressorConfigType_kHybrid
Definition: REVPH.h:24
@ HAL_REVPHCompressorConfigType_kDigital
Definition: REVPH.h:22
int32_t HAL_Bool
Definition: Types.h:73
HAL_Handle HAL_REVPHHandle
Definition: Types.h:71
::uint32_t uint32_t
Definition: Meta.h:56
::int32_t int32_t
Definition: Meta.h:57
Storage for compressor config.
Definition: REVPH.h:42
double maxAnalogVoltage
Definition: REVPH.h:44
double minAnalogVoltage
Definition: REVPH.h:43
HAL_Bool useDigital
Definition: REVPH.h:46
HAL_Bool forceDisable
Definition: REVPH.h:45
Storage for REV PH Faults.
Definition: REVPH.h:52
uint32_t brownout
Definition: REVPH.h:72
uint32_t channel1Fault
Definition: REVPH.h:54
uint32_t channel4Fault
Definition: REVPH.h:57
uint32_t solenoidOverCurrent
Definition: REVPH.h:71
uint32_t compressorOverCurrent
Definition: REVPH.h:69
uint32_t channel0Fault
Definition: REVPH.h:53
uint32_t channel14Fault
Definition: REVPH.h:67
uint32_t compressorOpen
Definition: REVPH.h:70
uint32_t canWarning
Definition: REVPH.h:73
uint32_t channel5Fault
Definition: REVPH.h:58
uint32_t channel3Fault
Definition: REVPH.h:56
uint32_t hardwareFault
Definition: REVPH.h:74
uint32_t channel13Fault
Definition: REVPH.h:66
uint32_t channel10Fault
Definition: REVPH.h:63
uint32_t channel15Fault
Definition: REVPH.h:68
uint32_t channel9Fault
Definition: REVPH.h:62
uint32_t channel2Fault
Definition: REVPH.h:55
uint32_t channel12Fault
Definition: REVPH.h:65
uint32_t channel8Fault
Definition: REVPH.h:61
uint32_t channel11Fault
Definition: REVPH.h:64
uint32_t channel7Fault
Definition: REVPH.h:60
uint32_t channel6Fault
Definition: REVPH.h:59
Storage for REV PH Sticky Faults.
Definition: REVPH.h:80
uint32_t brownout
Definition: REVPH.h:84
uint32_t solenoidOverCurrent
Definition: REVPH.h:83
uint32_t compressorOverCurrent
Definition: REVPH.h:81
uint32_t hasReset
Definition: REVPH.h:87
uint32_t compressorOpen
Definition: REVPH.h:82
uint32_t canWarning
Definition: REVPH.h:85
uint32_t canBusOff
Definition: REVPH.h:86
Storage for REV PH Version.
Definition: REVPH.h:30
uint32_t uniqueId
Definition: REVPH.h:36
uint32_t hardwareMinor
Definition: REVPH.h:34
uint32_t firmwareMinor
Definition: REVPH.h:32
uint32_t firmwareFix
Definition: REVPH.h:33
uint32_t hardwareMajor
Definition: REVPH.h:35
uint32_t firmwareMajor
Definition: REVPH.h:31