
DMM-16R-AT User Manual V1.31
www.diamondsystems.com
Page 29
8.4 Trigger and A/D conversion
After the above steps are completed, start the A/D conversion by writing to Base + 0. This write operation only
triggers the A/D if the CLKEN bit is 0 to disable hardware triggering and enable software triggering. Otherwise
the A/D will only trigger when the selected clock or trigger signal occurs. CLKEN should always be 0 when
controlling A/D conversions in software.
8.5 Wait for the conversion to finish
The A/D converter takes up to 10 microseconds to complete a conversion. Most processors and software can
operate fast enough so that if you try to read the A/D converter immediately after writing to base + 0, you will
beat the A/D converter and get invalid data. Therefore the A/D converter provides a status signal to indicate
whether it is busy or idle. This bit can be read back as bit 7 in the status register at Base + 8. When the A/D
converter is busy (performing an A/D conversion), this bit is 1, and when the A/D converter is idle (conversion
is done and data is available), this bit is 0. Here is a pseudocode explanation:
Status = read(base+8) AND 128 // or Status = read(base+8) AND 80 Hex
If Status = 0 then conversion is complete, else A/D converter is busy
Keep repeating this procedure until Status = 0.
8.6 Read the data from the board
Once the conversion is complete, you can read the data back from the A/D converter. The data is 16 bits wide
and is read back in two 8-bit bytes. The following pseudocode illustrates how to construct the 16-bit A/D value
from these two bytes:
LSB = read(base)
MSB = read(base+1)
Data = MSB * 256 + LSB // combine the 2 bytes into a 16-bit value
The final data is interpreted as a signed value ranging from
–32768 to +32767.
Note:
The data range always includes both positive and negative values, even if the board is set to a
unipolar input range. The data must now be converted to volts or other engineering units by using a
conversion formula as shown on the next page.