daqsys

Description Properties Methods Constants Examples See also






Description


The daqsys object controls National Instruments or DigiData data acquisition cards, and can be used to simultaneously read and write.



Properties


t = boardtype;
boardtype = t;



Currently, daqsys works only with National Instruments boards.

n = idevicename;
idevicename = n;



Make sure idevicename matches the name of your input device, as set in the NI Measurement and Automation Explorer.
The default value is Dev1.
Note that you can probably use different devices for input and output but all input channels must be on the same device; likewise for output.
Note that I haven't tested yet this configuration.

n = digitalidevicename;
digitalidevicename = n;




n = odevicename;
odevicename = n;



Make sure odevicename matches the name of your output device, as set in the NI Measurement and Automation Explorer.
The default value is Dev1.
Note that you can use different devices for input and output but all output channels must be on the same device; likewise for input.
Note that I haven't tested yet this configuration.

n = digitalodevicename;
digitalodevicename = n;




s = iscaling;
iscaling = s;



Use iscaling to set the hardware scaling factor of input channels.
The default is 20.0 / 65536, corresponding to a 16 bit card with a +/- 10 V input range.
For example, if you know the card has 12 bit and +/- 5 V range, set the scaling to 10.0 / 4096, where 4096 = 2^12.

s = oscaling;
oscaling = s;



Use oscaling to set the hardware scaling factor of output channels.
The default is 65536 / 20.0, corresponding to a 16 bit card with a +/- 10 V output range.
For example, if you know the card has 12 bit and +/- 5 V range, set the scaling to 4096 / 10.0, where 4096 = 2^12.

c = inputcount;


inputcount is equal to the number of channels set for input.

c = digitalinputcount;


digitalinputcount is equal to the number of channels set for digital input.

c = outputcount;


outputcount is equal to the number of channels set for output.

c = digitaloutputcount;


digitaloutputcount is equal to the number of channels set for digital output.

s = buffersize;


buffersize is equal to the size of the I/O buffers prepared for acquisition with setbuffer.

p = bufferposition;


This function returns the position in the buffer of the last converted sample.

d = ibufferdata(channel, point);
ibufferdata(channel, point) = d;




d = digitalibufferdata(channel, point);
digitalibufferdata(channel, point) = d;




d = obufferdata(channel, point);
obufferdata(channel, point) = d;




d = digitalobufferdata(channel, point);
digitalobufferdata(channel, point) = d;




s = opbuffersize(buffer);
opbuffersize(buffer) = s;



Read or set the size of the operation buffer.

c = continuous;
continuous = c;




r = isrunning;



r = isstopped;





Methods


setinput(name = n, channel = c, scale = s, offset = o);


setinput adds an input channel to be used for reading operations.


setdigitalinput(name = n, port = p, line = l);


setdigitalinput adds a digital input channel to be used for reading operations.


setoutput(name = n, channel = c, scale = s, offset = o);


setoutput adds an output channel to be used for writing operations.


setdigitaloutput(name = n, port = p, line = l);


setdigitaloutput adds a digital output channel to be used for writing operations.


clearinput;


clearinput removes all channels previously set for input.

cleardigitalinput;


cleardigitalinput removes all channels previously set for digital input.

clearoutput;


clearoutput removes all channels previously set for output.

cleardigitaloutput;


cleardigitaloutput removes all channels previously set for digital output.

setbuffer(size);


After setting up the input, digitalinput, output and digitaloutput channels, use setbuffer to allocate the buffers to be used for reading and writing.
Once the buffers are allocated, the buffer values can be set on a point-by-point basis (ibufferdata, digitalibufferdata, obufferdata, and digitalobufferdata), or using data fill (ibufferfill, digitalibufferfill, obufferfill, and digitalobufferfill), or data tranfer methods (e.g., ibufferload, digitalibufferload, obufferload, and digitalobufferload).

ibufferfill(channel = c, first = f, last = l, value = v);


ibufferfill fills one channel in the input buffer with a value, between the first and the last points.

digitalibufferfill(channel = c, first = f, last = l, value = v);


digitalibufferfill fills one channel in the digital input buffer with a value, between the first and the last points.

obufferfill(channel = c, first = f, last = l, value = v);


obufferfill fills one channel in the output buffer with a value, between the first and the last points.

digitalobufferfill(channel = c, first = f, last = l, value = v);


digitalobufferfill fills one channel in the digital output buffer with a value, between the first and the last points.

ibuffersave(channel = c, filename = n, first = f, last = l, format = fmt);


Use ibuffersave to save to disk the content of the input buffer, from the first to the last point. If these arguments are not specified, then the entire buffer is saved.
If channel is not specified, then all input channels are saved.
The format should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

digitalibuffersave(channel = c, filename = n, first = f, last = l, format = fmt);


Use digitalibuffersave to save to disk the content of the digital input buffer, from the first to the last point. If these arguments are not specified, then the entire buffer is saved.
If channel is not specified, then all digital input channels are saved.
The format should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

