
Athena IIII User Manual Rev A.00
www.diamondsystems.com
Page
69
17. GENERATING AN ANALOG OUTPUT
There are three steps involved in performing a D/A conversion, or generating an analog output. Each step is
described in more detail, below. The descriptions use direct programming instead of driver software.
Compute the D/A code for the desired output voltage.
12.
Write the value to the selected output channel.
13.
Wait for the D/A to update.
17.1
Compute the D/A Code for the Desired Output Voltage
Use the formulas in the preceding section to compute the D/A code required to generate the desired voltage.
Note:
The DAC cannot generate the actual full-scale reference voltage; to do so would require an output
code of 4096, which is not possible with a 12-bit number. The maximum output value is 4095. Therefore,
the maximum possible output voltage is always 1 LSB less than the full-scale reference voltage.
17.2
Write the Value to the Selected Output Channel Registers
Use the following formulas to compute the LSB and MSB values.
LSB = D/A Code & 255 ;keep only the low 8 bits
MSB = int(D/A code / 256) ;strip off low 8 bits, keep 4 high bits
Example:
For,
Output code = 1776
Compute,
LSB = 1776 & 255 = 240 (0xF0)
and
MSB = int(1776 / 256) = int(6.9375) = 6
The LSB is an 8-bit number in the range 0-255. The MSB is a 4-bit number in the range 0-15.
The MSB is always rounded down. The truncated portion is accounted for by the LSB.
Write these values to the selected channel. The LSB is written to Base+6. The MSB and channel number are
written to Base+7 (MSB = bits 0-3, channel number,0-3 = bits 6-7).
outp(Base+6, LSB);
outp(Base+7, MSB + channel << 6);
17.3
Wait for the D/A to Update
Writing the MSB and channel number to Base+7 starts the D/A update process for the selected channel. The
update process requires approximately 30 microseconds to transmit the data serially to the D/A chip and update
the D/A circuit in the chip. During this period, no attempt should be made to write to any other channel in the D/A
through addresses Base+6 or Base+7.
The status bit DACBUSY (Base+3, bit 4) indicates if the D/A is busy updating (1) or idle (0). After writing to the
D/A, monitor DACBUSY until it is zero before continuing with the next D/A operation.