AnalogChannel Class Reference

#include <AnalogChannel.h>

Inheritance diagram for AnalogChannel:

Inheritance graph
[legend]
Collaboration diagram for AnalogChannel:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 AnalogChannel (unsigned slot, unsigned channel)
 AnalogChannel (unsigned channel)
virtual ~AnalogChannel ()
AnalogModuleGetModule (void)
signed short GetValue (void)
signed int GetAverageValue (void)
float GetVoltage (void)
float GetAverageVoltage (void)
unsigned GetSlot (void)
unsigned GetChannel (void)
void SetAverageBits (unsigned bits)
unsigned GetAverageBits (void)
void SetOversampleBits (unsigned bits)
unsigned GetOversampleBits (void)
unsigned GetLSBWeight (void)
signed int GetOffset (void)


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 befor 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.


Constructor & Destructor Documentation

AnalogChannel::AnalogChannel ( unsigned  slot,
unsigned  channel 
)

Construct an analog channel on a specified module.

Parameters:
slot The slot that the analog module is plugged into.
channel The channel number to represent.

AnalogChannel::AnalogChannel ( unsigned  channel  ) 

Construct an analog channel on the default module.

Parameters:
channel The channel number to represent.

AnalogChannel::~AnalogChannel (  )  [virtual]

Channel destructor.


Member Function Documentation

AnalogModule * AnalogChannel::GetModule ( void   ) 

Get the analog module that this channel is on.

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

signed short AnalogChannel::GetValue ( void   ) 

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.

signed int AnalogChannel::GetAverageValue ( void   ) 

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.

float AnalogChannel::GetVoltage ( void   ) 

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.

float AnalogChannel::GetAverageVoltage ( void   ) 

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.

unsigned AnalogChannel::GetSlot ( void   ) 

Get the slot that the analog module is plugged into.

Returns:
The slot that the analog module is plugged into.

unsigned AnalogChannel::GetChannel ( void   ) 

Get the channel number.

Returns:
The channel number.

void AnalogChannel::SetAverageBits ( unsigned  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:
bits Number of bits of averaging.

unsigned AnalogChannel::GetAverageBits ( void   ) 

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.

void AnalogChannel::SetOversampleBits ( unsigned  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:
bits Number of bits of oversampling.

unsigned AnalogChannel::GetOversampleBits ( void   ) 

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.

unsigned AnalogChannel::GetLSBWeight ( void   ) 

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.

signed int AnalogChannel::GetOffset ( void   ) 

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.


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

Generated on Thu Oct 2 14:01:22 2008 for WPI Robotics Library by  doxygen 1.5.5