NI USB-6501

General

About the device

The NI USB-6501 is a USB digital IO module with 24 TTL IO lines group into 3 ports (P0-P2).

All IO lines can be configured as either input or output individually. Additionally, P2.7 can be used as a counter triggered by high-to-low transitions.

Pin assignment

Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Signal GND +5V P1.7 P1.6 P1.5 P1.4 GND GND P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
Pin 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Signal P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 GND GND P1.0 P1.1 P1.2 P1.3 +5V GND

USB message sequence

The following sequence of USB bulk transfer messages is used to communicate with the device:

r/w register content
OUT request
IN response

USB end points

register USB end point
IN 0x81
OUT 0x01

Packet format

All packets consist of several 4 byte words. Values longer than 1 byte are in big endian byte order.

Both request and response packets have the same basic structure:

Word #0

0 1 2 3
00 01 00 <PL>

PL
packet length incl. header in bytes

Word #1

0 1 2 3
00 <DL> 01 <CMD>

DL
data length in bytes (= packet length - 4)
CMD
command

Additional words

Additional words are dependent on the command.

Error behaviour

If the device receives an invalid packet, it will not respond and has to be reset by disconnecting it from the USB bus.

Commands

In the request packets below, both first and second word are omitted, as they can be derived from the packet length and command. In the response packets, only the first word is omitted.

0x09 — Start counter

Request:
0 1 2 3
02 20 00 00

Response:
0 1 2 3 4 5 6 7
00 08 01 00 00 00 00 02

0x0C — Stop counter

Request:
0 1 2 3
02 20 00 00

Response:
0 1 2 3 4 5 6 7
00 08 01 00 00 00 00 02

0x0E — Read port

Request:
0 1 2 3 4 5 6 7
02 10 00 00 00 03 <PORT> 00

PORT
number of the port

Response:
0 1 2 3 4 5 6 7 8 9 10 11
00 0C 01 00 00 00 00 02 00 03 <BMAP> 00

BMAP
bit map

0x0E — Read counter

Request:
0 1 2 3
02 20 00 00

Response:
0 1 2 3 4 5 6 7 8 9 10 11
00 0C 01 00 00 00 00 02 <CNT>

CNT
value of the counter

0x0F — Write port

Request:
0 1 2 3 4 5 6 7 8 9 10 11
02 10 00 00 00 03 <PORT> 00 03 <BMAP> 00 00

PORT
number of the port
BMAP
bit map

Response:
0 1 2 3 4 5 6 7
00 08 01 00 00 00 00 02

0x0F — Write counter

Request:
0 1 2 3 4 5 6 7
02 20 00 00 <CNT>

CNT
value of the counter

Response:
0 1 2 3 4 5 6 7
00 08 01 00 00 00 00 02

0x12 — Set in/out mode

Request:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
02 10 00 00 00 05 <M0> <M1> <M2> 00 05 00 00 00 00 00

M0-M2
mask for the port 0-2 (0 = input, 1 = output)

Response:
0 1 2 3 4 5 6 7
00 08 01 00 00 00 00 02

Demo program

A library (niusb6501.c and niusb6501.h) and a demo program in C (demo.c) is included, with examples for using the digital input/ouput and the counter functionality.

To compile it, type make. You need to have libusb (and headers) installed. Also, ensure your user is allowed to write to the files in /dev/bus/usb.

Disclaimer

As National Instruments decided not to make the protocol specification for this device available, I had to work it out myself by installing the Labview driver in Windows and looking at the communication with a USB sniffer. The sniffer logs are included in the directory usb-logs without any further documentation for the sake of completeness.

I still don't understand many details of the protocol, although what I do know is enough to use it for most purposes. I'm publishing this documentation in the hope that it is useful for others. In no way should it be regarded as complete or without errors. Use it on your own risk.

Contact

For questions and comments contact:

Marc Schütz <schuetzm@gmx.net>