User manual

Chapter 3 Software Overview
NI-DAQ User Manual for PC Compatibles 3-14 ni.com
2. To place the GeneralDAQEvent control into your form, go to the tool
box window and select the GeneralDAQEvent tool, labelled DAQ
EVENT.
3. Click somewhere on the form, and while holding down the mouse
button, drag the mouse to place the control onto the form. You will see
a small icon, which does not appear in run time.
4. To set up a DAQ Event that notifies you after every n scans
(DAQ Event #1), unless you decide to make n very large, you can use
the
Set_DAQ_Device_Info
function to set the device analog
inputs to use interrupts. The constants used in this function
come from
NIDAQCNS.INC
. See the function description for
Set_DAQ_Device_Info
in the NI-DAQ Function Reference Online
Help file for more information. You must also configure some
parameters so that the GeneralDAQEvent can occur when it needs to.
In the
Form_Load
event routine, add the following to the existing
code:
er% = Set_DAQ_Device_Info(1, ND_DATA_XFER_MODE_AI,
ND_INTERRUPTS) set AI to use INTR
GeneralDAQEvent1.Board = 1 ‘assume Device 1
GeneralDAQEvent1.DAQEvent = 1 ‘event every N scans
GeneralDAQEvent1.DAQTrigVal0 = 1000 ‘set N=1000
scans
GeneralDAQEvent1.Enabled = True
5. Next, start an asynchronous operation. Use the NI-DAQ function
DAQ_Start
. Set up your program so it does a
DAQ_Start
on
channel 0 when you click on a button you have placed on your form.
To do so, add the following code in the
Command1_Click()
subroutine as follows:
Redim buffer%(10000)
GeneralDAQEvent1.ChanStr = "AI0"
GeneralDAQEvent1.Refresh ‘refresh to set params
er% = DAQ_Start(1, 0, 1, buffer%(0), 10000, 3, 10)
6. Next, define what to do when the DAQ Event occurs. In this
example, we can easily update a text box upon every 1,000 scans
and also when the whole acquisition is complete. Place a text box
on your form. It is automatically named Text 1.