Class AnalogJNI
public class AnalogJNI extends JNIWrapper
- See Also:
- "hal/AnalogInput.h", "hal/AnalogOutput.h", "hal/AnalogAccumulator.h", "hal/AnalogTrigger.h"
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AnalogJNI.AnalogTriggerType
native declaration : AthenaJava\target\native\include\HAL\Analog.h:58
enum values -
Method Summary
Modifier and Type Method Description static 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 boolean
checkAnalogOutputChannel(int channel)
Checks that the analog output channel number is valid.static void
cleanAnalogTrigger(int analogTriggerHandle)
Frees an analog trigger.static void
freeAnalogInputPort(int portHandle)
Frees an analog input port.static void
freeAnalogOutputPort(int portHandle)
Frees an analog output port.static int
getAccumulatorCount(int analogPortHandle)
Read the number of accumulated values.static void
getAccumulatorOutput(int analogPortHandle, AccumulatorResult result)
Read the accumulated value and the number of accumulated values atomically.static long
getAccumulatorValue(int analogPortHandle)
Read the accumulated value.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 double
getAnalogOutput(int portHandle)
Gets the current analog output value.static int
getAnalogOversampleBits(int analogPortHandle)
Gets the number of oversample bits.static double
getAnalogSampleRate()
Gets the current sample rate.static int
getAnalogTriggerFPGAIndex(int analogTriggerHandle)
Get the FPGA index for the AnlogTrigger.static boolean
getAnalogTriggerInWindow(int analogTriggerHandle)
Returns the InWindow output of the analog trigger.static boolean
getAnalogTriggerOutput(int analogTriggerHandle, int type)
Gets the state of the analog trigger output.static boolean
getAnalogTriggerTriggerState(int analogTriggerHandle)
Returns the TriggerState output of the analog trigger.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 void
initAccumulator(int analogPortHandle)
Initialize the accumulator.static int
initializeAnalogInputPort(int halPortHandle)
Initializes the analog input port using the given port object.static int
initializeAnalogOutputPort(int halPortHandle)
Initializes the analog output port using the given port object.static int
initializeAnalogTrigger(int analogInputHandle)
Initializes an analog trigger.static int
initializeAnalogTriggerDutyCycle(int dutyCycleHandle)
Initializes an analog trigger with a Duty Cycle input.static boolean
isAccumulatorChannel(int analogPortHandle)
Is the channel attached to an accumulator.static void
resetAccumulator(int analogPortHandle)
Resets the accumulator to the initial value.static void
setAccumulatorCenter(int analogPortHandle, int center)
Set the center value of the accumulator.static void
setAccumulatorDeadband(int analogPortHandle, int deadband)
Set the accumulator's deadband.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
setAnalogOutput(int portHandle, double voltage)
Sets an analog output value.static void
setAnalogOversampleBits(int analogPortHandle, int bits)
Sets the number of oversample bits.static void
setAnalogSampleRate(double samplesPerSecond)
Sets the sample rate.static void
setAnalogTriggerAveraged(int analogTriggerHandle, boolean useAveragedValue)
Configures the analog trigger to use the averaged vs.static void
setAnalogTriggerFiltered(int analogTriggerHandle, boolean useFilteredValue)
Configures the analog trigger to use a filtered value.static void
setAnalogTriggerLimitsDutyCycle(int analogTriggerHandle, double lower, double higher)
Sets the upper and lower limits of the analog trigger.static void
setAnalogTriggerLimitsRaw(int analogTriggerHandle, int lower, int upper)
Sets the raw ADC upper and lower limits of the analog trigger.static void
setAnalogTriggerLimitsVoltage(int analogTriggerHandle, double lower, double upper)
Sets the upper and lower limits of the analog trigger.
-
Method Details
-
initializeAnalogInputPort
Initializes the analog input port using the given port object.- Parameters:
halPortHandle
- Handle to the port to initialize.- Returns:
- the created analog input handle
- See Also:
- "HAL_InitializeAnalogInputPort"
-
freeAnalogInputPort
Frees an analog input port.- Parameters:
portHandle
- Handle to the analog port.- See Also:
- "HAL_FreeAnalogInputPort"
-
initializeAnalogOutputPort
Initializes the analog output port using the given port object.- Parameters:
halPortHandle
- handle to the port- Returns:
- the created analog output handle
- See Also:
- "HAL_InitializeAnalogOutputPort"
-
freeAnalogOutputPort
Frees an analog output port.- Parameters:
portHandle
- the analog output handle- See Also:
- "HAL_FreeAnalogOutputPort"
-
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"
-
checkAnalogOutputChannel
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_CheckAnalogOutputChannel"
-
setAnalogInputSimDevice
Indicates the analog input is used by a simulated device.- Parameters:
handle
- the analog input handledevice
- simulated device handle- See Also:
- "HAL_SetAnalogInputSimDevice"
-
setAnalogOutput
Sets an analog output value.- Parameters:
portHandle
- the analog output handlevoltage
- the voltage (0-5v) to output- See Also:
- "HAL_SetAnalogOutput"
-
getAnalogOutput
Gets the current analog output value.- Parameters:
portHandle
- the analog output handle- Returns:
- the current output voltage (0-5v)
- See Also:
- "HAL_GetAnalogOutput"
-
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 5V 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"
-
isAccumulatorChannel
Is the channel attached to an accumulator.- Parameters:
analogPortHandle
- Handle to the analog port.- Returns:
- The analog channel is attached to an accumulator.
- See Also:
- "HAL_IsAccumulatorChannel"
-
initAccumulator
Initialize the accumulator.- Parameters:
analogPortHandle
- Handle to the analog port.- See Also:
- "HAL_InitAccumulator"
-
resetAccumulator
Resets the accumulator to the initial value.- Parameters:
analogPortHandle
- Handle to the analog port.- See Also:
- "HAL_ResetAccumulator"
-
setAccumulatorCenter
Set the center value of the accumulator.The center value is subtracted from each A/D value before it is added to the accumulator. This is used for the center value of devices like gyros and accelerometers to make integration work and to take the device offset into account when integrating.
This center value is based on the output of the oversampled and averaged source from channel 1. Because of this, any non-zero oversample bits will affect the size of the value for this field.
- Parameters:
analogPortHandle
- Handle to the analog port.center
- The center value of the accumulator.- See Also:
- "HAL_SetAccumulatorCenter"
-
setAccumulatorDeadband
Set the accumulator's deadband.- Parameters:
analogPortHandle
- Handle to the analog port.deadband
- The deadband of the accumulator.- See Also:
- "HAL_SetAccumulatorDeadband"
-
getAccumulatorValue
Read the accumulated value.Read the value that has been accumulating on channel 1. The accumulator is attached after the oversample and average engine.
- Parameters:
analogPortHandle
- Handle to the analog port.- Returns:
- The 64-bit value accumulated since the last Reset().
- See Also:
- "HAL_GetAccumulatorValue"
-
getAccumulatorCount
Read the number of accumulated values.Read the count of the accumulated values since the accumulator was last Reset().
- Parameters:
analogPortHandle
- Handle to the analog port.- Returns:
- The number of times samples from the channel were accumulated.
- See Also:
- "HAL_GetAccumulatorCount"
-
getAccumulatorOutput
Read the accumulated value and the number of accumulated values atomically.This function reads the value and count from the FPGA atomically. This can be used for averaging.
- Parameters:
analogPortHandle
- Handle to the analog port.result
- Accumulator result.- See Also:
- "HAL_GetAccumulatorOutput"
-
initializeAnalogTrigger
Initializes an analog trigger.- Parameters:
analogInputHandle
- the analog input to use for triggering- Returns:
- the created analog trigger handle
- See Also:
- "HAL_InitializeAnalogTrigger"
-
initializeAnalogTriggerDutyCycle
Initializes an analog trigger with a Duty Cycle input.- Parameters:
dutyCycleHandle
- the analog input to use for duty cycle- Returns:
- tbe created analog trigger handle
- See Also:
- "HAL_InitializeAnalogTriggerDutyCycle"
-
cleanAnalogTrigger
Frees an analog trigger.- Parameters:
analogTriggerHandle
- the trigger handle- See Also:
- "HAL_CleanAnalogTrigger"
-
setAnalogTriggerLimitsRaw
Sets the raw ADC upper and lower limits of the analog trigger.HAL_SetAnalogTriggerLimitsVoltage or HAL_SetAnalogTriggerLimitsDutyCycle is likely better in most cases.
- Parameters:
analogTriggerHandle
- the trigger handlelower
- the lower ADC valueupper
- the upper ADC value- See Also:
- "HAL_SetAnalogTriggerLimitsRaw"
-
setAnalogTriggerLimitsDutyCycle
public static void setAnalogTriggerLimitsDutyCycle(int analogTriggerHandle, double lower, double higher)Sets the upper and lower limits of the analog trigger.The limits are given as floating point duty cycle values.
- Parameters:
analogTriggerHandle
- the trigger handlelower
- the lower duty cycle valuehigher
- the upper duty cycle value- See Also:
- "HAL_SetAnalogTriggerLimitsDutyCycle"
-
setAnalogTriggerLimitsVoltage
public static void setAnalogTriggerLimitsVoltage(int analogTriggerHandle, double lower, double upper)Sets the upper and lower limits of the analog trigger.The limits are given as floating point voltage values.
- Parameters:
analogTriggerHandle
- the trigger handlelower
- the lower voltage valueupper
- the upper voltage value- See Also:
- "HAL_SetAnalogTriggerLimitsVoltage"
-
setAnalogTriggerAveraged
Configures the analog trigger to use the averaged vs. raw values.If the value is true, then the averaged value is selected for the analog trigger, otherwise the immediate value is used.
This is not allowed to be used if filtered mode is set. This is not allowed to be used with Duty Cycle based inputs.
- Parameters:
analogTriggerHandle
- the trigger handleuseAveragedValue
- true to use averaged values, false for raw- See Also:
- "HAL_SetAnalogTriggerAveraged"
-
setAnalogTriggerFiltered
Configures the analog trigger to use a filtered value.The analog trigger will operate with a 3 point average rejection filter. This is designed to help with 360 degree pot applications for the period where the pot crosses through zero.
This is not allowed to be used if averaged mode is set.
- Parameters:
analogTriggerHandle
- the trigger handleuseFilteredValue
- true to use filtered values, false for average or raw- See Also:
- "HAL_SetAnalogTriggerFiltered"
-
getAnalogTriggerInWindow
Returns the InWindow output of the analog trigger.True if the analog input is between the upper and lower limits.
- Parameters:
analogTriggerHandle
- the trigger handle- Returns:
- the InWindow output of the analog trigger
- See Also:
- "HAL_GetAnalogTriggerInWindow"
-
getAnalogTriggerTriggerState
Returns the TriggerState output of the analog trigger.True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.
- Parameters:
analogTriggerHandle
- the trigger handle- Returns:
- the TriggerState output of the analog trigger
- See Also:
- "HAL_GetAnalogTriggerTriggerState"
-
getAnalogTriggerOutput
Gets the state of the analog trigger output.- Parameters:
analogTriggerHandle
- the trigger handletype
- the type of trigger to trigger on- Returns:
- the state of the analog trigger output
- See Also:
- "HAL_GetAnalogTriggerOutput"
-
getAnalogTriggerFPGAIndex
Get the FPGA index for the AnlogTrigger.- Parameters:
analogTriggerHandle
- the trigger handle- Returns:
- the FPGA index
- See Also:
- "HAL_GetAnalogTriggerFPGAIndex"
-