RB8509_Adc12 Class Reference
[RB8509 12-bit ADC]

#include <rb8509_adc12.h>

Inherits RulbusDevice.

List of all members.


Detailed Description

Purpose

Measure a voltage.

Description

Module RB8509 is a 8-channel 12-bit analog to digital converter (ADC).

The module has eight analog inputs and a trigger input to start a data acquisition. A data acquisition can also be started by a software trigger.

Module RB8509 contains the following parts:

At production time, the ADC is configured for unipolar or bipolar operation and its input voltage range is defined as 10 or 20V.

The module cannot be queried about these settings, so they must be specified when the ADC is created through its constructor. When a ADC is created, it is configured with the following defaults:

.*) via constructor default argument

The following table shows the volt-per-bit values for the various input voltage ranges.

      Voltage range      |  volt-per-bit   bipolar
   ----------------------+--------------------------
      0    .. 10.2375  V |    2.5  mV        0
     -5.12 ..  5.1175  V |    2.5  mV        1
    -10.24 .. 10.235   V |    5    mV        1
   

Usage

The class provides methods to select the input-channel and gain and to obtain these settings and it provides methods to read the input as (raw) ADC-value or as voltage at the channel's input.

   Rulbus::RB8510_Adc12 adc( "adc" );

   adc.setChannel( 3 );
   adc.autoscale();

   std::cout << adc.name() <<
      ": channel " << adc.channel() <<
      ", gain "    << adc.gain()    << ": " << adc.voltage() << std::endl;

Implementation

Module RB8509 contains an input multiplexer, a programmable amplifier and a 12-bit ADC. The table below shows how these parts can be controlled and how information can be obtained from them.

   Register        Offset    Rd/Wr     Description
   ----------------------------------------------------------------------------
   adclsb          0         read      ADC least significant byte;
                                       resets the end of conversion flip-flop.

   control         0        write      control register
                                       76543210
                                       7        : interrupt enable    (active high)
                                        6       : ext. trigger enable (active high)
                                         54     : gain number selector (1,2,4,8)
                                           3    : multiplexer enable  (active low)
                                            210 : channel selector

   status          1         read      data and status register
                                       76543210
                                       7        : external trigger
                                        6       : interrupt pending
                                         5      : end of conversion (EOC)
                                          4     : ADC busy flag
                                           3210 : high order nibble

   convert         1        write      (start conversion)
                                       76543210 : don't care
   


Public Types

typedef Int Value
 ADC conversion data type.


Public Member Functions

Construction
 RB8509_Adc12 (NameCref aName, Addr aAddr=DEF_ADDR, Rack aRack=DEF_RACK, bool aBipolarFlag=DEF_BIP, Real aVoltPerBit=DEF_VPB, bool aExtTrigInpFlag=DEF_ETI)
 constructor.

 ~RB8509_Adc12 ()
 destructor.

Accessors
int channel () const
 the current channel number [0..7].

int gain () const
 the current gain [1,2,4,8].

Volt voltage ()
 issue software trigger and return input-voltage measured; may throw RulbusTimeoutError; or wait for external trigger and return input-voltage measured.

Value value ()
 issue software trigger and return conversion value; may throw RulbusTimeoutError; or wait for external trigger and return conversion value.

Value result ()
 return last (bipolar) conversion result; requires preceding external trigger or software trigger; when using the latter, it may throw RulbusTimeoutError.

Value rawresult ()
 return last raw conversion result; requires preceding external trigger or software trigger; when using latter, it may throw RulbusTimeoutError.

bool hasExtTriggerInput () const
 true if ADC has trigger input available.

bool extTriggerLevel () const
 the current external trigger level; requesting the level for a non-available trigger input throws a RulbusContextError.

bool isEnabledExtTrigger () const
 true if external trigger-input is enabled.

bool isEnabledMultiplexer () const
 true if multiplexer is enabled.

bool isEnabledInterrupt () const
 true if interrupt is enabled.

bool isBusyAdc () const
 true while ADC is converting.

bool isReady () const
 true if result is available; flag is reset by reading result.

bool isBipolar () const
 true if ADC has bipolar configuration.

