Class AnalogJNI
- See Also:
-
- "hal/AnalogInput.h"
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.hal.JNIWrapper
JNIWrapper.Helper
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkAnalogInputChannel
(int channel) Checks that the analog output channel number is valid.static boolean
checkAnalogModule
(byte module) Checks that the analog module number is valid.static void
freeAnalogInputPort
(int analogPortHandle) Frees an analog input port.static int
getAnalogAverageBits
(int analogPortHandle) Gets the number of averaging bits.static int
getAnalogAverageValue
(int analogPortHandle) Gets a sample from the output of the oversample and average engine for the channel.static double
getAnalogAverageVoltage
(int analogPortHandle) Gets a scaled sample from the output of the oversample and average engine for the channel.static int
getAnalogLSBWeight
(int analogPortHandle) Gets the factory scaling least significant bit weight constant.static int
getAnalogOffset
(int analogPortHandle) Gets the factory scaling offset constant.static int
getAnalogOversampleBits
(int analogPortHandle) Gets the number of oversample bits.static double
Gets the current sample rate.static short
getAnalogValue
(int analogPortHandle) Gets a sample straight from the channel on this module.static double
getAnalogValueToVolts
(int analogPortHandle, int value) Get the analog voltage from a raw value.static double
getAnalogVoltage
(int analogPortHandle) Gets a scaled sample straight from the channel on this module.static int
getAnalogVoltsToValue
(int analogPortHandle, double voltage) Converts a voltage to a raw value for a specified channel.static int
initializeAnalogInputPort
(int channel) Initializes the analog input port using the given port object.static void
setAnalogAverageBits
(int analogPortHandle, int bits) Sets the number of averaging bits.static void
setAnalogInputSimDevice
(int handle, int device) Indicates the analog input is used by a simulated device.static void
setAnalogOversampleBits
(int analogPortHandle, int bits) Sets the number of oversample bits.static void
setAnalogSampleRate
(double samplesPerSecond) Sets the sample rate.Methods inherited from class edu.wpi.first.hal.JNIWrapper
forceLoad, suppressUnused
-
Method Details
-
initializeAnalogInputPort
Initializes the analog input port using the given port object.- Parameters:
channel
- The smartio channel.- Returns:
- the created analog input handle
- See Also:
-
- "HAL_InitializeAnalogInputPort"
-
freeAnalogInputPort
Frees an analog input port.- Parameters:
analogPortHandle
- Handle to the analog port.- See Also:
-
- "HAL_FreeAnalogInputPort"
-
checkAnalogModule
Checks that the analog module number is valid.- Parameters:
module
- The analog module number.- Returns:
- Analog module is valid and present
- See Also:
-
- "HAL_CheckAnalogModule"
-
checkAnalogInputChannel
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:
channel
- The analog output channel number.- Returns:
- Analog channel is valid
- See Also:
-
- "HAL_CheckAnalogInputChannel"
-
setAnalogInputSimDevice
Indicates the analog input is used by a simulated device.- Parameters:
handle
- the analog input handledevice
- simulated device handle- See Also:
-
- "HAL_SetAnalogInputSimDevice"
-
setAnalogSampleRate
Sets the sample rate.This is a global setting for the Athena and effects all channels.
- Parameters:
samplesPerSecond
- The number of samples per channel per second.- See Also:
-
- "HAL_SetAnalogSampleRate"
-
getAnalogSampleRate
Gets the current sample rate.This assumes one entry in the scan list. This is a global setting for the Athena and effects all channels.
- Returns:
- Sample rate.
- See Also:
-
- "HAL_GetAnalogSampleRate"
-
setAnalogAverageBits
Sets the number of averaging bits.This sets the number of averaging bits. The actual number of averaged samples is 2**bits. Use averaging to improve the stability of your measurement at the expense of sampling rate. The averaging is done automatically in the FPGA.
- Parameters:
analogPortHandle
- Handle to the analog port to configure.bits
- Number of bits to average.- See Also:
-
- "HAL_SetAnalogAverageBits"
-
getAnalogAverageBits
Gets the number of averaging bits.This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits. The averaging is done automatically in the FPGA.
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- Bits to average.
- See Also:
-
- "HAL_GetAnalogAverageBits"
-
setAnalogOversampleBits
Sets the number of oversample bits.This sets the number of oversample bits. The actual number of oversampled values is 2**bits. Use oversampling to improve the resolution of your measurements at the expense of sampling rate. The oversampling is done automatically in the FPGA.
- Parameters:
analogPortHandle
- Handle to the analog port to use.bits
- Number of bits to oversample.- See Also:
-
- "HAL_SetAnalogOversampleBits"
-
getAnalogOversampleBits
Gets the number of oversample bits.This gets the number of oversample bits from the FPGA. The actual number of oversampled values is 2**bits. The oversampling is done automatically in the FPGA.
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- Bits to oversample.
- See Also:
-
- "HAL_GetAnalogOversampleBits"
-
getAnalogValue
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:
analogPortHandle
- Handle to the analog port to use.- Returns:
- A sample straight from the channel on this module.
- See Also:
-
- "HAL_GetAnalogValue"
-
getAnalogAverageValue
Gets a sample from the output of the oversample and average engine for the channel.The sample is 12-bit + the value configured in SetOversampleBits(). The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples. This is not a sliding window. The sample will not change until 2**(OversampleBits + AverageBits) samples have been acquired from the module on this channel. Use GetAverageVoltage() to get the analog value in calibrated units.
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- A sample from the oversample and average engine for the channel.
- See Also:
-
- "HAL_GetAnalogAverageValue"
-
getAnalogVoltsToValue
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:
analogPortHandle
- Handle to the analog port to use.voltage
- The voltage to convert.- Returns:
- The raw value for the channel.
- See Also:
-
- "HAL_GetAnalogVoltsToValue"
-
getAnalogValueToVolts
Get the analog voltage from a raw value.- Parameters:
analogPortHandle
- Handle to the analog port the values were read from.value
- The raw analog value- Returns:
- The voltage relating to the value
- See Also:
-
- "HAL_GetAnalogValueToVolts"
-
getAnalogVoltage
Gets a scaled sample straight from the channel on this module.The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset().
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- A scaled sample straight from the channel on this module.
- See Also:
-
- "HAL_GetAnalogVoltage"
-
getAnalogAverageVoltage
Gets a scaled sample from the output of the oversample and average engine for the channel.The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). Using oversampling will cause this value to be higher resolution, but it will update more slowly. Using averaging will cause this value to be more stable, but it will update more slowly.
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- A scaled sample from the output of the oversample and average engine for the channel.
- See Also:
-
- "HAL_GetAnalogAverageVoltage"
-
getAnalogLSBWeight
Gets the factory scaling least significant bit weight constant. The least significant bit weight constant for the channel that was calibrated in manufacturing and stored in an eeprom in the module.Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- Least significant bit weight.
- See Also:
-
- "HAL_GetAnalogLSBWeight"
-
getAnalogOffset
Gets the factory scaling offset constant. The offset constant for the channel that was calibrated in manufacturing and stored in an eeprom in the module.Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
- Parameters:
analogPortHandle
- Handle to the analog port to use.- Returns:
- Offset constant.
- See Also:
-
- "HAL_GetAnalogOffset"
-