ibufferload(channel = c, filename = n, first = f, last = l, format = fmt);


Use ibufferload to load data from a file into the input buffer, from the first to the last point. If these arguments are not specified, then the buffer will be filled starting with the first (zero index) point.
Also, when last is missing, the entire file will be loaded in the buffer. If necessary, the buffer will be resized.
If channel is not specified, then the file is assumed to contain the same number of channels as the daqsys object. Otherwise, the file is assumed to contain only one channel.
The format of the file should be binary, 16-bit integer (DAQ_BUFFER_INT2) or single precision float (DAQ_BUFFER_SINGLE).

digitalibufferload(channel = c, filename = n, first = f, last = l, format = fmt);


Use digitalibufferload to load data from a file into the digital input buffer, from the first to the last point. If these arguments are not specified, then the buffer will be filled starting with the first (zero index) point.
Also, when last is missing, the entire file will be loaded in the buffer. If necessary, the buffer will be resized.
If channel is not specified, then the file is assumed to contain the same number of channels as the daqsys object. Otherwise, the file is assumed to contain only one channel.
The format of the file should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

obuffersave(channel = c, filename = n, first = f, last = l, format = fmt);


Use obuffersave to save to disk the content of the output buffer, from the first to the last point. If these arguments are not specified, then the entire buffer is saved.
If channel is not specified, then all output channels are saved.
The format should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

digitalobuffersave(channel = c, filename = n, first = f, last = l, format = fmt);


Use digitalobuffersave to save to disk the content of the digital output buffer, from the first to the last point. If these arguments are not specified, then the entire buffer is saved.
If channel is not specified, then all digital output channels are saved.
The format should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

obufferload(channel = c, filename = n, first = f, last = l, format = fmt);


Use obufferload to load data from a file into the output buffer, from the first to the last point. If these arguments are not specified, then the buffer will be filled starting with the first (zero index) point.
Also, when last is missing, the entire file will be loaded in the buffer. If necessary, the buffer will be resized.
If channel is not specified, then the file is assumed to contain the same number of channels as the daqsys object. Otherwise, the file is assumed to contain only one channel.
The format of the file should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

digitalobufferload(channel = c, filename = n, first = f, last = l, format = fmt);


Use digitalobufferload to load data from a file into the digital output buffer, from the first to the last point. If these arguments are not specified, then the buffer will be filled starting with the first (zero index) point.
Also, when last is missing, the entire file will be loaded in the buffer. If necessary, the buffer will be resized.
If channel is not specified, then the file is assumed to contain the same number of channels as the daqsys object. Otherwise, the file is assumed to contain only one channel.
The format of the file should be binary, 16-bit integer (DAQ_BUFFER_INT2), 32-bit integer (DAQ_BUFFER_INT4), or single precision float (DAQ_BUFFER_SINGLE).

ibuffercopytodata(bufferfirst = f, bufferlast = l, data = d, newsegment = s);


Use ibuffercopytodata to append the data contained in the input buffer to a qub file.
If bufferfirst and bufferlast are not specified, the entire buffer will be appended.
The qub data file and the buffer must have the same number of channels and the same data type.

digitalibuffercopytodata(bufferfirst = f, bufferlast = l, data = d, newsegment = s);


Use digitalibuffercopytodata to append the data contained in the digital input buffer to a qub file.
If bufferfirst and bufferlast are not specified, the entire buffer will be appended.
The qub data file and the buffer must have the same number of channels and the same data type.

ibuffercopyfromdata(bufferfirst = f, data = d, datafirst = df, datalast = dl);


Transfers raw (unfiltered, etc) data between a qub file and the input buffer. If necessary, the buffer is resized.
The qub data file and the buffer must have the same number of channels and the same data type.

digitalibuffercopyfromdata(bufferfirst = f, data = d, datafirst = df, datalast = dl);


Transfers raw (unfiltered, etc) data between a qub file and the digital input buffer. If necessary, the buffer is resized.
The qub data file and the buffer must have the same number of channels and the same data type.

obuffercopytodata(bufferfirst = f, bufferlast = l, data = d, newsegment = s);


Use obuffercopytodata to append the data contained in the output buffer to a qub file.
If bufferfirst and bufferlast are not specified, the entire buffer will be appended.
The qub data file and the buffer must have the same number of channels and the same data type.

digitalobuffercopytodata(bufferfirst = f, bufferlast = l, data = d, newsegment = s);


Use digitalobuffercopytodata to append the data contained in the digital output buffer to a qub file.
If bufferfirst and bufferlast are not specified, the entire buffer will be appended.
The qub data file and the buffer must have the same number of channels and the same data type.

obuffercopyfromdata(bufferfirst = f, data = d, datafirst = df, datalast = dl);


Transfers raw (unfiltered, etc) data between a qub file and the output buffer. If necessary, the buffer is resized.
The qub data file and the buffer must have the same number of channels and the same data type.

