Now you can download a copy of these docs so you can use them offline! Download now

#include <AnalogChannel.h>

Inheritance diagram for AnalogChannel:
Collaboration diagram for AnalogChannel:

Public Member Functions

 AnalogChannel (uint8_t moduleNumber, uint32_t channel)
 
 AnalogChannel (uint32_t channel)
 
virtual ~AnalogChannel ()
 
AnalogModuleGetModule ()
 
int16_t GetValue ()
 
int32_t GetAverageValue ()
 
float GetVoltage ()
 
float GetAverageVoltage ()
 
uint8_t GetModuleNumber ()
 
uint32_t GetChannel ()
 
void SetAverageBits (uint32_t bits)
 
uint32_t GetAverageBits ()
 
void SetOversampleBits (uint32_t bits)
 
uint32_t GetOversampleBits ()
 
uint32_t GetLSBWeight ()
 
int32_t GetOffset ()
 
bool IsAccumulatorChannel ()
 
void InitAccumulator ()
 
void SetAccumulatorInitialValue (INT64 value)
 
void ResetAccumulator ()
 
void SetAccumulatorCenter (int32_t center)
 
void SetAccumulatorDeadband (int32_t deadband)
 
INT64 GetAccumulatorValue ()
 
uint32_t GetAccumulatorCount ()
 
void GetAccumulatorOutput (INT64 *value, uint32_t *count)
 
void SetVoltageForPID (bool shouldUseVoltageForPID)
 
double PIDGet ()
 
void UpdateTable ()
 
void StartLiveWindowMode ()
 
void StopLiveWindowMode ()
 
std::string GetSmartDashboardType ()
 
void InitTable (ITable *subTable)
 
ITableGetTable ()
 
- Public Member Functions inherited from SensorBase
 SensorBase ()
 
virtual ~SensorBase ()
 
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (ErrorBase *rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Static Public Attributes

static const uint8_t kAccumulatorModuleNumber = 1
 
static const uint32_t kAccumulatorNumChannels = 2
 
static const uint32_t kAccumulatorChannels [kAccumulatorNumChannels] = {1, 2}
 
- Static Public Attributes inherited from SensorBase
static const uint32_t kSystemClockTicksPerMicrosecond = 40
 
static const uint32_t kDigitalChannels = 14
 
static const uint32_t kAnalogChannels = 8
 
static const uint32_t kAnalogModules = 2
 
static const uint32_t kDigitalModules = 2
 
static const uint32_t kSolenoidChannels = 8
 
static const uint32_t kSolenoidModules = 2
 
static const uint32_t kPwmChannels = 10
 
static const uint32_t kRelayChannels = 8
 
static const uint32_t kChassisSlots = 8
 

Additional Inherited Members

- Public Types inherited from PIDSource
enum  PIDSourceParameter { kDistance, kRate, kAngle }
 
- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
 
static uint32_t GetDefaultAnalogModule ()
 
static uint32_t GetDefaultDigitalModule ()
 
static uint32_t GetDefaultSolenoidModule ()
 
static bool CheckAnalogModule (uint8_t moduleNumber)
 
static bool CheckDigitalModule (uint8_t moduleNumber)
 
static bool CheckPWMModule (uint8_t moduleNumber)
 
static bool CheckRelayModule (uint8_t moduleNumber)
 
static bool CheckSolenoidModule (uint8_t moduleNumber)
 
static bool CheckDigitalChannel (uint32_t channel)
 
static bool CheckRelayChannel (uint32_t channel)
 
static bool CheckPWMChannel (uint32_t channel)
 
static bool CheckAnalogChannel (uint32_t channel)
 
static bool CheckSolenoidChannel (uint32_t channel)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 
- Protected Member Functions inherited from SensorBase
void AddToSingletonList ()
 
- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
 
static Error _globalError
 

Detailed Description

Analog channel class.

Each analog channel is read from hardware as a 12-bit number representing -10V to 10V.

Connected to each analog channel is an averaging and oversampling engine. This engine accumulates the specified ( by SetAverageBits() and SetOversampleBits() ) number of samples before returning a new value. This is not a sliding window average. The only difference between the oversampled samples and the averaged samples is that the oversampled samples are simply accumulated effectively increasing the resolution, while the averaged samples are divided by the number of samples to retain the resolution, but get more stable values.

Definition at line 29 of file AnalogChannel.h.

Constructor & Destructor Documentation

AnalogChannel::AnalogChannel ( uint8_t  moduleNumber,
uint32_t  channel 
)

Construct an analog channel on a specified module.

Parameters
moduleNumberThe analog module (1 or 2).
channelThe channel number to represent.

Definition at line 71 of file AnalogChannel.cpp.

AnalogChannel::AnalogChannel ( uint32_t  channel)
explicit

Construct an analog channel on the default module.

Parameters
channelThe channel number to represent.

Definition at line 81 of file AnalogChannel.cpp.

AnalogChannel::~AnalogChannel ( )
virtual

Channel destructor.

Definition at line 89 of file AnalogChannel.cpp.

Member Function Documentation

uint32_t AnalogChannel::GetAccumulatorCount ( )

Read the number of accumulated values.

Read the count of the accumulated values since the accumulator was last Reset().

Returns
The number of times samples from the channel were accumulated.

Definition at line 383 of file AnalogChannel.cpp.

void AnalogChannel::GetAccumulatorOutput ( INT64 *  value,
uint32_t *  count 
)

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
valuePointer to the 64-bit accumulated output.
countPointer to the number of accumulation cycles.

Definition at line 407 of file AnalogChannel.cpp.

INT64 AnalogChannel::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.

Returns
The 64-bit value accumulated since the last Reset().

Definition at line 362 of file AnalogChannel.cpp.

uint32_t AnalogChannel::GetAverageBits ( )

Get the number of averaging bits previously configured. 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.

Returns
Number of bits of averaging previously configured.

Definition at line 226 of file AnalogChannel.cpp.

int32_t AnalogChannel::GetAverageValue ( )

Get a sample from the output of the oversample and average engine for this 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**(OversamplBits + AverageBits) samples have been acquired from the module on this channel. Use GetAverageVoltage() to get the analog value in calibrated units.

Returns
A sample from the oversample and average engine for this channel.

Definition at line 125 of file AnalogChannel.cpp.

float AnalogChannel::GetAverageVoltage ( )

Get a scaled sample from the output of the oversample and average engine for this 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.

Returns
A scaled sample from the output of the oversample and average engine for this channel.

Definition at line 149 of file AnalogChannel.cpp.

uint32_t AnalogChannel::GetChannel ( )

Get the channel number.

Returns
The channel number.

Definition at line 189 of file AnalogChannel.cpp.

uint32_t AnalogChannel::GetLSBWeight ( )

Get 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)

