A flexible function that handles all command/response functionality. One or more IOTypes are used to perform a single write/read or multiple writes/reads.
Note that the general protocol described in "Section 5.1":/support/u6/users-guide/5.1 defines byte 2 of an extended command as the number of data words, which is the number of words in a packet beyond the first 3 (a word is 2 bytes). Also note that the overall size of a packet must be an even number of bytes, so in this case an extra 0x00 is added to the end of the command and/or response if needed to accomplish this.
Since this command has a flexible size, byte 2 will vary. For instance, if a single IOType of PortStateRead (d26) is passed, byte 2 would be equal to 1 for the command and 3 for the response. If a single IOType of LED (d9) is passed, an extra 0 must be added to the command to make the packet have an even number of bytes, and byte 2 would be equal to 2. The response would also need an extra 0 to be even, and byte 2 would be equal to 2.
Command: | |
Byte | |
0 | Checksum8 |
1 | 0xF8 |
2 | 0.5 + Number of Data Words (IOTypes and Data) |
3 | 0x00 |
4 | Checksum16 (LSB) |
5 | Checksum16 (MSB) |
6 | Echo |
7-63 | IOTypes and Data |
Response: | |
Byte | |
0 | Checksum8 |
1 | 0xF8 |
2 | 1.5 + Number of Data Words (IOTypes and Data) |
3 | 0x00 |
4 | Checksum16 (LSB) |
5 | Checksum16 (MSB) |
6 | Errorcode |
7 | ErrorFrame |
8 | Echo |
9-63 | Data |
IOTypes for Feedback Command:
Name | IOType (dec) | WriteBytes | ReadBytes |
AIN | 1 | 3 | 2 |
AIN24 | 2 | 4 | 3 |
AIN24AR | 3 | 4 | 5 |
WaitShort | 5 | 2 | 0 |
WaitLong | 6 | 2 | 0 |
LED | 9 | 2 | 0 |
BitStateRead | 10 | 2 | 1 |
BitStateWrite | 11 | 2 | 0 |
BitDirRead | 12 | 2 | 1 |
BitDirWrite | 13 | 2 | 0 |
PortStateRead | 26 | 1 | 3 |
PortStateWrite | 27 | 7 | 0 |
PortDirRead | 28 | 1 | 3 |
PortDirWrite | 29 | 7 | 0 |
DAC0 (8-bit) | 34 | 2 | 0 |
DAC1 (8-bit) | 35 | 2 | 0 |
DAC0 (16-bit) | 38 | 3 | 0 |
DAC1 (16-bit) | 39 | 3 | 0 |
Timer0 | 42 | 4 | 4 |
Timer0Config | 43 | 4 | 0 |
Timer1 | 44 | 4 | 4 |
Timer1Config | 45 | 4 | 0 |
Timer2 | 46 | 4 | 4 |
Timer2Config | 47 | 4 | 0 |
Timer3 | 48 | 4 | 4 |
Timer3Config | 49 | 4 | 0 |
Counter0 | 54 | 2 | 4 |
Counter1 | 55 | 2 | 4 |
AIN, 3 Command Bytes: | |
0 | IOType=1 |
1 | PositiveChannel |
2 | Reserved |
2 Response Bytes: | |
0 | AIN LSB |
1 | AIN MSB |
This is the U3 style IOType to get a single analog input reading. It is available for compatibility, but to make full use of the U6 the new AIN24 IOType should be used.
Note: Do not call this IO type while streaming.
AIN24, 4 Command Bytes: | |
0 | IOType=2 |
1 | PositiveChannel |
2 | Bits 0-3: ResolutionIndex |
Bits 4-7: GainIndex | |
3 | Bits 0-2: SettlingFactor |
Bit 7: Differential | |
3 Response Bytes: | |
0 | AIN LSB |
1 | AIN Bits 8-15 |
2 | AIN MSB |
This IOType returns a single analog input reading. If using the autorange feature, the AIN24AR IOType in the following Section should be used instead.
Note: Do not call this IO type while streaming.
AIN24AR, 4 Command Bytes: | |
0 | IOType=3 |
1 | PositiveChannel |
2 | Bits 0-3: ResolutionIndex |
Bits 4-7: GainIndex | |
3 | Bits 0-2: SettlingFactor |
Bit 7: Differential | |
5 Response Bytes: | |
0 | AIN LSB |
1 | AIN Bits 8-15 |
2 | AIN MSB |
3 | Bits 0-3: ResolutionIndex |
Bits 4-7: Gain Index | |
4 | Status |
This IOType returns a single analog input reading. Also returns the actual resolution and gain used for the reading.
Note: Do not call this IO type while streaming.
WaitShort, 2 Command Bytes: | |
0 | IOType=5 |
1 | Time (* 64 us) |
0 Response Bytes: | |
This IOType provides a way to add a delay during execution of the Feedback function. The typical use would be putting this IOType in between IOTypes that set a digital output line high and low, thus providing a simple way to create a pulse. Note that this IOType uses the same internal timer as stream mode, so cannot be used while streaming.
Table 5.2.5.5-1. WaitLong Command Response
WaitLong, 2 Command Bytes: | |
0 | IOType=6 |
1 | Time (*16 ms) |
0 Response Bytes: |
This IOType provides a way to add a delay during execution of the Feedback function. The typical use would be putting this IOType in between IOTypes that set a digital output line high and low, thus providing a simple way to create a pulse. Note that this IOType uses the same internal timer as stream mode, so cannot be used while streaming.
Table 5.2.5.6-1. LED Command Response
LED, 2 Command Bytes: | |
0 | IOType = 9 |
1 | State |
0 Response Bytes: |
This IOType simply turns the status LED on or off.
Table 5.2.5.7-1. BitStateRead Command Response
BitStateRead, 2 Command Bytes: | |
0 | IOType = 10 |
1 | Bits 0-4: IONumber |
1 Response Byte: | |
0 | Bit 0: State |
This IOType reads the state of a single bit of digital I/O. Note that CIO0-2 & MIO0-2 are shared, so to write/read MIO0-2 use channel numbers 16-18. Only lines configured as digital (not analog) return valid readings.
Table 5.2.5.6-1. BitStateRead Command Response
BitStateWrite, 2 Command Bytes: | |
0 | IOType = 11 |
1 | Bits 0-4: IO Number |
Bit 7: State | |
0 Response Bytes: |
This IOType writes the state of a single bit of digital I/O. Note that CIO0-2 & MIO0-2 are shared, so to write/read MIO0-2 use channel numbers 16-18. The direction of the specified line is forced to output.
Table 5.2.5.9-1. BitDirRead Command Response
BitDirRead, 2 Command Bytes: | |
0 | IOType = 12 |
1 | Bits 0-4: IO Number |
1 Response Byte: | |
0 | Bit 0: Direction |
This IOType reads the direction of a single bit of digital I/O. Note that CIO0-2 & MIO0-2 are shared, so to write/read MIO0-2 use channel numbers 16-18. This is the digital direction only, and does not provide any information as to whether the line is configured as digital or analog.
Table 5.2.5.10-1. BitDirWrite Command Response
BitDirRead, 2 Command Bytes: | |
0 | IOType = 13 |
1 | Bits 0-4: IO Number |
Bit 7: Direction | |
0 Response Bytes: | |
This IOType writes the direction of a single bit of digital I/O. Note that CIO0-2 & MIO0-2 are shared, so to write/read MIO0-2 use channel numbers 16-18.
Table 5.2.5.11-1. PortStateRead Command Response
PortStateRead, 1 Command Byte: | |
0 | IOType = 26 |
3 Response Bytes: | |
0-2 | State |
This IOType reads the state of all digital I/O, where 0-7=FIO, 8-15=EIO, and 16-19=CIO. Note that CIO0-2 and MIO0-2 are shared, so for reads of MIO0-2 look at 16-18. Only lines configured as digital (not analog) return valid readings.
Table 5.2.5.12-1. PortStateWrite Command Response
PortStateWrite, 7 Command Bytes: | |
0 | IOType = 27 |
1-3 | WriteMask |
4-6 | State |
0 Response Bytes: |
This IOType writes the state of all digital I/O, where 0-7=FIO, 8-15=EIO, and 16-19=CIO. Note that CIO0-2 and MIO0-2 are shared, so for writes to MIO0-2 use channel numbers 16-18. The direction of the selected lines is forced to output.
Table 5.2.5.13-1. PortDirRead Command Response
PortDirRead, 1 Command Byte: | |
0 | IOType = 28 |
3 Response Bytes: | |
0-2 | Direction |
This IOType reads the directions of all digital I/O, where 0-7=FIO, 8-15=EIO, and 16-19=CIO. Note that CIO0-2 and MIO0-2 are shared, so for reads of MIO0-2 look at 16-18. These are the digital directions only, and do not provide any information as to whether the lines are configured as digital or analog.
Table 5.2.5.12-1. PortDirWrite Command Response
PortStateWrite, 7 Command Bytes: | |
0 | IOType = 29 |
1-3 | WriteMask |
4-6 | Direction |
0 Response Bytes: | |
This IOType writes the direction of all digital I/O, where 0-7=FIO, 8-15=EIO, and 16-19=CIO. Note that CIO0-2 and MIO0-2 are shared, so for writes to MIO0-2 use channel numbers 16-18.
Table 5.2.5.15-1. DAC 8-bit Command Response
DAC# (8-bit), 2 Command Bytes: | |
0 | IOType = 34, 35 |
1 | Value |
0 Response Bytes: | |
This IOType will set the value of a single analog output. Use IOType 34 to set DAC0 and 35 to set DAC1. We recommend using the 16-bit IOType when using the U6.
Table 5.2.5.16-1. DAC 16 bit Command Response
DAC# (16-bit), 3 Command Bytes: | |
0 | IOType = 38, 39 |
1 | Value LSB |
2 | Value MSB |
0 Response Bytes: | |
This IOType will set the value of a single analog output. Use IOType 38 to set DAC0 and 39 to set DAC1.
Table 5.2.5.17-1. Timer Command Response
Timer#, 4 Command Bytes: | |
0 | IOType = 42, 44, 46, 48 |
1 | Bit 0: UpdateReset |
2 | Value LSB |
3 | Value MSB |
4 Response Bytes: | |
0 | Timer LSB |
1 | Timer |
2 | Timer |
3 | Timer MSB |
This IOType provides the ability to update/reset a given timer, and read the timer value.
Table 5.2.5.18-1. TimerConfig Command Response
Timer#Config, 4 Command Bytes: | |
0 | IOType = 43, 45, 47, 49 |
1 | TimerMode |
2 | Value LSB |
3 | Value MSB |
0 Response Bytes: | |
This IOType configures a particular timer.
Table 5.2.5.19-1. Counter Command Response
Counter#, 2 Command Bytes: | |
0 | IOType = 54, 55 |
1 | Bit 0: Reset |
4 Response Bytes: | |
0 | Counter LSB |
1 | Counter |
2 | Counter |
3 | Counter MSB |
This IOType reads a hardware counter, and optionally can do a reset.