![Diamond Systems Poseidon User Manual Download Page 82](http://html1.mh-extra.com/html/diamond-systems/poseidon/poseidon_user-manual_2494418082.webp)
resets to the low channel and starts over again. This behavior enables you simplify your software by setting the
channel range just once.
To read continuously from a single channel, write the same channel number to both the low channel and high
channel registers.
To read from a series of consecutively numbered channels, write the starting channel to Base+2 and the ending
channel to Base+3.
To read from a group of non-consecutive channels, you must treat each as a single channel, as described above.
Select the Input Range
Select the code corresponding to the desired input range and write it to the analog I/O control register at Base+11.
You only need to write to this register if you want to select a different input range from the one used for the previous
conversion. If all channels will be using the same input range, you can configure this register just once at the
beginning of your procedure.
You can read the current value of this register by reading from Base+11.
Wait for Analog Input Circuit to Settle
After changing either the input channel or the input range, you must allow the circuit to settle on the new value
before performing an A/D conversion. The settling time is long compared to software execution times, so a timer is
provided on board to indicate when it is safe to proceed with A/D sampling. The WAIT bit at Base+11 indicates
when the circuit is settling and when it is safe to sample the input. When WAIT is 1, the board is settling. When
WAIT is 0, the board is ready for an A/D conversion.
Perform an A/D Conversion on the Current Channel
To generate an A/D conversion, simply write to Base+0 to start the conversion. Any value may be written to the
register.
Wait for the Conversion to Finish
The A/D converter takes about four microseconds to complete a conversion. If you try to read the A/D converter
data immediately after starting a conversion, you will get invalid data. Therefore, the A/D converter provides a
status signal to indicate whether it is busy or idle. This signal can be read back as the STS bit in the status register at
Base+8. When the A/D converter is busy (performing an A/D conversion) this bit is 1. When the A/D converter is
idle (conversion is done and data is available) this bit is 0.
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 at Base+0 and Base+1. The low byte must be read first.
Note: Reading data from an empty FIFO returns unpredictable results.
The following pseudo-code illustrates how to read and construct the 16-bit A/D value with 8-bit accesses:
LSB = inp(base);
MSB = inp(base+1);
Data = MSB * 256 + LSB; // combine the 2 bytes into a 16-bit value
Alternatively, the value can be read as one 16-bit value, which is preferred since this method increases overall
system bandwidth while reading data from the FIFO. For example,
Diamond Systems Corporation
Poseidon User Manual
Page 82