#include <rb8510_dac12.h>
Inherits RulbusDevice.
Generate a unipolar or bipolar voltage.
Module RB8510 is a dual 12-bit Digital to Analog Converter. It contains two 12-bit Digital to Analog Converters (DACs), each connecting to a BNC connector on the front panel. There are no inputs.
At production time, each DAC is configured for unipolar or bipolar operation and its output voltage range is defined as 5, 10 or 20V.
The module cannot be queried about these settings, so they must be specified when the DAC is created through its constructor. When a DAC is created, its output is set to 0 Volt.
The following table shows the volt-per-bit values for the various output voltage ranges.
Voltage range | volt-per-bit bipolar ----------------------+-------------------------- 0 .. 5.11875 V | 1.25 mV 0 0 .. 10.2375 V | 2.5 mV 0 0 .. 20.475 V | 5 mV 0 -5.12 .. 5.1175 V | 2.5 mV 1 -10.24 .. 10.235 V | 5 mV 1
The class provides methods to set and get the output voltage and methods to set and get the DAC-register code.
Rulbus::RB8510_Dac12 dac_ch0( "dac:channel-0" ); Rulbus::RB8510_Dac12 dac_ch1( "dac:channel-1", def_addr + 2 ); dac_ch0.setVoltage( 1.23 ); dac_ch1.setVoltage( 5.12 );
For each channel of the DAC module, a separate object must be created.
See dac.cpp for a complete example.
Module RB8510 contains two 12-bit DACs. Each DAC has two byte-wide registers to which to write the 12-bit code to in order to set the DAC- output to a certain voltage.
Register | Offset Rd/Wr Description --------------+----------------------------------------------------------- MSB | 0 write write high order byte to DAC-msb LSB | 1 write write low order byte to DAC-lsb
The DAC's configuration determines what output voltage a certain code gives. The following table shows the translation of DAC-codes into output voltage ranges.
DAC-code | volt-per-bit bipolar Voltage range --------------+--------------------------------------------- 0 .. 0xFFF | 1.25 mV 0 0 .. 5.11875 V 0 .. 0xFFF | 2.5 mV 0 0 .. 10.2375 V 0 .. 0xFFF | 5 mV 0 0 .. 20.475 V 0 .. 0xFFF | 2.5 mV 1 -5.12 .. 5.1175 V 0 .. 0xFFF | 5 mV 1 -10.24 .. 10.235 V
The DAC module may or may not have a sample & hold at its output. In the latter case the output voltage is not set in an atomic operation and the voltage may show unintended spikes when changed.
Public Types | |
typedef Int | Value |
register value type | |
Public Member Functions | |
Construction | |
RB8510_Dac12 (NameCref aName, Addr aAddr=DEF_ADDR, Rack aRack=DEF_RACK, bool aBipolarFlag=DEF_BIP, Real aVoltPerBit=DEF_VPB) | |
constructor; set output voltage to 0V; may throw RulbusOpenError. | |
~RB8510_Dac12 () | |
destructor. | |
Accessors | |
Volt | voltage () const |
the current DAC output voltage. | |
Value | value () const |
the current DAC-register value. | |
bool | isBipolar () const |
true if DAC is configured for bipolar operation. | |
float | voltperbit () const |
the DAC's volt-per-bit configuration. | |
Mutators | |
void | setVoltage (Volt aVoltage) |
set DAC output to specified voltage; may throw RulbusRangeError. | |
void | setValue (Value aValue) |
set DAC-register to specified value; may throw RulbusRangeError. | |
Static Public Attributes | |
Defaults | |
const Addr | DEF_ADDR = 0xD0 |
default address | |
const bool | DEF_BIP = true |
default bipolar | |
const Real | DEF_VPB = 5e-3 |
default bipolar, -10.24..+10.23V | |
Limits | |
const Value | LIM_MINVAL = 0x0000 |
min. value for unipolar DAC-code | |
const Value | LIM_MAXVAL = 0x0FFF |
max. value for unipolar DAC-code | |
const Value | LIM_BIPVAL = 0x0800 |
offset value for bipolar DAC-code | |
Protected Member Functions | |
Construction and Assignment | |
RB8510_Dac12 () | |
prevent default construction | |
RB8510_Dac12 (RB8510_Dac12Cref rhs) | |
prevent copying | |
RB8510_Dac12Ref | operator= (RB8510_Dac12Cref rhs) |
prevent copying | |
Private Attributes | |
Data | |
Value | theRegister |
last code sent to DAC register | |
bool | theBipolarFlag |
DAC is bipolar. | |
Real | theVoltPerBit |
DAC output sensitivity. | |
Static Private Attributes | |
Register offsets | |
const int | OFF_MSB = 0 |
MSB register offset. | |
const int | OFF_LSB = 1 |
LSB register offset. | |
const int | ADR_WIDTH = OFF_LSB + 1 |
address with |