Digital-to-Analog Conversion

This section describes the steps involved in generating an analog output (performing a D/A conversion) on a selected output channel using direct programming, without the driver software.

Perform an D/A conversion according to the following steps. Each step is discussed in detail, below.

  1. Compute the D/A output value for the desired output voltage.

  2. Compute the LSB and MSB values.

  3. Add the channel number to the MSB.

  4. Set D/A Simultaneous Update bit.

  5. Write the LSB and MSB to the board.

  6. Monitor the DACBUSY status bit.

Compute the D/A Output Value for the Desired Output Voltage

A different formula is required for bipolar and unipolar output ranges.

Note: The DAC cannot generate the actual full-scale reference voltage, which would require an output code of 4096 that is not possible with a 12-bit number. The maximum output value is 4095. Therefore, the maximum possible output voltage is 1 LSB less than the full-scale reference voltage.

Unipolar Mode D/A Formula

Output value = (Output voltage) / (Full-scale voltage) * 4096

Example:
Desired output voltage = 2.168V, full-scale voltage = 5V, unipolar mode (0-5V)
Output code = 2.168V / 5V * 4096 = 1776

Bipolar Mode D/A Formula

Output value = (Output voltage) / (Full-scale voltage) * 2048 + 2048

Example:
Desired output voltage = -2.168V, full-scale voltage = 5V, bipolar mode (±5V)
Output code = -2.168V / 5V * 2048 + 2048 = 1160

Compute the LSB and MSB Values

Use the following formulas to compute the LSB and MSB values.

LSB = (D/A Code) AND 255. Keep only the low 8 bits

MSB = int((D/A code) / 256). Strip off low 8 bits, keep 4 high bits

Example:
Output code = 1776
LSB = 1776 AND 255 = 240 (F0 Hex)
MSB = int(1776 / 256) = int(6.9375) = 6
(In other words, 1776 = 6*256 + 240)

Add the Channel Number to the MSB

The channel number is 0-3 and must be inserted in bits 7-6 of the D/A MSB byte, written to Base+5.

Example:
MSB = MSB + Channel * 64

Set D/A Simultaneous Update Bit

To update the DAC, set DASIM bit to 0. This performs an update of the current channel and all previously latched channels, causing a simultaneous update. If no other channels were previously latched, this only updates the current channel. To latch the channel set DASIM bit to 1.

Update example:
MSB = MSB & 0xDF
Latch example:
MSB = MSB + 32

Write the LSB and MSB to the Board

The LSB is written to Base+4 and the MSB/channel no. is written to Base+5. If you are using enhanced features be sure to enable enhanced features before writing to the registers.

Monitor the DACBUSY Status Bit

DACBUSY = 1 for 10mS while the data in registers Base+4 and Base+5 are serially shifted into the D/A chip. After DACBUSY returns to 0 you can write to register Base+4 and Base+5. Registers Base+4 and Base+5 should NOT be written to while DACBUSY = 1. When updating multiple channels for simultaneous update repeat steps 1 to 6, as shown in the following example.

Example:
  1. Compute D/A code.

  2. Using the bipolar mode formula, we compute D/A code = 3V / 5V * 2048 + 2048 = 3276.8.
    Round this up to 3277. (Binary value = 1100 1100 1101)
  3. Compute LSB and MSB.

  4. LSB = 3277 & 255 = 205 (Binary value = 1100 1101)
    MSB = int(3277/256) = 12 (Binary value = 1100)
  5. Add channel number to MSB.

  6. MSB = 12 + 1 * 64 = 76
  7. Check DASIM. For non-simultaneous update DASIM = 0, for latching DASIM = 1.

  8. To update: MSB = MSB & 0xDF
    To latch: MSB = MSB + 32
  9. Write LSB and MSB to board, enable enhanced features if using latching.

  10. outp(Base + 8, 3); //select page 3

    outp(Base + 15, 0xA6); //enable enhanced features

    outp(Base + 4, LSB);

    outp(Base + 5, MSB);

  11. Monitor DACBUSY bit, Base + 4 bit 7.

while (inp(Base + 4) & 0x80);