11.HOW TO PERFORM A/D CONVERSIONS USING INTERRUPTS

Diamond-MM-32 contains the ability to generate hardware interrupts to manage A/D conversions. Interrupt-based A/D conversions are used in several situations:

  • High-speed sampling

  • Applications where the sampling rate must be precise

  • Applications where the sampling rate is based on an external clock

The Diamond Systems Universal Driver functions dscADSampleInt() and dscADSetSettings() manage all of the required parameters to generate interrupt-based A/D conversions. Below is a checklist to help you configure the function call properly. All parameters are passed in the data structure of type DSCAIOINT for function dscADSampleInt() except for the input range.

1.A/D channel range (low channel, high channel)

On Diamond-MM-32DX-AT, the channel numbers range from 0 to 31. Some channel numbers may not be available, depending on the single-ended / differential configuration mode as explained on page 11. During interrupt-based A/D conversions, the channels being sampled must be consecutive in number. To sample only a single channel, set the low channel and high channel to the same channel number. To sample a range of channels, set the low and high channels accordingly.

2.Input voltage range

During interrupt-based A/D conversions, the input voltage range must be the same for all channels. Select the input range from the list of codes on page 35. This parameter is set with the function dscADSetSettings() prior to calling dscADSampleInt().

3.A/D Clock source, internal or external

For internal clocking, the on-board 32-bit counter/timer is programmed to the desired sample rate. For external clocking, the signal EXTCLK / DIN3 on I/O header J3 pin 45 controls sampling. Falling edges on this pin will generate A/D conversions. The signal is edge sensitive, so holding it low will generate only one conversion.

4. A/D conversion rate, if using internal clock

If internal clocking is selected, provide the desired sample rate in Hz as a floating value. The maximum sample rate is 250,000 per second (maximum A/D operating speed), and the slowest rate is .000024383Hz (100KHz input / 232), or approximately 1 sample every 42,950 seconds (approximately 11.9 hours).

5. External gating enable

You can choose whether to allow an external signal on J3 pin 46 to control the sampling. If so, then when this signal is high, sampling will occur, and when it is low, sampling will pause. External gating works with both internal and external clocking. This pin is connected to a 4.7K pull-up resistor.

6. One-shot vs. recycle mode

In one-shot mode, the operation occurs one time and then stops, and the parameter num_conversions determines the number of samples taken. In recycle mode, the operation runs repeatedly until you stop the operation with dscCancelOp(). In this case, the parameter num_conversions indicates the size of the memory buffer or array used to store the samples. Once the buffer is filled, the data is stored starting at the beginning again, causing the old data to be overwritten. In this situation, you only have access to the latest number of samples equal to num_conversions, and you must read the data out of the buffer before it is overwritten. The function dscGetStatus() can be used to indicate the current buffer position, which is the location at which the next data value will be stored.

Last updated