Returns
Least significant bit weight.

Definition at line 164 of file AnalogChannel.cpp.

AnalogModule * AnalogChannel::GetModule ( )

Get the analog module that this channel is on.

Returns
A pointer to the AnalogModule that this channel is on.

Definition at line 98 of file AnalogChannel.cpp.

uint8_t AnalogChannel::GetModuleNumber ( )

Get the module number.

Returns
The module number.

Definition at line 199 of file AnalogChannel.cpp.

int32_t AnalogChannel::GetOffset ( )

Get 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)

Returns
Offset constant.

Definition at line 179 of file AnalogChannel.cpp.

uint32_t AnalogChannel::GetOversampleBits ( )

Get the number of oversample bits previously configured. 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.

Returns
Number of bits of oversampling previously configured.

Definition at line 253 of file AnalogChannel.cpp.

std::string AnalogChannel::GetSmartDashboardType ( )
virtual
Returns
the string representation of the named data type that will be used by the smart dashboard for this sendable

Implements Sendable.

Definition at line 469 of file AnalogChannel.cpp.

ITable * AnalogChannel::GetTable ( )
virtual
Returns
the table that is currently associated with the sendable

Implements Sendable.

Definition at line 478 of file AnalogChannel.cpp.

int16_t AnalogChannel::GetValue ( )

Get a sample straight from this channel on the module. The sample is a 12-bit value representing the -10V to 10V 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.

Returns
A sample straight from this channel on the module.

Definition at line 110 of file AnalogChannel.cpp.

float AnalogChannel::GetVoltage ( )

Get a scaled sample straight from this channel on the module. The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset().

Returns
A scaled sample straight from this channel on the module.

Definition at line 136 of file AnalogChannel.cpp.

void AnalogChannel::InitAccumulator ( )

Initialize the accumulator.

Definition at line 278 of file AnalogChannel.cpp.

void AnalogChannel::InitTable ( ITable subtable)
virtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Implements Sendable.

Definition at line 473 of file AnalogChannel.cpp.

bool AnalogChannel::IsAccumulatorChannel ( )

Is the channel attached to an accumulator.

Returns
The analog channel is attached to an accumulator.

Definition at line 264 of file AnalogChannel.cpp.

double AnalogChannel::PIDGet ( )
virtual

Get the Average value for the PID Source base object.

Returns
The average voltage.

Implements PIDSource.

Definition at line 445 of file AnalogChannel.cpp.

void AnalogChannel::ResetAccumulator ( )

Resets the accumulator to the initial value.

Definition at line 302 of file AnalogChannel.cpp.

void AnalogChannel::SetAccumulatorCenter ( int32_t  center)

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.

Definition at line 325 of file AnalogChannel.cpp.

void AnalogChannel::SetAccumulatorDeadband ( int32_t  deadband)

Set the accumulator's deadband.

Definition at line 341 of file AnalogChannel.cpp.

void AnalogChannel::SetAccumulatorInitialValue ( INT64  initialValue)

Set an inital value for the accumulator.

This will be added to all values returned to the user.

Parameters
initialValueThe value that the accumulator should start from when reset.

Definition at line 293 of file AnalogChannel.cpp.

void AnalogChannel::SetAverageBits ( uint32_t  bits)

Set 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
bitsNumber of bits of averaging.

Definition at line 213 of file AnalogChannel.cpp.

void AnalogChannel::SetOversampleBits ( uint32_t  bits)

Set 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
bitsNumber of bits of oversampling.

Definition at line 240 of file AnalogChannel.cpp.

void AnalogChannel::SetVoltageForPID ( bool  shouldUseVoltageForPID)

Set whether to use voltage or value for PIDGet. This method determines whether PIDGet should use average voltage or value for PIDControllers for a particular channel. This is to preserve compatibility with existng programs and is likely to change in favor of voltage for 2015 and beyond.

Parameters
shouldUseVoltageForPIDtrue if voltage should be used for PIDGet.

Definition at line 436 of file AnalogChannel.cpp.

void AnalogChannel::StartLiveWindowMode ( )
virtual

Start having this sendable object automatically respond to value changes reflect the value on the table.

Implements LiveWindowSendable.

Definition at line 461 of file AnalogChannel.cpp.

void AnalogChannel::StopLiveWindowMode ( )
virtual

Stop having this sendable object automatically respond to value changes.

Implements LiveWindowSendable.

Definition at line 465 of file AnalogChannel.cpp.

void AnalogChannel::UpdateTable ( )
virtual

Update the table for this sendable object with the latest values.

Implements LiveWindowSendable.

Definition at line 455 of file AnalogChannel.cpp.


The documentation for this class was generated from the following files:

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6