To
interface your own acquisition software directly with our USB2 interface,
your acquisition software should make the function calls described
below. The USB2 driver functions are in the library file called
"RingBuffer.dll". (this library file is included with
ActiView). The functions used in the USB2 handshake are:
HANDLE
OPEN_DRIVER_ASYNC(void);
BOOL USB_WRITE(HANDLE hdevice, PCHAR data);
BOOL READ_MULTIPLE_SWEEPS(HANDLE hdevice,PCHAR data,DWORD nBytesToRead);
BOOL READ_POINTER(HANDLE hdevice,PDWORD pointer);
BOOL CLOSE_DRIVER_ASYNC(HANDLE hdevice);
|
Step
1: |
"Initializing
the USB2 interface" |
Call
function OPEN_DRIVER_ASYNC, the output provides a "handle"
parameter, used as an input for further function calls. |
|
|
Step
2: |
"Start
the acquisition with initializing the USB2 interface" |
Call
USB_WRITE, inputs are "handle" (from step 1) and "data",
use an array of 64 zero bytes for the "data" input. |
|
|
Step
3: |
"Initialize
the ringbuffer" |
Call
READ_MULTIPLE_SWEEPS, inputs are "handle" (from
step 1), "data" and "nBytes to read".
Use an initialized buffer of 32 Mbyte (recommended size) as
input for "data" (this is the ringbuffer), and use the buffersize as input for "nBytes to read" (33554432
= 2^25). |
Everything
is now set to start with the acquisition, and the only thing to
do is to enable the handshake.
Step
4: |
"Enable
the handshake" |
Call
again USB_WRITE, inputs are "handle" (from step
1) and "data", this time use an array of 1 byte
of 255 (FF) followed by 63 zero bytes for the "data" input. |
At this moment the handshake with the USB2 interface starts (green
"USB link" LED on receiver switches on), and the ringbuffer
is filled with incoming data from the ActiveTwo. Your acquisition
program should read the proper data for the ringbuffer.
Step
5: |
"generate
a file pointer" |
Call
READ_POINTER to generate a file pointer. Inputs are "handle"
(from step 1), and "pointer (0). Output is a "pointer".
Use this parameter as a file pointer. In our ActiVIEW software,
we have two counters running continuously: one counter tracks
the total of the buffered words, the other counts the total
of words displayed on screen (or written to file). Every time
the difference in the counters exceeds a set amount of words,
this amount of words is displayed on screen or written to
file. The difference between the two counters is the "backlog"
value, as soon as it exceeds the total ringbuffer size, an
overflow error is generated and the program stops. |
To
stop the acquisition you will have to disable the handshake.
Step
6: |
"Disable
the handshake" |
Call
USB_WRITE, inputs are "handle" (from step 1) and
"data", use an array of 64 zero bytes for the "data"
input. |
Finally,
the interface drivers should be closed:
Step
7: |
"Close
the drivers" |
Call
CLOSE_DRIVER_ASYNC, input is "handle" (from step
1). |
If
all goes OK, you will receive the following data format from the
ActiveTwo:
Most
of the currently shipped ActiveTwo systems are of the Mk2 version.
This recent version has the option for 24 extra channels, and consequently
a higher data throughput is used. Please refer to the table below,
and also check http://www.biosemi.com/faq/adjust_samplerate.htm:
The
ActiveTwo sends the following number of 32-bit words per sample:
Mk1:
Speedmode 0 and 4: 258
Speedmode 1 and 5: 130
Speedmode 2 and 6: 66
Speedmode 3 and 7: 34
Speedmode 8: 290 (2+256+32) |
Mk2:
Speedmode 0, 1, 2 and 3: 610 (2+4*152)
Speedmode 4: 282
Speedmode 5: 154
Speedmode 6: 90
Speedmode 7: 58
Speedmode 8: 314 (2+280+32) |
Like
current ActiView, your software can be made to recognize whether
a Mk1 or Mk 2 is connected by checking bit 23 (MSB) of the trigger/status
channel (channel 2), see http://www.biosemi.com/faq/trigger_signals.htm
The
receiver converts every 24-bit word from the AD-box into a 32-bit
Signed Integer, by adding an extra zero Least Significant Byte to
the ADC data. The 24-bit ADC output has an LSB value of 1/32th uV.
The 32-bit Integer received for the USB interface has an LSB value
of 1/32*1/256 = 1/8192th uV
Two extra channels
are leading the ADC data: before: channel 1 = sync (check for FFFFFF00)
and channel 2 = Status (see
http://www.biosemi.com/faq/trigger_signals.htm), channels 3-258
are ADCs 1-256.
|