USB-AI16-16A Sample Program Release Notes

Table of Contents

Overview

Sample.cpp is a simple program to demonstrate using the AIOUSB module to control an ACCES I/O model USB-AI16-16A analog input board. The program is not intended to be a comprehensive demonstration and is limited to demonstrating the following features of the AIOUSB API:

For easy identification, the source code lines prefixed with the comment /*API*/ denote calls to the AIOUSB API.

Building

Before building the program, make sure the libusb module is installed. Also refer to the comments at the top of sample.cpp for additional details.

Also, make sure that the ACCES I/O AIOUSB module is installed (see Installing And Using AIOUSB Library).

The simplest way to build the sample program is to type make at the command line. The sample program is the default target in Makefile. Optionally, one can manually compile the program with the command:

g++ sample.cpp -laiousb -lusb-1.0 -o sample

Executing

Before executing the sample program, make sure the Linux system is configured to automatically detect ACCES I/O devices plugged into the USB bus and upload the appropriate firmware to those devices. The files that support this automatic configuration have recently been updated and new documentation prepared. Please refer to Configuring ACCES I/O USB Devices To Work Under Linux for details.

To execute the program, attach a USB-AI16-16A analog input board to the USB bus and verify that its LED turns on, indicating that firmware has been successfully uploaded to the board. Then simply type ./sample at the command line. There are no command line arguments to worry about. The program will search for the first USB-AI16-16A analog input board on the USB bus. If it fails to find such a board, it will print an error message and quit. If it finds such a board, the following output will appear:

USB-AI16-16A sample program $Revision: 1.18 $ $Date: 2009/10/23 20:58:15 $
  (AIOUSB library $Revision: 1.68 $ $Date: 2009/10/23 17:32:03 $)
  This program demonstrates controlling a USB-AI16-16A device on
  the USB bus. For simplicity, it uses the first such device found
  on the bus.
ACCES devices found:
  Device at index 0:
    Product ID: 0x8040
    Product name: USB-AI16-16A (12 characters)
    Number of digital I/O bytes: 2
    Number of counters: 1
Serial number of device at index 0: 40e38f15d5c94894
A/D settings successfully configured
Automatic calibration completed successfully
Ground counts = 0 (should be approx. 0)
Reference counts = 65101 (should be approx. 65102)
Volts read:
  Channel  0 = 0.006104
  Channel  1 = 0.135958
  Channel  2 = 0.113832
  Channel  3 = 0.123598
  Channel  4 = 0.200809
  Channel  5 = 0.112612
  Channel  6 = 0.204623
  Channel  7 = 0.145266
  Channel  8 = 0.108339
  Channel  9 = 0.108644
  Channel 10 = 0.108339
  Channel 11 = 0.051575
  Channel 12 = 0.130922
  Channel 13 = 0.096132
  Channel 14 = 0.087892
  Channel 15 = 0.083314
Volts read from A/D channel 5 = 0.105898
Started bulk acquire of 35200000 bytes
  34237440 bytes remaining
  33254400 bytes remaining
  32271360 bytes remaining
  31308800 bytes remaining
  30325760 bytes remaining
  29342720 bytes remaining
  28359680 bytes remaining
  27397120 bytes remaining
  26414080 bytes remaining
  25431040 bytes remaining
  24448000 bytes remaining
  23485440 bytes remaining
  22502400 bytes remaining
  21519360 bytes remaining
  20536320 bytes remaining
  19573760 bytes remaining
  18590720 bytes remaining
  17607680 bytes remaining
  16624640 bytes remaining
  15662080 bytes remaining
  14679040 bytes remaining
  13696000 bytes remaining
  12712960 bytes remaining
  11750400 bytes remaining
  10767360 bytes remaining
  9784320 bytes remaining
  8801280 bytes remaining
  7838720 bytes remaining
  6855680 bytes remaining
  5872640 bytes remaining
  4889600 bytes remaining
  3927040 bytes remaining
  2944000 bytes remaining
  1960960 bytes remaining
  977920 bytes remaining
  0 bytes remaining
Successfully bulk acquired 35200000 bytes

The sample program prints out a list of all the ACCES devices found on the USB bus and then proceeds to exercise the first USB-AI16-16A board found.