WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
Analog Input Functions

Functions

HAL_AnalogInputHandle HAL_InitializeAnalogInputPort (int32_t channel, const char *allocationLocation, int32_t *status)
 Initializes the analog input port using the given port object.
void HAL_FreeAnalogInputPort (HAL_AnalogInputHandle analogPortHandle)
 Frees an analog input port.
HAL_Bool HAL_CheckAnalogModule (int32_t module)
 Checks that the analog module number is valid.
HAL_Bool HAL_CheckAnalogInputChannel (int32_t channel)
 Checks that the analog output channel number is valid.
void HAL_SetAnalogInputSimDevice (HAL_AnalogInputHandle handle, HAL_SimDeviceHandle device)
 Indicates the analog input is used by a simulated device.
int32_t HAL_GetAnalogValue (HAL_AnalogInputHandle analogPortHandle, int32_t *status)
 Gets a sample straight from the channel on this module.
int32_t HAL_GetAnalogVoltsToValue (HAL_AnalogInputHandle analogPortHandle, double voltage, int32_t *status)
 Converts a voltage to a raw value for a specified channel.
double HAL_GetAnalogVoltage (HAL_AnalogInputHandle analogPortHandle, int32_t *status)
 Gets a scaled sample straight from the channel on this module.
double HAL_GetAnalogValueToVolts (HAL_AnalogInputHandle analogPortHandle, int32_t rawValue, int32_t *status)
 Get the analog voltage from a raw value.

Detailed Description

Function Documentation

◆ HAL_CheckAnalogInputChannel()

HAL_Bool HAL_CheckAnalogInputChannel ( int32_t channel)

Checks that the analog output channel number is valid.

Verifies that the analog channel number is one of the legal channel numbers. Channel numbers are 0-based.

Parameters
[in]channelThe analog output channel number.
Returns
Analog channel is valid

◆ HAL_CheckAnalogModule()

HAL_Bool HAL_CheckAnalogModule ( int32_t module)

Checks that the analog module number is valid.

Parameters
[in]moduleThe analog module number.
Returns
Analog module is valid and present

◆ HAL_FreeAnalogInputPort()

void HAL_FreeAnalogInputPort ( HAL_AnalogInputHandle analogPortHandle)

Frees an analog input port.

Parameters
analogPortHandleHandle to the analog port.

◆ HAL_GetAnalogValue()

int32_t HAL_GetAnalogValue ( HAL_AnalogInputHandle analogPortHandle,
int32_t * status )

Gets a sample straight from the channel on this module.

The sample is a 12-bit value representing the 0V to 3.3V range of the A/D converter in the module. The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.

Parameters
[in]analogPortHandleHandle to the analog port to use.
[out]statusthe error code, or 0 for success
Returns
A sample straight from the channel on this module.

◆ HAL_GetAnalogValueToVolts()

double HAL_GetAnalogValueToVolts ( HAL_AnalogInputHandle analogPortHandle,
int32_t rawValue,
int32_t * status )

Get the analog voltage from a raw value.

Parameters
[in]analogPortHandleHandle to the analog port the values were read from.
[in]rawValueThe raw analog value
[out]statusError status variable. 0 on success.
Returns
The voltage relating to the value

◆ HAL_GetAnalogVoltage()

double HAL_GetAnalogVoltage ( HAL_AnalogInputHandle analogPortHandle,
int32_t * status )

Gets a scaled sample straight from the channel on this module.

The value is scaled to units of Volts.

Parameters
[in]analogPortHandleHandle to the analog port to use.
[out]statusthe error code, or 0 for success
Returns
A scaled sample straight from the channel on this module.

◆ HAL_GetAnalogVoltsToValue()

int32_t HAL_GetAnalogVoltsToValue ( HAL_AnalogInputHandle analogPortHandle,
double voltage,
int32_t * status )

Converts a voltage to a raw value for a specified channel.

This process depends on the calibration of each channel, so the channel must be specified.

Todo
This assumes raw values. Oversampling not supported as is.
Parameters
[in]analogPortHandleHandle to the analog port to use.
[in]voltageThe voltage to convert.
[out]statusthe error code, or 0 for success
Returns
The raw value for the channel.

◆ HAL_InitializeAnalogInputPort()

HAL_AnalogInputHandle HAL_InitializeAnalogInputPort ( int32_t channel,
const char * allocationLocation,
int32_t * status )

Initializes the analog input port using the given port object.

Parameters
[in]channelthe smartio channel.
[in]allocationLocationthe location where the allocation is occurring (can be null)
[out]statusthe error code, or 0 for success
Returns
the created analog input handle

◆ HAL_SetAnalogInputSimDevice()

void HAL_SetAnalogInputSimDevice ( HAL_AnalogInputHandle handle,
HAL_SimDeviceHandle device )

Indicates the analog input is used by a simulated device.

Parameters
handlethe analog input handle
devicesimulated device handle