3.1 - Command/Response [U6 Datasheet]
Everything besides streaming is accomplished in command/response mode (CR), meaning that all communication is initiated by a command from the host which is followed by a response from the U6. The low-level Feedback function is the primary UD function used in CR activities and is limited to 64-bytes per data packet (command and response). CR commands requiring more than 64 bytes will result in multiple CR packets between the host and the U6. Table 3.1.1 lists typical measured execution times for various tasks (no analog IO), using CR mode, assuming a single CR data exchange (< 64 bytes).
USB high-high [ms] | USB other [ms] | |
---|---|---|
No I/O | 0.60 | 4.00 |
Read All DI | 0.68 | 4.08 |
Write All DO | 0.68 | 4.08 |
Write Both DACs | 0.72 | 4.12 |
Testing Procedure and Definitions:
The times in table 3.1.1 were measured using the example program “allio.c” (VC6_LJUD)
or similar (Firmware 1.43, LJUD 3.45). The program executes a loop 1000 times and divides the
total time by 1000. The resulting round-trip communication time includes Windows latency, UD
driver overhead, communication time, and U6 processing time.
A "USB high-high" configuration applies to setups where the U6 is connected to a
high-speed USB2 hub which is then connected to a high-speed USB2 host. The U6 is not a high-speed USB device. However, placing a high-speed
USB2 hub between the U6 and host will improve communication performance.
A "USB other" configuration applies to setups where the U6 is connected directly to the USB host (your PC) or if the U6 is connected to an old full-speed hub (hard to find). Connecting the U6 directly to a high-speed USB2 port on your PC does not constitute a "USB high-high" connection. Performance times shown in the "USB Other" column apply to all direct connections between the U6 and host.
Preemptive Operating Systems and Thread Priority
It is important to understand that Linux, Mac, and Windows are generally "best-effort" operating systems and not "real-time", meaning that the listed CR speeds can vary based on each individual computer, the hardware inside of it, its currently enabled peripherals, current network traffic, design of the application software, other running software, and many more variables.
ADC Conversions
Analog to digital conversions (ADC) will increase the command response time depending on the number of channels, input gain, and resolution index being used. Table 3.1.2 lists the conversion times for the U6 at various gains and resolution index settings, reading a single analog input channel. The total command response time (CRT) when reading analog inputs is equal to the overhead time from tables 3.1.1 added to the conversion times from Table 3.1.2 (per channel being read) . Please review table 3.1.1 and 3.1.2 carefully, as the listed times will determine the maximum sampling rate achievable when reading analog inputs in command response mode.
CRT (milliseconds) = overhead + (#AINs * AIN Sample Time)
Estimating Command/Response Times
The following examples demonstrate how to estimate the CRT for single and multiple command/response data sets.
Example 1 - Read four analog inputs at G=x100 and Res=1 with a "USB Other" connection:
The expected overhead for a "USB Other" configuration is 4.0 ms (Table 3.1.1) and the sampling time at the specified gain and resolution is 1.04ms (Table 3.1.2). The CRT is then:
CRT = 4.0ms + (4 x 1.04ms) = 8.16ms
Example 2 - Read four analog inputs at G=x100 and Res=1 and set both DACs with a "USB Other" connection:
The given configuration is the same as Example 1 with the additional writes to the two DACs. Table 3.1.1 lists the DAC read as 4.12 ms which includes all overhead. The CRT is:
CRT = 4.12ms + (4 x 1.04ms) = 8.28ms
Example 3 - Read 16 analog inputs at G=x100 and Res=1 with a "USB high-high" connection:
The overhead and analog sample time for the given configuration is 0.60ms and 1.04 ms, respectively. Unlike the previous examples, reading 16 analog channels requires multiple CR data exchanges. The Feedback function can transmit/receive up to 64 bytes for a command and response packet. Handshaking data accounts for a small portion of the data packet and thus command packets are limited to 57 bytes and response packets to 55 bytes for data (see the low level documentation). Analog reads use the AIN24 low-level IO type which requires 4 command bytes and 3 response bytes (see AIN24). With this in mind, the maximum number of analog reads that will fit into a single CR command packet is 14, limited by command bytes (14 x 4 < 57). The resulting CR transmissions will therefore consist of two separate transmissions: one 14 channel read followed by a two channel read. The CRT is calculated as:
CRT = {0.60ms + (14 x 1.04ms)} + {0.60 + (2 x 1.04ms)} = 17.3ms
Note:
Various software issues need consideration when implementing a feedback loop that executes at the desired time interval. Some considerations are: thread priority, logging to file, updating the screen, and other programs running on the machine.