bool isPendingInterrupt () const
 true if an interrupt is pending; flag is reset by reading result.

Real voltperbit () const
 the ADC's input sensitivity configuration.

Predicates
bool isValidChannel (int aChannel) const
 true if channel is valid.

bool isValidGain (int aGain) const
 true if gain is valid.

Mutators
void setChannel (int aChannel)
 select a new channel [0..7]; may throw RulbusRangeError.

void setGain (int aGain)
 select new amplifier gain [1,2,4,8]; may throw RulbusRangeError.

void autoscale ()
 determine amplifier gain to fit current signal.

void convert ()
 start an analog to digital conversion.

bool enableMultiplexer (bool enable=true)
 enable or disable multiplexer.

bool enableExtTrigger (bool enable=true)
 enable or disable external trigger-input; enabling a non-available trigger input throws a RulbusContextError.

bool enableInterrupt (bool enable=true)
 enable or disable interrupt.


Static Public Attributes

Defaults
const Addr DEF_ADDR = 0xC0
 default address

const int DEF_GAIN = 1
 default gain value

const int DEF_CHAN = 0
 default channel number

const bool DEF_BIP = true
 default bipolar

const Real DEF_VPB = 5e-3
 default bipolar, -10.24..+10.23V

const bool DEF_ETI = false
 default no external trigger input

Limits
const int LIM_MINCHAN = 0
 min. value for channel selection

const int LIM_MAXCHAN = 7
 max. value for channel selection

const int LIM_MINGAIN = 1
 min. value for gain selection

const int LIM_MAXGAIN = 8
 max. value for gain selection

const Real LIM_MINVPB
 min. value for volt per bit

const Real LIM_MAXVPB
 max. value for volt per bit

const int LIM_TIMOUT = 1000
 maximum conversion-ready testloops

const Value LIM_MINVAL = 0x0000
 min. value for unipolar ADC-code

const Value LIM_MAXVAL = 0x0FFF
 max. value for unipolar ADC-code

const Value LIM_BIPVAL = 0x0800
 offset value for bipolar ADC-code


Protected Member Functions

Construction and Assignment
 RB8509_Adc12 ()
 prevent default construction

 RB8509_Adc12 (RB8509_Adc12Cref rhs)
 prevent copying

RB8509_Adc12Ref operator= (RB8509_Adc12Cref rhs)
 prevent copying

Checkers
void checkChannel (int aChannel) const
 check if channel is valid; may throw RulbusRangeError.

void checkGain (int aGain) const
 check if channel is valid; may throw RulbusRangeError.


Private Attributes

Data
Byte theControlRegister
 control-register contents

bool theExtTrigInpFlag
 ADC has external trigger input.

bool theBipolarFlag
 ADC is bipolar.

Real theVoltPerBit
 ADC input sensitivity.


Static Private Attributes

Register offsets
const int OFF_ADCLSB = 0
 data low order byte

const int OFF_CONTROL = 0
 control-register

const int OFF_STATUS = 1
 data high orde nibble and status

const int OFF_CONVERT = 1
 start conversion

const int ADR_WIDTH = OFF_CONVERT + 1
 address with

Signal masks and shifts
const int MSK_CTLCHAN = 0x07
 mask byte for channel selection

const int MSK_CTLMPLX = 0x08
 mask byte for multiplexer enable

const int MSK_CTLGAIN = 0x30
 mask byte for gain selection

const int MSK_CTLTRIG = 0x40
 mask byte for external trigger

const int MSK_CTLINTR = 0x80
 mask byte for interrupt

const int MSK_STSBSY = 0x10
 mask byte for busy status

const int MSK_STSEOC = 0x20
 mask byte for EOC

const int MSK_STSINTR = 0x40
 mask byte for interrupt

const int MSK_STSTRIG = 0x80
 mask byte for external trigger

const int MSK_VALMSN = 0x0F
 mask byte for high order data bits

const int SHL_CTLCHAN = 0
 shift for channel selection

const int SHL_CTLGAIN = 4
 shift for gain selection


The documentation for this class was generated from the following files:
Generated on Tue Oct 12 14:12:04 2004 for Rulbus Device Class Library for Microsoft Windows by doxygen 1.3.4