digitalobuffercopyfromdata(bufferfirst = f, data = d, datafirst = df, datalast = dl);


Transfers raw (unfiltered, etc) data between a qub file and the output buffer. If necessary, the buffer is resized.
The qub data file and the buffer must have the same number of channels and the same data type.

a = bufferavg(buffertype = t, channel = c, first = f, last = l);


bufferavg calculates the average between the first and the last points, for a channel in the buffer.

s = bufferstd(buffertype = t, channel = c, first = f, last = l, avg = a);


bufferstd calculates the standard deviation between the first and the last points, for a channel in the buffer.

m = buffermin(buffertype = t, channel = c, first = f, last = l);


buffermin finds the minimum between the first and the last points, for a channel in the buffer.

a = buffermax(buffertype = t, channel = c, first = f, last = l);


buffermax finds the maximum between the first and the last points, for a channel in the buffer.

i = bufferminidx(buffertype = t, channel = c, first = f, last = l);


bufferminidx finds the index of the minimum between the first and the last points, for a channel in the buffer.

a = buffermaxidx(buffertype = t, channel = c, first = f, last = l);


buffermaxidx finds the index of the maximum between the first and the last points, for a channel in the buffer.

buffertoopbuffer(buffertype = t, channel = c, first = f, last = l, opbuffer = b, opfirst = of, opmode = m);


buffertoopbuffer transfers the content of the buffer into an operation buffer.

opbuffertobuffer(opbuffer = b, opfirst = of, oplast = ol, buffertype = t, channel = c, first = f, opmode = m);


opbuffertobuffer transfers the content of an operation buffer into the buffer.

opbufferscaleoffset(buffer = b, first = f, last = l, scale = s, offset = o);


opbufferscaleoffset multiplies, on a point-by-point basis, the content of the opbuffer with a scaling factor and then adds an offset.

opbufferfill(buffer = b, first = f, last = l, value = v);


opbufferfill fills the content of an opbuffer with a value, between the first and the last points.

a = opbufferavg(buffer = b, first = f, last = l);


opbufferavg calculates the average of an opbuffer, between the first and the last points.

s = opbufferstd(buffer = b, first = f, last = l, avg = a);


opbufferstd calculates the standard deviation of an opbuffer, between the first and the last points.

m = opbuffermin(buffer = b, first = f, last = l);


opbuffermin finds the minimum of an opbuffer, between the first and the last points.

m = opbuffermax(buffer = b, first = f, last = l);


opbuffermax finds the maximum of an opbuffer, between the first and the last points.

i = opbufferminidx(buffer = b, first = f, last = l);


opbufferminidx finds the index of the minimum of an opbuffer, between the first and the last points.

i = opbuffermaxidx(buffer = b, first = f, last = l);


opbuffermaxidx finds the index of the maximum of an opbuffer, between the first and the last points.

start(rate = r, first = f, last = l, mode = m);


After setting up the input, digital input, output, and digital output channels, and the buffer, use start to initiate acquisition.
The rate is in Hz. The reading and writing use the buffer from the first to the last points; if not specified, the entire buffer is used.
The mode argument is either DAQ_MODE_RUN, or DAQ_MODE_PREPARE; in the latter case the acquisition is prepared but no read/write operation occurs.
Subsequent calls to start should use the DAQ_MODE_RUN mode (default) to read/write (different sections of) the buffer.
Acquisition should be stopped with a call to stop; acquisition stops automatically when the script where the daqsys object is declared terminates.
When (digital) input and (digital) output channels are set, the read and write operations will be synchronized. However, the delay between the read and write operations should be tested, to determine the exact timing. Generally, reading may be one sample behind writing.

stop(abort);


Use stop to terminate acquisition. If an acquisition operation is in progress and abort is true, it will be immediately terminated.

readsample(count);


Use readsample to read one ore more samples. If no argument is given, only one sample is read.



Constants




Examples


The following example shows how to set up acquisition for a simple voltage clamp protocol:

//Declare the daqsys object:
daqsys daq;

//Declare the rate variable:
var dbl Rate = 10000;//in Hz

//Add two input channels, one for current, one for voltage:
daq.setinput(name = "I", channel = 0);
daq.setinput(name = "V", channel = 1);

//Add one output channel for voltage stimulation:
daq.setoutput(name = "V", channel = 0);

//Allocate the buffer
daq.setbuffer(0.1*Rate);//100 ms x 10 kHz = 1000 points

//Set the stimulus:
var int i;
for i = 0 to 0.01*Rate do {
daq.obuffer(0, i) = -60;//Conditioning pulse
};
for i = 0.01*Rate to daq.buffersize - 1 do {
daq.obuffer(0, i) = 10;//Test pulse
};

//Start acquisition:
daq.start(rate = Rate);

//Save the data:
daq.ibuffersave(filename = "testdaq.dat", format = DAQ_BUFFER_SINGLE);



See also





(C) 2008-2010 Lorin Milescu. Last modified: 08-29-2010