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

#include <AnalogModule.h>

Inheritance diagram for AnalogModule:
Collaboration diagram for AnalogModule:

List of all members.

Public Member Functions

void SetSampleRate (float samplesPerSecond)
float GetSampleRate ()
void SetAverageBits (UINT32 channel, UINT32 bits)
UINT32 GetAverageBits (UINT32 channel)
void SetOversampleBits (UINT32 channel, UINT32 bits)
UINT32 GetOversampleBits (UINT32 channel)
INT16 GetValue (UINT32 channel)
INT32 GetAverageValue (UINT32 channel)
float GetAverageVoltage (UINT32 channel)
float GetVoltage (UINT32 channel)
UINT32 GetLSBWeight (UINT32 channel)
INT32 GetOffset (UINT32 channel)
INT32 VoltsToValue (INT32 channel, float voltage)

Static Public Member Functions

static AnalogModuleGetInstance (UINT8 moduleNumber)

Static Public Attributes

static const long kTimebase = 40000000
 40 MHz clock
static const long kDefaultOversampleBits = 0
static const long kDefaultAverageBits = 7
static const float kDefaultSampleRate = 50000.0

Protected Member Functions

 AnalogModule (UINT8 moduleNumber)
virtual ~AnalogModule ()

Friends

class Module

Detailed Description

Analog Module class. Each module can independently sample its channels at a configurable rate. There is a 64-bit hardware accumulator associated with channel 1 on each module. The accumulator is attached to the output of the oversample and average engine so that the center value can be specified in higher resolution resulting in less error.

Definition at line 20 of file AnalogModule.h.


Constructor & Destructor Documentation

AnalogModule::AnalogModule ( UINT8  moduleNumber  )  [explicit, protected]

Create a new instance of an analog module.

Create an instance of the analog module object. Initialize all the parameters to reasonable values on start. Setting a global value on an analog module can be done only once unless subsequent values are set the previously set value. Analog modules are a singleton, so the constructor is never called outside of this class.

Parameters:
moduleNumber The analog module to create (1 or 2).

Definition at line 54 of file AnalogModule.cpp.

AnalogModule::~AnalogModule (  )  [protected, virtual]

Destructor for AnalogModule.

Definition at line 85 of file AnalogModule.cpp.


Member Function Documentation

UINT32 AnalogModule::GetAverageBits ( UINT32  channel  ) 

Get 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:
channel Channel to address.
Returns:
Bits to average.

Definition at line 214 of file AnalogModule.cpp.

INT32 AnalogModule::GetAverageValue ( UINT32  channel  ) 

Get 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**(OversamplBits + AverageBits) samples have been acquired from the module on this channel. Use GetAverageVoltage() to get the analog value in calibrated units.

Parameters:
channel Channel number to read.
Returns:
A sample from the oversample and average engine for the channel.

Definition at line 298 of file AnalogModule.cpp.

float AnalogModule::GetAverageVoltage ( UINT32  channel  ) 

Get 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:
channel The channel to read.
Returns:
A scaled sample from the output of the oversample and average engine for the channel.

Definition at line 377 of file AnalogModule.cpp.

AnalogModule * AnalogModule::GetInstance ( UINT8  moduleNumber  )  [static]

Get an instance of an Analog Module.

Singleton analog module creation where a module is allocated on the first use and the same module is returned on subsequent uses.

Parameters:
moduleNumber The analog module to get (1 or 2).
Returns:
A pointer to the AnalogModule.

Definition at line 28 of file AnalogModule.cpp.

UINT32 AnalogModule::GetLSBWeight ( UINT32  channel  ) 

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)

Parameters:
channel The channel to get calibration data for.
Returns:
Least significant bit weight.

Definition at line 397 of file AnalogModule.cpp.

INT32 AnalogModule::GetOffset ( UINT32  channel  ) 

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)

Parameters:
channel The channel to get calibration data for.
Returns:
Offset constant.

Definition at line 415 of file AnalogModule.cpp.

UINT32 AnalogModule::GetOversampleBits ( UINT32  channel  ) 

Get 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:
channel Channel to address.
Returns:
Bits to oversample.

Definition at line 248 of file AnalogModule.cpp.

float AnalogModule::GetSampleRate (  ) 

Get the current sample rate on the module.

This assumes one entry in the scan list. This is a global setting for the module and effects all channels.

Returns:
Sample rate.

Definition at line 134 of file AnalogModule.cpp.

INT16 AnalogModule::GetValue ( UINT32  channel  ) 

Get a sample straight from the channel on this 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 the channel on this module.

Definition at line 264 of file AnalogModule.cpp.

float AnalogModule::GetVoltage ( UINT32  channel  ) 

Get 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:
channel The channel to read.
Returns:
A scaled sample straight from the channel on this module.

Definition at line 358 of file AnalogModule.cpp.

void AnalogModule::SetAverageBits ( UINT32  channel,
UINT32  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:
channel Analog channel to configure.
bits Number of bits to average.

Definition at line 198 of file AnalogModule.cpp.

void AnalogModule::SetOversampleBits ( UINT32  channel,
UINT32  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:
channel Analog channel to configure.
bits Number of bits to oversample.

Definition at line 232 of file AnalogModule.cpp.

void AnalogModule::SetSampleRate ( float  samplesPerSecond  ) 

Set the sample rate on the module.

This is a global setting for the module and effects all channels.

Parameters:
samplesPerSecond The number of samples per channel per second.

Definition at line 97 of file AnalogModule.cpp.

INT32 AnalogModule::VoltsToValue ( INT32  channel,
float  voltage 
)

Convert 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:
channel The channel to convert for.
voltage The voltage to convert.
Returns:
The raw value for the channel.

Definition at line 332 of file AnalogModule.cpp.


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

Generated on Thu Jan 12 2012 22:35:26 for WPILibC++ by doxygen 1.7.1