Chapter 4
Programming
4-14
©
National Instruments Corporation
9.
Call
AI_Arming
to arm the analog input counter.
AI_Command_1_Register
AI SC arm = 1;
AI SI arm = 1;
AI SI2 arm = 1;
AI DIV arm = 1;
10. The function
AI_Start_The_Acquisition
starts the acquisition
process.
AI_Command_2_Register
AI START1 Pulse = 1;
11. Poll the AI FIFO not empty flag in the AI_Status_1_Register until not
empty and read the ADC FIFO data in the ADC_FIFO_Data_Register.
Do
{
If (AI FIFO not empty) then
read FIFO data;
} while (20 samples have not been read)
Example 3
Example 3 performs the same acquisition as Example 2, but with
interrupts.
Acquire 5 scans at a scan interval of 1 ms. The scan list contains channels
5, 4, 1, and 0 respectively. The channels are configured as RSE at a gain of
1. Within each scan, the sample interval should be 100 µs. Dithering should
remain off during the operation. No external multiplexers are used. Use
interrupts to acquire the data.
Only minor modifications to Analog Input Example 2 are needed for this
example. Instead of installing the interrupt service routine (ISR) as an
interrupt, this example emulates the operation of the interrupt by polling the
status register in the DAQ-STC. When the status register indicates an
interrupt, the main loop transfers control to the ISR. To use the example
ISR as an actual interrupt, learn how to install software interrupts on your
system. Generally, the procedure is as follows:
1.
Determine the software interrupt number corresponding to the IRQ
line you are using.
2.
Use the OS specific functions such as
getvect()
and
setvect()
for
DOS to replace the default interrupt handler with your ISR. You should
disable interrupts during this step.
3.
Reset the interrupt controller hardware.