labjack - u3 user's guide - 2011-01-06

66
Published on LabJack ( http://labjack.com) U3 User's Guide The complete user's guide for the U3, including documentation for the LabJackUD driver. Covers hardware versions 1.20, 1.21, and 1.30 (LV/HV). To make a PDF of the whole manual, click "Export All" towards the upper-right of this page. If you are looking at a PDF or hardcopy, realize that the original is an online document at http://labjack.com/support/u3/users-guide. Rather than using a PDF, though, we encourage you to use this web-based documentation. Some advantages: We can quickly change or update content. The site search includes the user's guide, forum, and all other resources at labjack.com. When you are looking for something try using the site search. For support, try going to the applicable user's guide page and post a comment. When appropriate we can then immediately add/change content on that page to address the question. One other trick worth mentioning, is to browse the table of contents to the left. Rather than clicking on all the links to browse, you can click on the small black triangles to expand without reloading the whole page. User's Guide 1 - Installation on Windows The LJUD driver requires a PC running Windows. For other operating systems, go to labjack.com for available support. Software will be installed to the LabJack directory which defaults to c:\Program Files\LabJack\. Install the software first by going to labjack.com/support/u3. Connect the USB cable: The USB cable provides data and power. After the UD software installation is complete, connect the hardware and Windows should prompt with “Found New Hardware” and shortly after the Found New Hardware Wizard will open. When the Wizard appears allow Windows to install automatically by accepting all defaults. Run LJControlPanel: From the Windows Start Menu, go to the LabJack group and run LJControlPanel. Click the “Find Devices” button, and an entry should appear for the connected U3 showing the serial number. Click on the “USB – 1” entry below the serial number to bring up the U3 configuration panel. Click on “Test” in the configuration panel to bring up the test panel where you can view and control the various I/O on the U3. If LJControlPanel does not find the U3, check Windows Device Manager to see if the U3 installed correctly. One way to get to the Device Manager is: Start => Control Panel => System => Hardware => Device Manager The entry for the U3 should appear as in the following figure. If it has a yellow caution symbol or exclamation point symbol, right- click and select “Uninstall” or “Remove”. Then disconnect and reconnect the U3 and repeat the Found New Hardware Wizard as described above. Correctly Functioning U3 in Windows Device Manager 1.1 - Control Panel Application (LJControlPanel) The LabJack Control Panel application (LJCP) handles configuration and testing of the U3. Click on the “Find Devices” button to search for connected devices. 1

Upload: ajc42

Post on 26-Mar-2015

128 views

Category:

Documents


1 download

TRANSCRIPT

Published on LabJack (http://labjack.com)

U3 User's GuideThe complete user's guide for the U3, including documentation for the LabJackUD driver. Covers hardware versions 1.20, 1.21, and 1.30 (LV/HV). To make a PDF of the whole manual, click "Export All" towards the upper-right of this page. If you are looking at a PDF or hardcopy, realize that the original is an online document at http://labjack.com/support/u3/users-guide. Rather than using a PDF, though, we encourage you to use this web-based documentation. Some advantages: We can quickly change or update content. The site search includes the user's guide, forum, and all other resources at labjack.com. When you are looking for something try using the site search. For support, try going to the applicable user's guide page and post a comment. When appropriate we can then immediately add/change content on that page to address the question. One other trick worth mentioning, is to browse the table of contents to the left. Rather than clicking on all the links to browse, you can click on the small black triangles to expand without reloading the whole page.

User's Guide

1 - Installation on WindowsThe LJUD driver requires a PC running Windows. For other operating systems, go to labjack.com for available support. Software will be installed to the LabJack directory which defaults to c:\Program Files\LabJack\. Install the software first by going to labjack.com/support/u3. Connect the USB cable: The USB cable provides data and power. After the UD software installation is complete, connect the hardware and Windows should prompt with Found New Hardware and shortly after the Found New Hardware Wizard will open. When the Wizard appears allow Windows to install automatically by accepting all defaults. Run LJControlPanel: From the Windows Start Menu, go to the LabJack group and run LJControlPanel. Click the Find Devices button, and an entry should appear for the connected U3 showing the serial number. Click on the USB 1 entry below the serial number to bring up the U3 configuration panel. Click on Test in the configuration panel to bring up the test panel where you can view and control the various I/O on the U3. If LJControlPanel does not find the U3, check Windows Device Manager to see if the U3 installed correctly. One way to get to the Device Manager is: Start => Control Panel => System => Hardware => Device Manager The entry for the U3 should appear as in the following figure. If it has a yellow caution symbol or exclamation point symbol, rightclick and select Uninstall or Remove. Then disconnect and reconnect the U3 and repeat the Found New Hardware Wizard as described above.

Correctly Functioning U3 in Windows Device Manager

1.1 - Control Panel Application (LJControlPanel)The LabJack Control Panel application (LJCP) handles configuration and testing of the U3. Click on the Find Devices button to search for connected devices.

1

Figure 1-1. LJControlPanel Main Window Figure 1-1 shows the results from a typical search. The application found one U3 connected by USB. The USB connection has been selected in Figure 1-1, bringing up the configuration window on the right side. Refresh: Reload the window using values read from the device. Write Values: Write the Local ID from the window to the device. Config. IO Defaults: Opens the window shown in Figure 1-2. Reset: Click to reset the selected device. Test: Opens the window shown in Figure 1-3.

Figure 1-2. LJControlPanel U3 Configure Defaults Window Figure 1-2 shows the configuration window for U3 defaults. These are the values that will be loaded by the U3 at power-up or reset. The factory defaults, as shown above, are all lines configured as digital input. Figure 1-3 shows the U3 test window. This window continuously (once per second) writes to and reads from the selected LabJack.

Figure 1-3. LJControlPanel U3 Test Window Selecting Options=>Settings from the main LJControlPanel menu brings up the window shown in Figure 1-4. This window allows some features to of the LJControlPanel application to be customized.

2

Figure 1-4. LJControlPanel Settings Window Search for USB devices: If selected, LJControlPanel will include USB when searching for devices. Search for Ethernet devices using UDP broadcast packet: Does not apply to the U3. Search for Ethernet devices using specified IP addresses: Does not apply to the U3.

1.2 - Self-Upgrade Application (LJSelfUpgrade)The processor in the U3 has field upgradeable flash memory. The self-upgrade application shown in Figure 1-5 programs the latest firmware onto the processor. USB is the only interface on the U3, and first found is the only option for self-upgrading the U3, so no changes are needed in the Connect by: box. There must only be one U3 connected to the PC when running LJSelfUpgrade. Click on Get Version Numbers, to find out the current firmware versions on the device. Then use the provided Internet link to go to labjack.com and check for more recent firmware. Download firmware files to the \LabJack\LJSelfUpgrade\upgradefiles\ directory. Click the Browse button and select the upgrade file to program. Click the Program button to begin the self-upgrade process.

Figure 1-5. Self-Upgrade Application If problems are encountered during programming, try the following: 1. Unplug the U3, wait 5 seconds then reconnect the U3. Click OK then press program again. 2. If step 1 does not fix the problem unplug the U3 and watch the LED while plugging the U3 back in. Follow the following steps based on the LED's activity. 1. If the LED is blinking continuously (flash mode), connect a jumper between FIO4 and SPC (FIO0 to SCL on U3 1.20/1.21), then unplug the U3, wait 5 seconds and plug the U3 back in. Try programming again (disconnect the jumper before programming). 2. If the LED blinks several times and stays on, connect a jumper between FIO5 and SPC (FIO1 to SCL on U3 1.20/1.21), then unplug the U3, wait 5 seconds and plug the U3 back in. Try programming again (disconnect the jumper before programming). 3. If the LED blinks several times and stays off, the U3 is not enumerating. Please restart your computer and try to program again. 4. If there is no LED activity, connect a jumper between FIO5 and SPC (FIO1 to SCL on U3 1.20/1.21), then unplug the U3, wait 5 seconds and plug the U3 back in. If the LED is blinking continuously click OK and program again (after removing the jumper). If the LED does not blink connect a jumper between FIO4 and SPC (FIO0 to SCL on U3 1.20/1.21), then unplug the U3, wait 5 seconds and plug the U3 back in. 5. If the LED does a repeating pattern of 3 blinks then pause, the U3 has detected internal memory corruption and you will have to contact LabJack Support. 3. If there is no activity from the U3's LED after following the above steps, please contact support.

2 - Hardware DescriptionThe U3 has 3 different I/O areas: Communication Edge, Screw Terminal Edge, DB Edge. The communication edge has a USB type B connector (with black cable connected in Figure 2-1). All power and communication is handled by the USB interface. The screw terminal edge has convenient connections for the analog outputs and 8 flexible I/O (digital I/O, analog inputs, timers, or counters). The screw terminals are arranged in blocks of 4, with each block consisting of Vs, GND, and two I/O. There is also a status LED located on the left edge. The DB Edge has a D-sub type connectors called DB15 which has the 8 EIO lines and 4 CIO lines. The EIO lines are flexible like the FIO lines, while the CIO are dedicated digital I/O.

3

Figure 2-1. LabJack U3

2.1 - USBFor information about USB installation, see Section 1. The U3 has a full-speed USB connection compatible with USB version 1.1 or 2.0. This connection provides communication and power (Vusb). USB ground is connected to the U3 ground (GND), and USB ground is generally the same as the ground of the PC chassis and AC mains. The details of the U3 USB interface are handled by the high level drivers (Windows LabJackUD DLL), so the following information is really only needed when developing low-level drivers. The LabJack vendor ID is 0x0CD5. The product ID for the U3 is 0x0003. The USB interface consists of the normal bidirectional control endpoint (0 OUT & IN), 3 used bulk endpoints (1 OUT, 2 IN, 3 IN), and 1 dummy endpoint (3 OUT). Endpoint 1 consists of a 64 byte OUT endpoint (address = 0x01). Endpoint 2 consists of a 64 byte IN endpoint (address = 0x82). Endpoint 3 consists of a dummy OUT endpoint (address = 0x03) and a 64 byte IN endpoint (address = 0x83). Endpoint 3 OUT is not supported by the firmware, and should never be used. All commands should always be sent on Endpoint 1, and the responses to commands will always be on Endpoint 2. Endpoint 3 is only used to send stream data from the U3 to the host.

2.2 - Status LEDThere is a green status LED on the LabJack U3. This LED blinks on reset, and then remains steadily lit. Other LED behavior is generally related to flash upgrade modes (Section 1.2).

2.3 - GND and SGNDThe GND connections available at the screw-terminals and DB connectors provide a common ground for all LabJack functions. This ground is the same as the ground line on the USB connection, which is often the same as ground on the PC chassis and therefore AC mains ground. SGND is located near the upper-left of the device. This terminal has a self-resetting thermal fuse in series with GND. This is often a good terminal to use when connecting the ground from another separately powered system that could unknowingly already share a common ground with the U3. See the AIN, DAC, and Digital I/O Sections for more information about grounding.

2.4 - VSThe Vs terminals are designed as outputs for the internal supply voltage (nominally 5 volts). This will be the voltage provided from the USB cable. The Vs connections are outputs, not inputs. Do not connect a power source to Vs in normal situations. All Vs terminals are the same.

2.5 - Flexible I/O (FIO/EIO)The FIO and EIO ports on the LabJack U3 can be individually configured as digital input, digital output, or analog input. This is FIO0-EIO7 on the U3-LV (16 lines), or FIO4-EIO7 on the U3-HV (12 lines). In addition, up to 2 of these lines can be configured as timers, and up to 2 of these lines can be configured as counters. If a line is configured as analog, it is called AINx according to the following table:AIN0 FIO0 AIN8 EIO0 AIN1 FIO1 AIN9 EIO1 AIN2 FIO2 AIN10 EIO2 AIN3 FIO3 AIN11 EIO3 AIN4 FIO4 AIN12 EIO4 AIN5 FIO5 AIN13 EIO5 AIN6 FIO6 AIN14 EIO6 AIN7 FIO7 AIN15 EIO7 Table 2.5-1. Analog Input Pin Locations

On the U3-HV, compared to the -LV, the first four flexible I/O are fixed as analog inputs (AIN0-AIN3) with a nominal 10 volt input range. All digital operations, including analog/digital configuration, are ignored on these 4 fixed analog inputs. Timers and counters can appear on various pins, but other I/O lines never move. For example, Timer1 can appear anywhere from FIO4 to EIO1, depending on TimerCounterPinOffset and whether Timer0 is enabled. On the other hand, FIO5 (for example), is always on the screw terminal labeled FIO5, and AIN5 (if enabled) is always on that same screw terminal. The first 8 flexible I/O lines (FIO0-FIO7) appear on built-in screw terminals. The other 8 flexible I/O lines (EIO0-EIO7) are available on the DB15 connector. Many software applications will need to initialize the flexible I/O to a known pin configuration. That requires calls to the low-level functions ConfigIO and ConfigTimerClock. Following are the values to set the pin configuration to the factory default state:

4

Byte # 6 WriteMask 15 Write all parameters 8 TimerCounterConfig 0 No Timers/Counters. Offset = 4 9 DAC1 Enable 0 DAC1 Disabled. (Ignored on HW 1.3) 10 FIOAnalog 0 FIO all digital. 11 EIOAnalog 0 EIO all digital. Table 2.5-2. ConfigIO Factory Default Values Byte # 8 TimerClockConfig 130 Set clock to 48MHz. 9 TimerClockDivisor 0 Divisor = 0. Table 2.5-3. ConfigTimerClock Factory Default Values

When using the high-level LabJackUD driver, this could be done with the following requests:ePut ePut ePut ePut ePut ePut ePut ePut (lngHandle, (lngHandle, (lngHandle, (lngHandle, (lngHandle, (lngHandle, (lngHandle, (lngHandle, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 0, 0); LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 4, 0); LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc48MHZ, 0); LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 0, 0); LJ_ioPUT_COUNTER_ENABLE, 0, 0, 0); LJ_ioPUT_COUNTER_ENABLE, 1, 0, 0); LJ_ioPUT_DAC_ENABLE, 1, 0, 0); //Ignored on hardware rev 1.30+. LJ_ioPUT_ANALOG_ENABLE_PORT, 0, 0, 16);

or with a single request to the following IOType created exactly for this purpose:ePut (lngHandle, LJ_ioPIN_CONFIGURATION_RESET, 0, 0, 0);

2.6 - AINThe LabJack U3 has up to 16 analog inputs available on the flexible I/O lines (FIO0-FIO7 and EIO0-EIO7). Single-ended measurements can be taken of any line compared to ground, or differential measurements can be taken of any line to any other line. Analog input resolution is 12-bits. The range of single-ended analog inputs is normally about 0-2.44, and there is a special 0-3.6 volt range available. The range of differential analog inputs is typically 2.4 volts, but is pseudobipolar, not true bipolar. The difference (positive channel minus negative channel) can be -2.4 volts, but neither input can have a voltage less than -0.3 volts to ground. For valid measurements, the voltage on every low-voltage analog input pin, with respect to ground, must be within -0.3 to +3.6 volts. See Appendix A for voltage limits to avoid damage. On the U3-HV, compared to the -LV, the first four flexible I/O are fixed as analog inputs (AIN0-AIN3), and have scaling such that the input range is a true bipolar 10 volts normally, and -10 to +20 volts when using the special range. The input impedance of these four lines is roughly 1 M, which is good, but less than the normal low voltage analog inputs. Analog/digital configuration and all other digital operations on these pins are ignored. FIO4-EIO7 are still available as flexible I/O, same as the U3-LV. Because the scaling on the high-voltage inputs on the U3-HV (AIN0-AIN3) is inherently single-ended, a factory calibration is not possible for differential readings. If a differential reading is requested where either channel is a high-voltage channel, the driver will return the raw binary reading and the user must handle calibration/conversion. The analog inputs have a QuickSample option where each conversion is done faster at the expense of increased noise. This is enabled by passing a nonzero value for put_config special channel LJ_chAIN_RESOLUTION. There is also a LongSettling option where additional settling time is added between the internal multiplexer configuration and the analog to digital conversion. This allows signals with more source impedance, and is enabled by passing a nonzero value for put_config special channel LJ_chAIN_SETTLING_TIME. Both of these options are disabled by default. This applies to command/response mode only, and the resulting typical data rates are discussed in Section 3.1. For stream mode, see Section 3.2. Note that sinking excessive current into digital outputs can cause substantial errors in analog input readings. See Section 2.8.1.4 for more info.

2.6.1 - Channel NumbersThe LabJack U3 has up to 16 external analog inputs, plus a few internal channels. The low-level functions specify a positive and negative channel for each analog input conversion. With the LabJackUD driver, the IOType LJ_ioGET_AIN is used for singleended channels only, and thus the negative channel is internally set to 31. There is an additional IOType called LJ_ioGET_AIN_DIFF that allows the user to specify the positive and negative channel.Positive Channel # 0-7 AIN0-AIN7 (FIO0-FIO7) 8-15 AIN8-AIN15 (EIO0-EIO7) 30 Temp Sensor 31 Vreg Table 2.6.1-1. Positive Channel Numbers Negative Channel # 0-7 AIN0-AIN7 (FIO0-FIO7) 8-15 AIN8-AIN15 (EIO0-EIO7) 30 Vref 31 or 199 Single-Ended 32 Special 0-3.6 or -10/+20 (UD Only) Table 2.6.1-2 Negative Channel Numbers

Positive channel 31 puts the internal Vreg (~3.3 volts) on the positive input of the ADC. See Section 2.6.4 for information about the internal temperature sensor. If the negative channel is set to anything besides 31/199, the U3 does a differential conversion and returns a pseudobipolar value. If the negative channel is set to 31/199, the U3 does a single-ended conversion and returns a unipolar value. Channel 30 puts the internal voltage reference Vref (~2.44 volts) on the negative input of the ADC. Channel 32 is a special negative channel supported by the LabJack UD driver. When used, the driver will actually pass 30 as the negative channel to the U3, and when the result is returned the driver adds Vref to the value. For a low-voltage analog input this results in a full span on the positive channel of about 0 to 4.88 volts (versus ground), but since the voltage on any analog input cannot exceed 3.6 volts, only 75% of the converters range is used and the span is about 0 to 3.6 volts. For a high-voltage analog input, channel 32 (special range) results in a span of about -10 to +20 volts. In the U3 examples that accompany the Exodriver, u3.c also supports channel 32 in calls to eAIN(). Channel 32 is also supported in LabJackPython:# On the U3, wire a jumper from DAC0 to FIO0, then run: >>> import u3 >>> d = u3.U3() >>> d.configIO(FIOAnalog = 1) # Set FIO0 to analog >>> d.writeRegister(5000, 3) # Set DAC0 to 3 V

5

>>> d.getAIN(0, 32) 3.0141140941996127

For the four high-voltage channels on the U3-HV, the special channel negative channel also puts Vref on the negative. This results in an overall range of about -10 to +20 volts on the positive input.

2.6.2 - Converting Binary Readings to VoltagesFollowing are the nominal input voltage ranges for the low-voltage analog inputs. This is all analog inputs on the U3-LV, and AIN4AIN15 on the U3-HV.Max V Min V Single-Ended 2.44 0 Differential 2.44 -2.44 Special 0-3.6 3.6 0 Table 2.6.2-1. Nominal Analog Input Voltage Ranges for Low-Voltage Channels Max V Single-Ended 10.3 Differential N/A Special -10/+20 20.1 Table 2.6.2-2. Nominal Analog Min V -10.3 N/A -10.3 Input Voltage Ranges for High-Voltage Channels

Note that the minimum differential input voltage of -2.44 volts means that the positive channel can be as much as 2.44 volts less than the negative channel, not that a channel can measure 2.44 volts less than ground. The voltage of any low-voltage analog input pin, compared to ground, must be in the range -0.3 to +3.6 volts. The special range (0-3.6 on low-voltage channels and -10/+20 volts on high-voltage channels) is obtained by doing a differential measurement where the negative channel is set to the internal Vref (2.44 volts). For low-voltage channels, simply do the lowvoltage differential conversion as described below, then add the stored Vref value. For high-voltage channels, do the same thing, then multiply by the proper high-voltage slope, divide by the single-ended low-voltage slope, and add the proper high-voltage offset. The UD driver handles these conversions automatically. Although the binary readings have 12-bit resolution, they are returned justified as 16-bit values, so the approximate nominal conversion from binary to voltage is:Volts(uncalibrated) = (Bits/65536)*Span (Single-Ended) Volts(uncalibrated) = (Bits/65536)*Span Span/2 (Differential)

Binary readings are always unsigned integers. Where span is the maximum voltage minus the minimum voltage from the tables above. The actual nominal conversions are provided in the tables below, and should be used if the actual calibration constants are not read for some reason. Most applications will use the actual calibrations constants (Slope and Offset) stored in the internal flash.Volts = (Slope * Bits) + Offset

Since the U3 uses multiplexed channels connected to a single analog-to-digital converter (ADC), all low-voltage channels have the same calibration for a given configuration. High-voltage channels have individual scaling circuitry out front, and thus the calibration is unique for each channel. See Section 5.4 for detail about the location of the U3 calibration constants.

2.6.2.1 - Analog Inputs With DAC1 Enabled (Hardware Revisions 1.20 & 1.21 only)This Section only applies to the older hardware revisions 1.20 and 1.21. Starting with hardware revision 1.30, DAC1 is always enabled and does not affect the analog inputs. The previous information assumed that DAC1 is disabled. If DAC1 is enabled, then the internal reference (Vref = 2.44 volts) is not available for the ADC, and instead the internal regulator voltage (Vreg = 3.3 volts) is used as the reference for the ADC. Vreg is not as stable as Vref, but more stable than Vs (5 volt power supply). Following are the nominal input voltage ranges for the analog inputs, assuming that DAC1 is enabled.Max V Min V Single-Ended 3.3 0 Differential 3.3 -3.3 Special -10/+20 N/A N/A Table 2.6.2.1-1. Nominal Analog Input Voltage Ranges (DAC1 Enabled)

Note that the minimum differential input voltage of -3.3 volts means that the positive channel can be as much as 3.3 volts less than the negative channel, not that a channel can measure 3.3 volts less than ground. The voltage of any analog input pin, compared to ground, must be in the range -0.3 to +3.6 volts, for specified performance. See Appendix A for voltage limits to avoid damage. Negative channel numbers 30 and 32 are not valid with DAC1 enabled. When DAC1 is enabled, the slope/offset calibration constants are not used to convert raw readings to voltages. Rather, the Vreg value is retrieved from the Mem area, and used with the approximate single-ended or differential conversion equations above, where Span is Vreg (single-ended) or 2Vreg (differential).

2.6.3 - Typical Analog Input ConnectionsA common question is can this sensor/signal be measured with the U3. Unless the signal has a voltage (referred to U3 ground) beyond the limits in Appendix A, it can be connected without damaging the U3, but more thought is required to determine what is necessary to make useful measurements with the U3 or any measurement device. Voltage (versus ground): The single-ended analog inputs on the U3 measure a voltage with respect to U3 ground. The differential inputs measure the voltage difference between two channels, but the voltage on each channel with respect to ground must still be within the common mode limits specified in Appendix A. When measuring parameters other than voltage, or voltages too big or too small for the U3, some sort of sensor or transducer is required to produce the proper voltage signal. Examples are a temperature sensor, amplifier, resistive voltage divider, or perhaps a combination of such things. Impedance: When connecting the U3, or any measuring device, to a signal source, it must be considered what impact the measuring device will have on the signal. The main consideration is whether the currents going into or out of the U3 analog input will cause noticeable voltage errors due to the impedance of the source. To maintain consistent 12-bit results, it is recommended to keep the source impedance within the limits specified in Appendix A. Resolution (and Accuracy): Based on the measurement type and resolution of the U3, the resolution can be determined in terms of

6

voltage or engineering units. For example, assume some temperature sensor provides a 0-10 mV signal, corresponding to 0-100 degrees C. Samples are then acquired with the U3 using the 0-2.44 volt single-ended input range, resulting in a voltage resolution of about 2.44/4096 = 596 V. That means there will be about 17 discrete steps across the 10 mV span of the signal, and the temperature resolution is about 6 degrees C. If this experiment required a resolution of 1 degrees C, this configuration would not be sufficient. Accuracy will also need to be considered. Appendix A places some boundaries on expected accuracy, but an insystem calibration can generally be done to provide absolute accuracy down to the linearity (INL) limits of the U3. Speed: How fast does the signal need to be sampled? For instance, if the signal is a waveform, what information is needed: peak, average, RMS, shape, frequency, ? Answers to these questions will help decide how many points are needed per waveform cycle, and thus what sampling rate is required. In the case of multiple channels, the scan rate is also considered. See Sections 3.1 and 3.2.

2.6.3.1 - Signal from the LabJackOne example of measuring a signal from the U3 itself, is with an analog output. All I/O on the U3 share a common ground, so the voltage on an analog output (DAC) can be measured by simply connecting a single wire from that terminal to an AIN terminal (FIO/EIO). The analog output must be set to a voltage within the range of the analog input.

2.6.3.2 - Unpowered Isolated SignalAn example of an unpowered isolated signal would be a photocell where the sensor leads are not shorted to any external voltages. Such a sensor typically has two leads, where the positive lead connects to an AIN terminal and the negative lead connects to a GND terminal.

2.6.3.3 - Signal Powered By the LabJackA typical example of this type of signal is a 3-wire temperature sensor. The sensor has a power and ground wire that connect to Vs and GND on the LabJack, and then has a signal wire that simply connects to an AIN terminal. Another variation is a 4-wire sensor where there are two signal wires (positive and negative) rather than one. If the negative signal is the same as power ground, or can be shorted ground, then the positive signal can be connected to AIN and a single-ended measurement can be made. A typical example where this does not work is a bridge type sensor, such as pressure sensor, providing the raw bridge output (and no amplifier). In this case the signal voltage is the difference between the positive and negative signal, and the negative signal cannot be shorted to ground. Such a signal could be measured using a differential input on the U3.

2.6.3.4 - Signal Powered ExternallyAn example is a box with a wire coming out that is defined as a 0-2 volt analog signal and a second wire labeled as ground. The signal is known to have 0-2 volts compared to the ground wire, but the complication is what is the voltage of the box ground compared to the LabJack ground. If the box is known to be electrically isolated from the LabJack, the box ground can simply be connected to LabJack GND. An example would be if the box was plastic, powered by an internal battery, and does not have any wires besides the signal and ground which are connected to AINx and GND on the LabJack. If the box ground is known to be the same as the LabJack GND, then perhaps only the one signal wire needs to be connected to the LabJack, but it generally does not hurt to go ahead and connect the ground wire to LabJack GND with a 100 resistor. You definitely do not want to connect the grounds without a resistor. If little is known about the box ground, a DMM can be used to measure the voltage of box ground compared to LabJack GND. As long as an extreme voltage is not measured, it is generally OK to connect the box ground to LabJack GND, but it is a good idea to put in a 100 series resistor to prevent large currents from flowing on the ground. Use a small wattage resistor (typically 1/8 or 1/4 watt) so that it blows if too much current does flow. The only current that should flow on the ground is the return of the analog input bias current, which is only microamps. The SGND terminals (on the same terminal block as SPC) can be used instead of GND for externally powered signals. A series resistor is not needed as SGND is fused to prevent overcurrent, but a resistor will eliminate confusion that can be caused if the fuse is tripping and resetting. In general, if there is uncertainty, a good approach is to use a DMM to measure the voltage on each signal/ground wire without any connections to the U3. If no large voltages are noted, connect the ground to U3 SGND with a 100 series resistor. Then again use the DMM to measure the voltage of each signal wire before connecting to the U3. Another good general rule is to use the minimum number of ground connections. For instance, if connecting 8 sensors powered by the same external supply, or otherwise referred to the same external ground, only a single ground connection is needed to the U3. Perhaps the ground leads from the 8 sensors would be twisted together, and then a single wire would be connected to a 100 resistor which is connected to U3 ground.

2.6.3.5 - Amplifying Small Signal VoltagesThe best results are generally obtained when a signal voltage spans the full analog input range of the LabJack. If the signal is too small it can be amplified before connecting to the LabJack. One good way to handle low-level signals such as thermocouples is the LJTick-InAmp, which is a 2-channel instrumentation amplifier module that plugs into the U3 screw-terminals. For a do-it-yourself solution, the following figure shows an operational amplifier (op-amp) configured as non-inverting:

7

Figure 2-3. Non-Inverting Op-Amp Configuration The gain of this configuration is:Vout = Vin * (1 + (R2/R1))

100 k is a typical value for R2. Note that if R2=0 (short-circuit) and R1=inf (not installed), a simple buffer with a gain equal to 1 is the result. There are numerous criteria used to choose an op-amp from the thousands that are available. One of the main criteria is that the op-amp can handle the input and output signal range. Often, a single-supply rail-to-rail input and output (RIRO) is used as it can be powered from Vs and GND and pass signals within the range 0-Vs. The OPA344 from Texas Instruments (ti.com) is good for many 5 volt applications. The op-amp is used to amplify (and buffer) a signal that is referred to the same ground as the LabJack (single-ended). If instead the signal is differential (i.e. there is a positive and negative signal both of which are different than ground), an instrumentation amplifier (in-amp) should be used. An in-amp converts a differential signal to single-ended, and generally has a simple method to set gain.

2.6.3.6 - Signal Voltages Beyond 0-2.44 Volts (and Resistance Measurement)The normal input range for a low voltage channel on the U3 is about 0-2.44 volts. The easiest way to handle larger voltages is often by using the LJTick-Divider, which is a two channel buffered divider module that plugs into the U3 screw-terminals. The basic way to handle higher unipolar voltages is with a resistive voltage divider. The following figure shows the resistive voltage divider assuming that the source voltage (Vin) is referred to the same ground as the U3 (GND).

Figure 2-4. Voltage Divider Circuit The attenuation of this circuit is determined by the equation:Vout = Vin * ( R2 / (R1+R2))

This divider is easily implemented by putting a resistor (R1) in series with the signal wire, and placing a second resistor (R2) from the AIN terminal to a GND terminal. To maintain specified analog input performance, R1 should not exceed the values specified in Appendix A, so R1 can generally be fixed at the max recommended value and R2 can be adjusted for the desired attenuation. The divide by 2 configuration where R1 = R2 = 10 k (max source impedance limit for low-voltage channels), presents a 20 k load to the source, meaning that a 5 volt signal will have to be able to source/sink up to +250 A. Some signal sources might require a load with higher resistance, in which case a buffer should be used. The following figure shows a resistive voltage divider followed by an op-amp configured as non-inverting unity-gain (i.e. a buffer).

Figure 2-5. Buffered Voltage Divider Circuit The op-amp is chosen to have low input bias currents so that large resistors can be used in the voltage divider. For 0-5 volt applications, where the amp will be powered from Vs and GND, a good choice would be the OPA344 from Texas Instruments (ti.com). The OPA344 has a very small bias current that changes little across the entire voltage range. Note that when powering the amp from Vs and GND, the input and output to the op-amp is limited to that range, so if Vs is 4.8 volts your signal range will be 04.8 volts. The information above also applies to resistance measurement. A common way to measure resistance is to build a voltage divider as shown in Figure 2-4, where one of the resistors is known and the other is the unknown. If Vin is known and Vout is measured, the voltage divider equation can be rearranged to solve for the unknown resistance.

2.6.3.7 - Measuring Current (Including 4-20 mA) with a Resistive ShuntThe following figure shows a typical method to measure the current through a load, or to measure the 4-20 mA signal produced by a 2-wire (loop-powered) current loop sensor. The current shunt shown in the figure is simply a resistor.

Figure 2-5. Current Measurement With Arbitrary Load or 2-Wire 4-20 mA Sensor When measuring a 4-20 mA signal, a typical value for the shunt would be 120 . This results in a 0.48 to 2.40 volt signal corresponding to 4-20 mA. The external supply must provide enough voltage for the sensor and the shunt, so if the sensor requires 5 volts the supply must provide at least 7.4 volts.

8

For applications besides 4-20 mA, the shunt is chosen based on the maximum current and how much voltage drop can be tolerated across the shunt. For instance, if the maximum current is 1.0 amp, and 1.0 volts of drop is the most that can be tolerated without affecting the load, a 1.0 resistor could be used. That equates to 1.0 watts, though, which would require a special high wattage resistor. A better solution would be to use a 0.1 shunt, and then use an amplifier to increase the small voltage produced by that shunt. If the maximum current to measure is too high (e.g. 100 amps), it will be difficult to find a small enough resistor and a hall-effect sensor should be considered instead of a shunt. The following figure shows typical connections for a 3-wire 4-20 mA sensor. A typical value for the shunt would be 120 which results in 0.48 to 2.40 volts.

Figure 2-6. Current Measurement With 3-Wire 4-20 mA (Sourcing) Sensor The sensor shown in Figure 2-6 is a sourcing type, where the signal sources the 4-20 mA current which is then sent through the shunt resistor and sunk into ground. Another type of 3-wire sensor is the sinking type, where the 4-20 mA current is sourced from the positive supply, sent through the shunt resistor, and then sunk into the signal wire. If sensor ground is connected to U3 ground, the sinking type of sensor presents a problem, as at least one side of the resistor has a high common mode voltage (equal to the positive sensor supply). If the sensor is isolated, a possible solution is to connect the sensor signal or positive sensor supply to U3 ground (instead of sensor ground). This requires a good understanding of grounding and isolation in the system. The LJTickCurrentShunt is often a simple solution. Both Figure 2-5 and 2-6 show a 0-100 resistor in series with SGND, which is discussed in general in Section 2.6.3.4. In this case, if SGND is used (rather than GND), a direct connection (0 ) should be good. The best way to handle 4-20 mA signals is with the LJTick-CurrentShunt, which is a two channel active current to voltage converter module that plugs into the U3 screw-terminals.

2.6.3.8 - Floating/Unconnected InputsThe reading from a floating (no external connection) analog input channel can be tough to predict and is likely to vary with sample timing and adjacent sampled channels. Keep in mind that a floating channel is not at 0 volts, but rather is at an undefined voltage. In order to see 0 volts, a 0 volt signal (such as GND) should be connected to the input. Some data acquisition devices use a resistor, from the input to ground, to bias an unconnected input to read 0. This is often just for cosmetic reasons so that the input reads close to 0 with floating inputs, and a reason not to do that is that this resistor can degrade the input impedance of the analog input. In a situation where it is desired that a floating channel read a particular voltage, say to detect a broken wire, a resistor (pull-down or pull-up) can be placed from the AINx screw terminal to the desired voltage (GND, VS, DACx, ). A 100 k resistor should pull the analog input readings to within 50 mV of any desired voltage, but obviously degrades the input impedance to 100 k. For the specific case of pulling a floating channel to 0 volts, a 1 M resistor to GND can typically be used to provide analog input readings of less than 50 mV. This information is for a low-voltage analog input channel on a U3. Note that the four high-voltage channels on the U3-HV do sit at a predictable 1.4 volts. You can use a pull-down or pull-up resistor with the high-voltage inputs, but because their input impedance is lower the resistor must be lower (~1k might be typical) and thus the signal is going to have to drive substantial current.

2.6.4 - Internal Temperature SensorThe U3 has an internal temperature sensor. Although this sensor measures the temperature inside the U3, which is warmer than ambient, it has been calibrated to read actual ambient temperature. For accurate measurements the temperature of the entire U3 must stabilize relative to the ambient temperature, which can take on the order of 1 hour. Best results will be obtained in still air in an environment with slowly changing ambient temperatures. With the UD driver, the internal temperature sensor is read by acquiring single-ended analog input channel 30, and returns degrees K.

2.7 - DACThe LabJack U3 has 2 analog outputs (DAC0 and DAC1) that are available on the screw terminals. Each analog output can be set to a voltage between about 0.04 and 4.95 volts with 10 bits of resolution (8 bits on older hardware revision 1.20/1.21). The maximum output voltage is limited by the supply voltage to the U3. Starting with hardware revision 1.30, DAC1 is always enabled and does not affect the analog inputs, but with older hardware the second analog output is only available in certain configurations. With hardware revisions >> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 1) Sent: [0x49, 0xf8, 0x3, 0xb, 0x42, 0x0, 0x1, 0x0, 0x41, 0x0, 0x0, 0x0] Response: [0x57, 0xf8, 0x3, 0xb, 0x50, 0x0, 0x0, 0x0, 0x41, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 65, 'EnableCounter1' >>> d.getFeedback(u3.Timer(timer = 0, UpdateReset = False, Value = 0, Mode = None)) Sent: [0x26, 0xf8, 0x3, 0x0, 0x2a, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x0] Response: [0xfc, 0xf8, 0x4, 0x0, 0xfe, 0x1, 0x0, 0x0, 0x0, 0x63, 0xdd, 0x4c, 0x72, 0x0] [1917640035]This Gist brought to you by GitHub. u3-feedback-Timer.txt view raw

For reading the value of the Timer0. It provides the ability to update/reset Timer0, and read the timer value. (Section 5.2.5.14 of the User's Guide) UpdateReset: Set True if you want to update the value Value: Only updated if the UpdateReset bit is 1. parameter varies with the timer mode. The meaning of this

Mode: Set to the timer mode to handle any special processing. See classes QuadratureInputTimer and TimerStopInput1.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 1) Sent: [0x49, 0xf8, 0x3, 0xb, 0x42, 0x0, 0x1, 0x0, 0x41, 0x0, 0x0, 0x0] Response: [0x57, 0xf8, 0x3, 0xb, 0x50, 0x0, 0x0, 0x0, 0x41, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 65, 'EnableCounter1' >>> d.getFeedback(u3.Timer0(UpdateReset = False, Value = 0, Mode = None)) Sent: [0x26, 0xf8, 0x3, 0x0, 0x2a, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x0] Response: [0x51, 0xf8, 0x4, 0x0, 0x52, 0x2, 0x0, 0x0, 0x0, 0xf6, 0x90, 0x46, 0x86, 0x0] [2252771574]This Gist brought to you by GitHub. u3-feedback-Timer0.txt view raw

50

For reading the value of the Timer1. It provides the ability to update/reset Timer1, and read the timer value. (Section 5.2.5.14 of the User's Guide) UpdateReset: Set True if you want to update the value Value: Only updated if the UpdateReset bit is 1. parameter varies with the timer mode. The meaning of this

Mode: Set to the timer mode to handle any special processing. See classes QuadratureInputTimer and TimerStopInput1.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 2) Sent: [0x4a, 0xf8, 0x3, 0xb, 0x43, 0x0, 0x1, 0x0, 0x42, 0x0, 0x0, 0x0] Response: [0x58, 0xf8, 0x3, 0xb, 0x51, 0x0, 0x0, 0x0, 0x42, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 2, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 66, 'EnableCounter1' >>> d.getFeedback(u3.Timer1(UpdateReset = False, Value = 0, Mode = None)) Sent: [0x28, 0xf8, 0x3, 0x0, 0x2c, 0x0, 0x0, 0x2c, 0x0, 0x0, 0x0, 0x0] Response: [0x8d, 0xf8, 0x4, 0x0, 0x8e, 0x2, 0x0, 0x0, 0x0, 0xf3, 0x31, 0xd0, 0x9a, 0x0] [2597335539]This Gist brought to you by GitHub. u3-feedback-Timer1.txt view raw

For reading Quadrature input timers. They are special because their values are signed. (Section 2.9.1.8 of the User's Guide) Args: UpdateReset: Set True if you want to reset the counter. Value: Set to 0, and UpdateReset to True to reset the counter. Returns a signed integer.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 2) Sent: [0x4a, 0xf8, 0x3, 0xb, 0x43, 0x0, 0x1, 0x0, 0x42, 0x0, 0x0, 0x0] Response: [0x58, 0xf8, 0x3, 0xb, 0x51, 0x0, 0x0, 0x0, 0x42, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 2, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 66, 'EnableCounter1' >>> # Setup the two timers to be quadrature >>> d.getFeedback(u3.Timer0Config(8), u3.Timer1Config(8)) Sent: [0x66, 0xf8, 0x5, 0x0, 0x68, 0x0, 0x0, 0x2b, 0x8, 0x0, 0x0, 0x2d, 0x8, 0x0, 0x0, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None, None] >>> # Read the value [0] >>> d.getFeedback(u3.QuadratureInputTimer()) Sent: [0x26, 0xf8, 0x3, 0x0, 0x2a, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x0] Response: [0xf5, 0xf8, 0x4, 0x0, 0xf5, 0x3, 0x0, 0x0, 0x0, 0xf8, 0xff, 0xff, 0xff, 0x0] [-8] >>> d.getFeedback(u3.QuadratureInputTimer()) Sent: [0x26, 0xf8, 0x3, 0x0, 0x2a, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x0] Response: [0x9, 0xf8, 0x4, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0] [12]This Gist brought to you by GitHub. u3-feedback-QuadratureInputTimer.txt view raw

For reading a stop input timer. They are special because the value returns the current edge count and the stop value. (Section 2.9.1.9 of the User's Guide) Args: UpdateReset: Set True if you want to update the value. Value: The stop value. Only updated if the UpdateReset bit is 1. Returns a tuple where the first value is current edge count, and the second value is the stop value.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 2) Sent: [0x4a, 0xf8, 0x3, 0xb, 0x43, 0x0, 0x1, 0x0, 0x42, 0x0, 0x0, 0x0] Response: [0x58, 0xf8, 0x3, 0xb, 0x51, 0x0, 0x0, 0x0, 0x42, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 2, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 66, 'EnableCounter1' >>> # Setup the timer to be Stop Input >>> d.getFeedback(u3.Timer1Config(9, Value = 30)) Sent: [0x50, 0xf8, 0x3, 0x0, 0x54, 0x0, 0x0, 0x2d, 0x9, 0x1e, 0x0, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None] >>> d.getFeedback(u3.TimerStopInput1()) Sent: [0x28, 0xf8, 0x3, 0x0, 0x2c, 0x0, 0x0, 0x2c, 0x0, 0x0, 0x0, 0x0] Response: [0x1b, 0xf8, 0x4, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x0] [(0, 0)]This Gist brought to you by GitHub. u3-feedback-TimerStopInput1.txt view raw

5.2.5.16 - Timer#Config: IOType=43,4551

Timer#Config, 4 Command Bytes: 0 IOType = 43, 45 1 TimerMode 2 Value LSB 3 Value MSB 0 Response Bytes:

This IOType configures a particular timer. TimerMode: See Section 2.9 for more information about the available modes. Value: The meaning of this parameter varies with the timer mode.

LabJackPython example sessionAutomatically extracted from u3.py. Debugging turned on to show the bytes sent and received. This IOType configures a particular timer. timer = # of the timer to configure TimerMode = See Section 2.9 for more information about the available modes. Value = The meaning of this parameter varies with the timer mode.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 1) Sent: [0x49, 0xf8, 0x3, 0xb, 0x42, 0x0, 0x1, 0x0, 0x41, 0x0, 0x0, 0x0] Response: [0x57, 0xf8, 0x3, 0xb, 0x50, 0x0, 0x0, 0x0, 0x41, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 65, 'EnableCounter1' >>> d.getFeedback(u3.TimerConfig(timer = 0, TimerMode = 0, Value = 0)) Sent: [0x27, 0xf8, 0x3, 0x0, 0x2b, 0x0, 0x0, 0x2b, 0x0, 0x0, 0x0, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None] >>> d.getFeedback(u3.TimerConfig(timer = 0, TimerMode = 0, Value = 65535)) Sent: [0x27, 0xf8, 0x3, 0x0, 0x29, 0x2, 0x0, 0x2b, 0x0, 0xff, 0xff, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None]This Gist brought to you by GitHub. u3-feedback-TimerCong.txt view raw

This IOType configures Timer0. TimerMode = See Section 2.9 for more information about the available modes. Value = The meaning of this parameter varies with the timer mode.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 1) Sent: [0x49, 0xf8, 0x3, 0xb, 0x42, 0x0, 0x1, 0x0, 0x41, 0x0, 0x0, 0x0] Response: [0x57, 0xf8, 0x3, 0xb, 0x50, 0x0, 0x0, 0x0, 0x41, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 65, 'EnableCounter1' >>> d.getFeedback(u3.Timer0Config(TimerMode = 1, Value = 0)) Sent: [0x28, 0xf8, 0x3, 0x0, 0x2c, 0x0, 0x0, 0x2b, 0x1, 0x0, 0x0, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None] >>> d.getFeedback(u3.Timer0Config(TimerMode = 1, Value = 65535)) Sent: [0x28, 0xf8, 0x3, 0x0, 0x2a, 0x2, 0x0, 0x2b, 0x1, 0xff, 0xff, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None]This Gist brought to you by GitHub. u3-feedback-Timer0Cong.txt view raw

This IOType configures Timer1. TimerMode = See Section 2.9 for more information about the available modes. Value = The meaning of this parameter varies with the timer mode.

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(NumberOfTimersEnabled = 2) Sent: [0x4a, 0xf8, 0x3, 0xb, 0x43, 0x0, 0x1, 0x0, 0x42, 0x0, 0x0, 0x0] Response: [0x58, 0xf8, 0x3, 0xb, 0x51, 0x0, 0x0, 0x0, 0x42, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 2, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 66, 'EnableCounter1' >>> d.getFeedback(u3.Timer1Config(TimerMode = 6, Value = 1)) Sent: [0x30, 0xf8, 0x3, 0x0, 0x34, 0x0, 0x0, 0x2d, 0x6, 0x1, 0x0, 0x0] Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [None]This Gist brought to you by GitHub. u3-feedback-Timer1Cong.txt view raw

5.2.5.17 - Counter#: IOType=54,55

52

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. Reset: Setting this bit resets the counter to 0 after reading. Counter: Returns the current count from the counter if enabled. This is the value before reset (if reset was done).

LabJackPython example sessionAutomatically extracted from u3.py. Debugging turned on to show the bytes sent and received. Counter Feedback command Reads a hardware counter, optionally resetting it counter: 0 or 1 Reset: True ( or 1 ) = Reset, False ( or 0 ) = Don't Reset

Returns the current count from the counter if enabled. If reset, this is the value before the reset. >>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(EnableCounter0 = True, FIOAnalog = 15) Sent: [0x5f, 0xf8, 0x3, 0xb, 0x58, 0x0, 0x5, 0x0, 0x44, 0x0, 0xf, 0x0] Response: [0x5a, 0xf8, 0x3, 0xb, 0x53, 0x0, 0x0, 0x0, 0x44, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 0, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 68, 'EnableCounter1' >>> d.getFeedback(u3.Counter(counter = 0, Reset = False)) Sent: [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0] Response: [0xfc, 0xf8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [0] >>> # Tap a ground wire to counter 0 >>> d.getFeedback(u3.Counter(counter = 0, Reset = False)) Sent: [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0] Response: [0xe9, 0xf8, 0x4, 0x0, 0xec, 0x0, 0x0, 0x0, 0x0, 0xe8, 0x4, 0x0, 0x0, 0x0] [1256]This Gist brought to you by GitHub. u3-feedback-Counter.txt view raw

Counter0 Feedback command Reads hardware counter0, optionally resetting it Reset: True ( or 1 ) = Reset, False ( or 0 ) = Don't Reset Returns the current count from the counter if enabled. this is the value before the reset. If reset,

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(EnableCounter0 = True, FIOAnalog = 15) Sent: [0x5f, 0xf8, 0x3, 0xb, 0x58, 0x0, 0x5, 0x0, 0x44, 0x0, 0xf, 0x0] Response: [0x5a, 0xf8, 0x3, 0xb, 0x53, 0x0, 0x0, 0x0, 0x44, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 0, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 68, 'EnableCounter1' >>> d.getFeedback(u3.Counter0( Reset = False ) ) Sent: [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0] Response: [0xfc, 0xf8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [0] >>> # Tap a ground wire to counter 0 >>> d.getFeedback(u3.Counter0(Reset = False)) Sent: [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0] Response: [0xe, 0xf8, 0x4, 0x0, 0x11, 0x0, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x0] [17] >>> # Tap a ground wire to counter 0 >>> d.getFeedback(u3.Counter0(Reset = False)) Sent: [0x31, 0xf8, 0x2, 0x0, 0x36, 0x0, 0x0, 0x36, 0x0, 0x0] Response: [0x19, 0xf8, 0x4, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x0, 0xb, 0x11, 0x0, 0x0, 0x0] [4363]This Gist brought to you by GitHub. u3-feedback-Counter0.txt view raw

Counter1 Feedback command Reads hardware counter1, optionally resetting it Reset: True ( or 1 ) = Reset, False ( or 0 ) = Don't Reset Returns the current count from the counter if enabled. this is the value before the reset. If reset,

>>> import u3 >>> d = u3.U3() >>> d.debug = True >>> d.configIO(EnableCounter1 = True, FIOAnalog = 15) Sent: [0x63, 0xf8, 0x3, 0xb, 0x5c, 0x0, 0x5, 0x0, 0x48, 0x0, 0xf, 0x0] Response: [0x5e, 0xf8, 0x3, 0xb, 0x57, 0x0, 0x0, 0x0, 0x48, 0x0, 0xf, 0x0] {'NumberOfTimersEnabled': 0, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 15, 'EIOAnalog': 0, 'TimerCounterConfig': 72, 'EnableCounter1' >>> d.getFeedback(u3.Counter1(Reset = False))

53

Sent: [0x32, 0xf8, 0x2, 0x0, 0x37, 0x0, 0x0, 0x37, 0x0, 0x0] Response: [0xfc, 0xf8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] [0] >>> # Tap a ground wire to counter 1 >>> d.getFeedback(u3.Counter1(Reset = False)) Sent: [0x32, 0xf8, 0x2, 0x0, 0x37, 0x0, 0x0, 0x37, 0x0, 0x0] Response: [0xfd, 0xf8, 0x4, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0] [1] >>> # Tap a ground wire to counter 1 >>> d.getFeedback(u3.Counter1(Reset = False)) Sent: [0x32, 0xf8, 0x2, 0x0, 0x37, 0x0, 0x0, 0x37, 0x0, 0x0] Response: [0xb4, 0xf8, 0x4, 0x0, 0xb7, 0x0, 0x0, 0x0, 0x0, 0x6b, 0x2b, 0x21, 0x0, 0x0] [2173803]This Gist brought to you by GitHub. u3-feedback-Counter1.txt view raw

5.2.5.18 - Buzzer: IOType=63Buzzer, 6 Command Bytes: 0 IOType = 63 1 Bit 0: Continuous 2 Period LSB 3 Period MSB 4 Toggles LSB 5 Toggles MSB 0 Response Bytes:

This IOType is used to make the buzzer buzz. The buzzer is only available on hardware revisions 1.20 and 1.21, not on 1.30. Continuous: If this bit is set, the buzzer will toggle continuously. Period: This value determines how many main firmware loops the processor will execute before toggling the buzzer voltage. Toggles: If Continuous is false, this value specifies how many times the buzzer will toggle.

5.2.6 - ReadMem (ReadCal)Reads 1 block (32 bytes) from the non-volatile user or calibration memory. Command number 0x2A accesses the user memory area which consists of 256 bytes (block numbers 0-7). Command number 0x2D accesses the calibration memory area consisting of 512 bytes (block numbers 0-15), of which the last 8 blocks are not used. Do not call this function while streaming.Command: Byte 0 1 2 3 4 5 6 7 Response: Byte 0 1 2 3 4 5 6 7 8-39

Checksum8 0xF8 0x01 0x2A (0x2D) Checksum16 (LSB) Checksum16 (MSB) 0x00 BlockNum

Checksum8 0xF8 0x11 0x2A (0x2D) Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00 32 Bytes of Data

5.2.7 - WriteMem (WriteCal)Writes 1 block (32 bytes) to the non-volatile user or calibration memory. Command number 0x28 accesses the user memory area which consists of 256 bytes (block numbers 0-7). Command number 0x2B accesses the calibration memory area consisting of 512 bytes (block numbers 0-15), of which the last 8 blocks are not used. Memory must be erased before writing. Do not call this function while streaming.Command: Byte 0 1 2 3 4 5 6 7 8-39 Response: Byte 0 1 2 3 4 5 6 7

Checksum8 0xF8 0x11 0x28 (0x2b) Checksum16 (LSB) Checksum16 (MSB) 0x00 BlockNum 32 Bytes of Data

Checksum8 0xF8 0x01 0x28 (0x2B) Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00

5.2.8 - EraseMem (EraseCal)The U3 uses flash memory that must be erased before writing. Command number 0x29 erases the entire user memory area. Command number 0x2C erases the entire calibration memory area. The EraseCal command has two extra constant bytes, to

54

make it more difficult to call the function accidentally. Do not call this function while streaming.Command: Byte 0 1 2 3 4 5 (6) (7) Response: Byte 0 1 2 3 4 5 6 7 Checksum8 0xF8 0x01 0x29 ( 0x2C ) Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00

Checksum8 0xF8 0x00 ( 0x01 ) 0x29 ( 0x2C ) Checksum16 (LSB) Checksum16 (MSB) (0x4C) (0x6C)

5.2.9 - ResetCauses a soft or hard reset. A soft reset consists of re-initializing most variables without re-enumeration. A hard reset is a reboot of the processor and does cause re-enumeration.Command: Byte 0 1 2

Checksum8 0x99 ResetOptions Bit 1: Hard Reset Bit 0: Soft Reset

3 Response: Byte 0 1 2 3

0x00

Checksum8 0x99 0x00 Errorcode

5.2.10 - StreamConfigStream mode operates on a table of channels that are scanned at the specified scan rate. Before starting a stream, you need to call this function to configure the table and scan clock. Requires U3 hardware version 1.21.Command: Byte 0 1 2 3 4 5 6 7 8 9

10-11 12 13

Checksum8 0xF8 NumChannels + 3 0x11 Checksum16 (LSB) Checksum16 (MSB) NumChannels SamplesPerPacket (1-25) Reserved ScanConfig Bit 7: Reserved Bit 6: Reserved Bit 3: Internal stream clock frequency. b0: 4 MHz b1: 48 MHz Bit 2: Divide Clock by 256 Bits 0-1: Resolution b00: 12.8-bit effective b01: 11.9-bit effective b10: 11.3-bit effective b11: 10.5-bit effective Scan Interval (1-65535) PChannel NChannel

Repeat 12-13 for each channel Response: Byte 0 1 2 3 4 5 6 7 Checksum8 0xF8 0x01 0x11 Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00

NumChannels: This is the number of channels you will sample per scan (1-25). SamplesPerPacket: Specifies how many samples will be pulled out of the U3 FIFO buffer and returned per data read packet. For faster stream speeds, 25 samples per packet are required for data transfer efficiency. A small number of samples per packet would be desirable for low-latency data retrieval. Note that this parameter is not necessarily the same as the number of channels per scan. Even if only 1 channel is being scanned, SamplesPerPacket will usually be set to 25, so there are usually multiple scans per packet. ScanConfig: Has bits to specify the stream bas clock and effective resolution. ScanInterval: (1-65535) This value divided by the clock frequency defined in the ScanConfig parameter, gives the interval (in seconds) between scans. PChannel/NChannel: For each channel, these two parameters specify the positive and negative voltage measurement point. PChannel is 0-7 for FIO0-FIO7, 8-15 for EIO0-EIO15, 30 for temp sensor, 31 for Vreg, or 193.-224 for digital/timer/counter channels. NChannel is 0-7 for FIO0-FIO7, 8-15 for EIO0-EIO15, 30 for Vref, or 31 for single-ended.

55

5.2.11 - StreamStartOnce the stream settings are configured, this function is called to start the stream. Requires U3 hardware version 1.21.Command: Byte 0 1 Response: Byte 0 1 2 3

0xA8 0xA8

Checksum8 0xA9 Errorcode 0x00

5.2.12 - StreamDataAfter starting the stream, the data will be sent as available in the following format. Reads oldest data from buffer. Requires U3 hardware version 1.21.Response: Byte 0 1 2 3 4 5 6-9 10 11 12-13 62 (max) 63 (max)

Checksum8 0xF9 4 + SamplesPerPacket 0xC0 Checksum16 (LSB) Checksum16 (MSB) TimeStamp PacketCounter Errorcode Sample0 Backlog 0x00

SamplesPerPacket: From StreamConfig function. TimeStamp: Not currently implemented during normal operation, but after auto-recovery bytes 6-7 reports the number of packets missed (1-65535). PacketCounter: An 8-bit (0-255) counter that is incremented by one for each packet of data. Useful to make sure packets are in order and no packets are missing. Sample#: Stream data is placed in a FIFO (first in first out) buffer, so Sample0 is the oldest data read from the buffer. The analog input reading is returned justified as a 16-bit value. Differential readings are signed, while single-ended readings are unsigned. Backlog: When streaming, the processor acquires data at precise intervals, and transfers it to a FIFO buffer until it can be sent to the host. This value represents how much data is left in the buffer after this read. The value ranges from 0-255, where 256 would equal 100% full. Stream mode on the U3 uses a feature called auto-recovery. If the stream buffer gets too full, the U3 will go into auto-recovery mode. In this mode, the U3 no longer stores new scans in the buffer, but rather new scans are discarded. Data already in the buffer will be sent until the buffer contains less samples than SamplesPerPacket, and every StreamData packet will have errorcode 59. Once the stream buffer contains less samples than SamplesPerPacket, the U3 will start to buffer new scans again. The next packet returned will have errorcode 60. This packet will have 1 dummy scan where each sample is 0xFFFF, and this scan separates new data from any pre auto-recovery data. Note that the dummy scan could be at the beginning, middle, or end of this packet, and can even extend to following packets. Also, the TimeStamp parameter in this packet contains the number of scans that were discarded, allowing correct time to be calculated. The dummy scan counts as one of the missing scans included in the TimeStamp value.

5.2.13 - StreamStopRequires U3 hardware version 1.21.Command: Byte 0 1 Response: Byte 0 1 2 3

0xB0 0xB0

Checksum8 0xB1 Errorcode 0x00

5.2.14 - WatchdogRequires U3 hardware version 1.21. Controls a firmware based watchdog timer. Unattended systems requiring maximum up-time might use this capability to reset the U3 or the entire system. When any of the options are enabled, an internal timer is enabled which resets on any incoming USB communication. If this timer reaches the defined TimeoutPeriod before being reset, the specified actions will occur. Note that while streaming, data is only going out, so some other command will have to be called periodically to reset the watchdog timer. If the watchdog is accidentally configured to reset the processor with a very low timeout period (such as 1 second), it could be difficult to establish any communication with the device. In such a case, the reset-to-default jumper can be used to turn off the watchdog (sets bytes 7-10 to 0). Power up the U3 with a short from FIO6 to SPC (FIO2 to SCL on U3 1.20/1.21), then remove the jumper and power cycle the device again. This also affects the parameters in the ConfigU3 function. The watchdog settings (bytes 7-10) are stored in non-volatile flash memory, so every call to this function where settings are written causes a flash erase/write. The flash has a rated endurance of at least 20000 writes, which is plenty for reasonable operation, but if this function is called in a high-speed loop the flash could be damaged. Note: Do not call this function while streaming.

56

Command: Byte 0 1 2 3 4 5 6 7

Checksum8 0xF8 0x05 0x09 Checksum16 (LSB) Checksum16 (MSB) WriteMask Bit 0: Write WatchdogOptions Bit 5: Reset on Timeout Bit 4: Set DIO State on Timeout

8-9 10

TimeoutPeriod DIOConfig Bit 7: State Bit 0-4: DIO#

11 12 13 14 15 Response: Byte 0 1 2 3 4 5 6 7 8-9 10 11 12 13 14 15

Reserved Reserved Reserved Reserved Reserved

Checksum8 0xF8 0x05 0x09 Checksum16 (LSB) Checksum16 (MSB) Errorcode WatchdogOptions TimeoutPeriod DIOConfig Reserved Reserved Reserved Reserved Reserved

WatchdogOptions: The watchdog is enabled when this byte is nonzero. Set the appropriate bits to reset the device and/or update the state of 1 digital output. TimeoutPeriod: The watchdog timer is reset to zero on any incoming USB communication. Note that most functions consist of a write and read, but StreamData is outgoing only and does not reset the watchdog. If the watchdog timer is not reset before it counts up to TimeoutPeriod, the actions specified by WatchdogOptions will occur. The watchdog timer has a clock rate of about 1 Hz, so a TimeoutPeriod range of 1-65535 corresponds to about 1 to 65535 seconds. DIOConfig: Determines which digital I/O is affected by the watchdog, and the state it is set to. The specified DIO must have previously been configured for output. DIO# is a value from 0-19 according to the following: 0-7 => FIO0-FIO7, 8-15 => EIO0EIO7, 16-19 => CIO0-CIO3

5.2.15 - SPIRequires U3 hardware version 1.21. Sends and receives serial data using SPI synchronous communication.Command: Byte 0 1 2 3 4 5 6

Checksum8 0xF8 4 + NumSPIWords 0x3A Checksum16 (LSB) Checksum16 (MSB) SPIOptions Bit 7: AutoCS Bit 6: DisableDirConfig Bits 1-0: SPIMode (0=A, 1=B, 2=C, 3=D)

7 8 9 10 11 12 13 14 ... Response: Byte 0 1 2 3 4 5 6 7 8 ...

SPIClockFactor Reserved CSPinNum CLKPinNum MISOPinNum MOSIPinNum NumSPIBytesToTransfer SPIByte0 ...

Checksum8 0xF8 1 + NumSPIWords 0x3A Checksum16 (LSB) Checksum16 (MSB) Errorcode NumSPIBytesTransferred SPIByte0 ...

NumSPIWords: This is the number of SPI bytes divided by 2. If the number of SPI bytes is odd, round up and add an extra zero to the packet. SPIOptions: If AutoCS is true, the CS line is automatically driven low during the SPI communication and brought back high when done. If DisableDirConfig is true, this function does not set the direction of the lines, whereas if it is false the lines are configured as CS=output, CLK=output, MISO=input, and MOSI=output. SPIMode specifies the standard SPI mode as discussed below. SPIClockFactor: Sets the frequency of the SPI clock. A zero corresponds to the maximum speed of about 80kHz and 255 the minimum speed of about 5.5kHz. CS/CLK/MISO/MOSI -PinNum: Assigns which digital I/O line is used for each SPI line. Value passed is 0-19 corresponding to the normal digital I/O numbers as specified in Section 2.8. NumSPIBytesToTransfer: Specifies how many SPI bytes will be transferred (1-50). The initial state of SCK is set properly (CPOL), by this function, before CS (chip select) is brought low (final state is also set properly before CS is brought high again). If CS is being handled manually, outside of this function, care must be taken to make

57

sure SCK is initially set to CPOL before asserting CS. All standard SPI modes supported (A, B, C, and D). Mode A: CPHA=0, CPOL=0 Mode B: CPHA=0, CPOL=1 Mode C: CPHA=1, CPOL=0 Mode D: CPHA=1, CPOL=1 If Clock Phase (CPHA) is 1, data is valid on the edge going to CPOL. If CPHA is 0, data is valid on the edge going away from CPOL. Clock Polarity (CPOL) determines the idle state of SCK. Up to 50 bytes can be written/read. Communication is full duplex so 1 byte is read at the same time each byte is written.

5.2.16 - AsynchConfigRequires U3 hardware version 1.21+. Configures the U3 UART for asynchronous communication. On hardware version 1.30 the TX (transmit) and RX (receive) lines appear on FIO/EIO after any timers and counters, so with no timers/counters enabled, and pin offset set to 4, TX=FIO4 and RX=FIO5. On hardware version 1.21, the UART uses SDA for TX and SCL for RX. Communication is in the common 8/n/1 format. Similar to RS232, except that the logic is normal CMOS/TTL. Connection to an RS232 device will require a converter chip such as the MAX233, which inverts the logic and shifts the voltage levels.Command: Byte 0 1 2 3 4 5 6 7

Checksum8 0xF8 0x02 0x14 Checksum16 (LSB) Checksum16 (MSB) 0x00 AsynchOptions Bit 7: Update Bit 6: UARTEnable Bit 5: Reserved

8 9

BaudFactor LSB (1.30 only) BaudFactor MSB

Response: Byte 0 1 2 3 4 5 6 7 8 9

Checksum8 0xF8 0x02 0x14 Checksum16 (LSB) Checksum16 (MSB) Errorcode AsynchOptions BaudFactor LSB (1.30 only) BaudFactor MSB

AsynchOptions: Bit 7: Update If true, the new parameters are written (otherwise just a read is done). Bit 6: UARTEnable If true, the UART module is enabled. Note that no data can be transfered until pins have been assigned to the UART module using the ConfigIO function. BaudFactor16 (BaudFactor8): This 16-bit value sets the baud rate according the following formula: BaudFactor16 = 216 48000000/(2 x Desired Baud). For example, a BaudFactor16 = 63036 provides a baud rate of 9600 bps. (With hardware revision 1.21, the value is only 8-bit and the formula is BaudFactor8 = 28 TimerClockBase/(Desired Baud) ).

5.2.17 - AsynchTXRequires U3 hardware version 1.21. Sends bytes to the U3 UART which will be sent asynchronously on the transmit line.Command: Byte 0 1 2 3 4 5 6 7 8 ... Response: Byte 0 1 2 3 4 5 6 7 8 9

Checksum8 0xF8 1 + NumAsynchWords 0x15 Checksum16 (LSB) Checksum16 (MSB) 0x00 NumAsynchBytesToSend AsynchByte0 ...

Checksum8 0xF8 0x02 0x15 Checksum16 (LSB) Checksum16 (MSB) Errorcode NumAsynchBytesSent NumAsynchBytesInRXBuffer 0x00

NumAsynchWords: This is the number of asynch data bytes divided by 2. If the number of bytes is odd, round up and add an extra zero to the packet. NumAsynchBytesToSend: Specifies how many bytes will be sent (0-56). NumAsynchBytesInRXBuffer: Returns how many bytes are currently in the RX buffer.

5.2.18 - AsynchRXRequires U3 hardware version 1.21. Reads the oldest 32 bytes from the U3 UART RX buffer (received on receive terminal). The buffer holds 256 bytes.

58

Command: Byte 0 1 2 3 4 5 6 7 Response: Byte 0 1 2 3 4 5 6 7 8 ... 39

Checksum8 0xF8 0x01 0x16 Checksum16 (LSB) Checksum16 (MSB) 0x00 Flush

Checksum8 0xF8 1 + NumAsynchWords 0x15 Checksum16 (LSB) Checksum16 (MSB) Errorcode NumAsynchBytesInRXBuffer AsynchByte0 ... AsynchByte31

Flush: If nonzero, the entire 256-byte RX buffer is emptied. If there are more than 32 bytes in the buffer that data is lost. NumAsynchBytesInRXBuffer: Returns the number of bytes in the buffer before this read. AsynchByte#: Returns the 32 oldest bytes from the RX buffer.

5.2.19 - ICRequires U3 hardware version 1.21+. Sends and receives serial data using IC (I2C) synchronous communication.Command: Byte 0 1 2 3 4 5 6

Checksum8 0xF8 4 + NumI2CWordsSend 0x3B Checksum16 (LSB) Checksum16 (MSB) I2COptions Bits 7-4: Reserved Bit 3: Enable Clock Stretching Bit 2: No Stop when restarting Bit 1: ResetAtStart Bit 0: Reserved

7 8 9 10 11 12 13 14 ...

SpeedAdjust SDAPinNum SCLPinNum AddressByte Reserved NumI2CBytesToSend NumI2CBytesToReceive I2CByte0 ...

Response: Byte 0 1 2 3 4 5 6 7 8 9 10 11 12 ...

Checksum8 0xF8 3+ NumI2CWordsReceive 0x3B Checksum16 (LSB) Checksum16 (MSB) Errorcode Reserved AckArray0 AckArray1 AckArray2 AckArray3 I2CByte0 ...

NumI2CWordsSend: This is the number of IC bytes to send divided by 2. If the number of bytes is odd, round up and add an extra zero to the packet. This parameter is actually just to specify the size of this packet, as the NumI2CbytesToSend parameter below actually specifies how many bytes will be sent. I2COptions: If ResetAtStart is true, an IC bus reset will be done before communicating. SpeedAdjust: Allows the communication frequency to be reduced. 0 is the maximum speed of about 150 kHz. 20 is a speed of about 70 kHz. 255 is the minimum speed of about 10 kHz. SDAP/SCLP -PinNum: Assigns which digital I/O line is used for each IC line. Value passed is 0-19 corresponding to the normal digital I/O numbers as specified in Section 2.8. Note that the screw terminals labeled SDA and SCL on hardware revision 1.20 or 1.21 are not used for IC. Note that the IC bus generally requires pull-up resistors of perhaps 4.7 k from SDA to Vs and SCL to Vs. AddressByte: This is the first byte of data sent on the IC bus. The upper 7 bits are the address of the slave chip and bit 0 is the read/write bit. Note that the read/write bit is controlled automatically by the LabJack, and thus bit 0 is ignored. NumI2CBytesToSend: Specifies how many IC bytes will be sent (0-50). NumI2CBytesToReceive: Specifies how many IC bytes will be read (0-52). I2Cbyte#: In the command, these are the bytes to send. In the response, these are the bytes read. NumI2CWordsReceive: This is the number of IC bytes to receive divided by 2. If the number of bytes is odd, the value is rounded up and an extra zero is added to the packet. This parameter is actually just to specify the size of this packet, as the NumI2CbytesToReceive parameter above actually specifies how many bytes to read. AckArray#: Represents a 32-bit value where bits are set if the corresponding IC write byte was acked. Useful for debugging up to the first 32 write bytes of communication. Bit 0 corresponds to the last data byte, bit 1 corresponds to the second to last data byte, and so on up to the address byte. So if n is the number of data bytes, the ACKs value should be (2^(n+1))-1.

5.2.20 - SHT1XRequires U3 hardware version 1.21. Reads temperature and humidity from a Sensirion SHT1X sensor (which is used by the EI-

59

1050). For more information, see the EI-1050 datasheet, and the SHT1X datasheet from sensirion.com.Command: Byte 0 1 2 3 4 5 6 7 8 9 Response: Byte 0 1 2 3 4 5 6 7 8 9 10-11 12 13-14 15

Checksum8 0xF8 0x02 0x39 Checksum16 (LSB) Checksum16 (MSB) DataPinNum (0-19) ClockPinNum (0-19) Reserved Reserved

Checksum8 0xF8 0x05 0x39 Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00 StatusReg StatusRegCRC Temperature TemperatureCRC Humidity HumidityCRC

Data/Clock -PinNum: Assigns which digital I/O line is used for each SPI line. Value passed is 0-7 corresponding to FIO0FIO7. State and direction are controlled automatically for the specified lines. StatusReg: Returns a read of the SHT1X status register. Temperature: Returns the raw binary temperature reading. Humidity: Returns the raw binary humidity reading. #CRC: Returns the CRC values from the sensor.

5.2.21 - SetDefaults (SetToFactoryDefaults)Executing this function causes the current or last used values (or the factory defaults) to be stored in flash as the power-up defaults. The U3 flash has a rated endurance of at least 20000 writes, which is plenty for reasonable operation, but if this function is called in a high-speed loop the flash could eventually be damaged. Note: Do not call this function while streaming.Command: Byte 0 1 2 3 4 5 6 7 Response: Byte 0 1 2 3 4 5 6 7

Checksum8 0xF8 0x01 0x0E Checksum16 (LSB) Checksum16 (MSB) 0xBA (0x82) 0x26 (0xC7)

Checksum8 0xF8 0x01 0x0E Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00

5.2.22 - ReadDefaults (ReadCurrent)Reads the power-up defaults from flash (Read the current configuration).

60

Command: Byte 0 1 2 3 4 5 6 7

Checksum8 0xF8 0x01 0x0E Checksum16 (LSB) Checksum16 (MSB) 0x00 bits[0:6] BlockNum 0-7 bit 7: 1 = ReadCurrent

Response: Byte 0 1 2 3 4 5 6 7 8-39

Checksum8 0xF8 0x01 0x0E Checksum16 (LSB) Checksum16 (MSB) Errorcode 0x00 Data

Defaults Map Block Number Byte Offset Description Nominal Values 0 0-3 Not Used 0x00 0 4 FIO Directions 0x00 0 5 FIO States 0xFF 0 6 FIO Analog 0x00 0 7 Not Used 0x00 0 8 EIO Directions 0x00 0 9 EIO States 0xFF 0 10 EIO Analog 0x00 0 11 Not Used 0x00 0 12 CIO Directions 0x00 0 13 CIO States 0xFF 0 14-15 Not Used 0x00 0 16 Config Write Mask 0x00 (NM) 0 17 NumOfTimersEnabled 0x00 0 18 Counter Mask 0x00 0 19 Pin Offset 0x04 0 20 Options 0x00 0 21-31 Not Used 0x00 1 0 (32) Clock_Source 0x02 1 1 (33) Divisor 0x00 1 2-15 (33-47) Not Used 0x00 1 16 (48) TMR0 Mode 0x0A 1 17 (49) TMR0 Value L 0x00 1 18 (50) TMR0 Value H 0x00 1 19 (51) Not Used 0x00 1 20 (52) TMR1 Mode 0x0A 1 21 (53) TMR1 Value L 0x00 1 22 (54) TMR1 Value H 0x00 1 23-31 (55-63) Not Used 0x00 2 0-15 (64-79) Not Used 0x00 2 16-17 (80-81) DAC0 (2 Bytes) 0x0000 2 18-19 (82-83) Not Used 0x00 2 20-21 (84-85) DAC1 (2 Bytes) 0x0000 2 22-31 (86-95) Not Used 0x00 3 0-15 (96-111) AIN Neg Channel 0x1F 3 16-31 (112-127) Not Used 0x00

5.3 - ErrorcodesFollowing is a list of the low-level function errorcodes.

61

Code 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23 24 25 26 27 28 29 40 41 42 43 44 45 46 48 49 50 51 52 53 54 55 56 57 58 59 60 63 64 65 66 67 68 69 70 71 72 80 81 82 96 97 98 99 100 101 102 112 113 114

Description SCRATCH_WRT_FAIL SCRATCH_ERASE_FAIL DATA_BUFFER_OVERFLOW ADC0_BUFFER_OVERFLOW FUNCTION_INVALID SWDT_TIME_INVALID XBR_CONFIG_ERROR FLASH_WRITE_FAIL FLASH_ERASE_FAIL FLASH_JMP_FAIL FLASH_PSP_TIMEOUT FLASH_ABORT_RECEIVED FLASH_PAGE_MISMATCH FLASH_BLOCK_MISMATCH FLASH_PAGE_NOT_IN_CODE_AREA MEM_ILLEGAL_ADDRESS FLASH_LOCKED INVALID_BLOCK FLASH_ILLEGAL_PAGE FLASH_TOO_MANY_BYTES FLASH_INVALID_STRING_NUM SHT1x_COMM_TIME_OUT SHT1x_NO_ACK SHT1x_CRC_FAILED SHT1X_TOO_MANY_W_BYTES SHT1X_TOO_MANY_R_BYTES SHT1X_INVALID_MODE SHT1X_INVALID_LINE STREAM_IS_ACTIVE STREAM_TABLE_INVALID STREAM_CONFIG_INVALID STREAM_BAD_TRIGGER_SOURCE STREAM_NOT_RUNNING STREAM_INVALID_TRIGGER STREAM_ADC0_BUFFER_OVERFLOW STREAM_SCAN_OVERLAP STREAM_SAMPLE_NUM_INVALID STREAM_BIPOLAR_GAIN_INVALID STREAM_SCAN_RATE_INVALID STREAM_AUTORECOVER_ACTIVE STREAM_AUTORECOVER_REPORT STREAM_AUTORECOVER_OVERFLOW TIMER_INVALID_MODE TIMER_QUADRATURE_AB_ERROR TIMER_QUAD_PULSE_SEQUENCE TIMER_BAD_CLOCK_SOURCE TIMER_STREAM_ACTIVE TIMER_PWMSTOP_MODULE_ERROR TIMER_SEQUENCE_ERROR TIMER_LINE_SEQUENCE_ERROR TIMER_SHARING_ERROR EXT_OSC_NOT_STABLE INVALID_POWER_SETTING PLL_NOT_LOCKED INVALID_PIN PIN_CONFIGURED_FOR_ANALOG PIN_CONFIGURED_FOR_DIGITAL IOTYPE_SYNCH_ERROR INVALID_OFFSET IOTYPE_NOT_VALID TC_PIN_OFFSET_MUST_BE_4-8 UART_TIMEOUT UART_NOT_CONNECTED UART_NOT_ENABLED

5.4 - Calibration ConstantsCalibration Constant The majority of the U3's analog interface functions return or require binary values. Converting between binary and voltages requires the use of calibration constants and formulas. When using ModBus the U3 will apply calibration automatically, so voltages are sent to and read from the U3, formatted as a float.

Which Constants Should I Use? The calibration constants stored on the U3 can be categorized as follows: Analog Input Analog Output Internal Temperature

Analog Input: Since the U3 uses multiplexed channels connected to a single analog-to-digital converter (ADC), all low-voltage channels have the same calibration for a given configuration. High-voltage channels have individual scaling circuitry out front, and thus the calibration is unique for each channel. The table below shows where the various calibration values are stored in the Mem area. Generally when communication is initiated with the U3, four calls will be made to the ReadMem function to retrieve the first 4 blocks of memory. This information can then be used to convert all analog input readings to voltages. Again, the high level Windows DLL (LabJackUD) does this automatically. Analog Output: Only two calibrations are provided, one for DAC0 and one for DAC1. Internal Temperature: This calibration is applied to the bits of a reading from channel 30 (internal temp).

U3 Input Ranges The U3 input ranges can be found in section 2.6.2 of the User's Guide. For your convenience, that table has been provided again below.

62

Max V Min V Single-Ended 2.44 0 Differential 2.44 -2.44 Special 0-3.6 3.6 0 Table 2.6.2-1. Nominal Analog Input Voltage Ranges for Low-Voltage Channels Max V Single-Ended 10.3 Differential N/A Special -10/+20 20.1 Table 2.6.2-2. Nominal Analog Min V -10.3 N/A -10.3 Input Voltage Ranges for High-Voltage Channels

U3 Calibration Formulas (Analog In) The readings returned by the analog inputs are raw binary values (low level functions). An approximate voltage conversion can be performed as:Volts(uncalibrated) = (Bits/65536)*Span (Single-Ended) Volts(uncalibrated) = (Bits/65536)*Span Span/2 (Differential)

Where span is the maximum voltage minus the minimum voltage from the table above. For a proper voltage conversion, though, use the calibration values (Slope and Offset) stored in the internal flash on the Control processor.Volts = (Slope * Bits) + Offset

U3 Calibration Formulas (Analog Out) Writing to the U3's DAC require that the desired voltage be converted into a binary value. To convert the desired voltage to binary select the Slope and Offset calibration constants for the DAC being used and plug into the following formula.Bits = (DesiredVolts * Slope) + Offset

U3 Calibration Formulas (Internal Temp) Internal Temperature can be obtained by reading channel 30 and using the following formula.Temp (K) = Bits * TemperatureSlope

U3 Calibration Constants Below are the various calibration values are stored in the Mem area. Generally when communication is initiated with the U3, eight calls will be made to the ReadMem function to retrieve the first 8 blocks of memory. This information can then be used to convert all analog input readings to voltages. Again, the high level Windows DLL (LabJackUD) does this automatically.

Starting Block # Byte Nominal Value 0 0 LV AIN SE Slope 3.7231E-05 volts/bit 0 8 LV AIN SE Offset 0.0000E+00 volts 0 16 LV AIN Diff Slope 7.4463E-05 volts/bit 0 24 LV AIN Diff Offset -2.4400E+00 volts 1 0 DAC0 Slope 5.1717E_01 bits/volt 1 8 DAC0 Offset 0.0000E+00 bits 1 16 DAC1 Slope 5.1717E+1 bits/volt 1 24 DAC1 Offset 0.0000E+00 bits 2 0 Temp Slope 1.3021E-02 degK/bit 2 8 Vref @Cal 2.4400E+00 volts 2 16 Vref*1.5 @Cal 3.6600E+00 volts 2 24 Vreg @Cal 3.3000E+00 volts Table 5.4-1. Normal Calibration Constant Memory Locations Starting Block # Byte Nominal Value 3 0 HV AIN0 Slope 3.1400E-4 volts/bit 3 8 HV AIN1 Slope 3.1400E-4 volts/bit 3 16 HV AIN2 Slope 3.1400E-4 volts/bit 3 24 HV AIN3 Slope 3.1400E-4 volts/bit 4 0 HV AIN0 Offset -10.3 volts 4 8 HV AIN1 Offset -10.3 volts 4 16 HV AIN2 Offset -10.3 volts 4 24 HV AIN3 Offset -10.3 volts Table 5.4-2. Additional High-Voltage Calibration Constant Memory Locations

Format of the Calibration Constants Each value is stored in 64-bit fixed point format (signed 32.32 little endian, 2's complement). Following are some examples of fixed point arrays and the associated floating point double values.Fixed Point Byte Array {LSB, ..., MSB} Floating Point Double {0,0,0,0,0,0,0,0} 0.0000000000 {0,0,0,0,1,0,0,0} 1.0000000000 {0,0,0,0,255,255,255,255} -1.0000000000 {51,51,51,51,0,0,0,0} 0.2000000000 {205,204,204,204,255,255,255,255,255} -0.2000000000 {73,20,5,0,0,0,0,0} 0.0000775030 {255,122,20,110,2,0,0,0} 2.4300000000 {102,102,102,38,42,1,0,0} 298.1500000000 Table 5.4-3. Fixed Point Conversion Examples

63

Appendix A - SpecificationsSpecifications at 25 degrees C and Vusb/Vext = 5.0V, except where noted.Parameter General USB Cable Length Supply Voltage Supply Current (1) Operating Temperature Clock Error Typ. Command Execution Time (2) VS Outputs Typical Voltage (3) Maximum Currrent (3) Conditions Min Typical Max 5 5.25 85 1.5 Units meters volts mA C % ms ms volts mA mA

4 Hardware V1.21+ -40 -40 to 85 C USB high-high USB other Self-Powered Bus-Powered Self-Powered Bus-Powered 0.6 4 4.75 4

5 50

5 5 450 50

5.25 5.25

(1) Typical current drawn by the U3 itself, not including any user connections. (2) Total typical time to execute a single Feedback function with no analog inputs. Measured by timing a Windows application that performs 1000 calls to the Feedback function. See Section 3.1 for more timing information. (3) These specifications are related to the power provided by the host/hub. Self- and bus-powered describes the host/hub, not the U3. Self-powered would apply to USB hubs with a power supply, all known desktop computer USB hosts, and some notebook computer USB hosts. An example of bus-powered would be a hub with no power supply, or many PDA ports. The current rating is the maximum current that should be sources through the U3 and out of the Vs terminals.

Parameter Analog Inputs Typical input Range (1)

Conditions Single-Ended, LV Differential, LV Special, LV Single-Ended, HV Special, HV Valid Readings, LV No Damage, FIO No Damage, EIO No Damage, HV LV HV LongSettling Off, LV LongSettling On, LV LongSettling Off, HV LongSettling On, HV

Min 0 -2.44 0 -10.3 -10.3 -0.3 -10 -6 -40

Typical

Max 2.44 2.44 3.6 10.3 20.1 3.6 10 6 40

Units volts volts volts volts volts volts volts volts volts M M k k k k bits % FS counts % FS % FS % FS ppm/C counts counts bits bits mV mV mV mV

Max AIN Voltage to GND (2) Max AIN Voltage to GND (3)

Input Impedance (4) Source Impedance (4)

40 1.3 10 200 1 1 12 0.05 1 0.13 0.25 0.25 15 1 2 >12 11 1.2 2.4 9.8 19.5

Resolution Integral Linearity Error Differential Linearity Error Absolute Accuracy

Single-Ended Differential Special 0-3.6 QuickSample Off QuickSample On QuickSample Off QuickSample Off Single-Ended, LV Diff., Special, LV Single-Ended, HV Special, HV See Section 3.1 See Section 3.2

Temperature Drift Noise (Peak-To-Peak) (5) Effective Resolution (RMS) (6) Noise-Free Resolution (5)

Command/Response Speed Stream Perfromance

(1) With DAC1 disabled on hardware version < 1.30 (2) This is the maximum voltage on any AIN pin compared to ground for valid measurements. Not that differential channel has a minimum voltage of -2.44 volts, meaning that the positive channel can be 2.44 volts less than the negative channel, but no AIN pin can go more than 0.3 volts below ground. (3) Maximum voltage, compared to ground, to avoid damage to the device. Protection level is the same whether the device is powered or not. (4) The low-voltage analog inputs essentially connect directly to a SAR ADC on the U3, presenting a capacitive load to the signal source. The high-voltage inputs connect first to a resistive level-shifter/divider. The key specification in both cases is the maximum source impedance. As long as the source impedance is not over this value, there will be no substantial errors due to impedance problems. (5) Measurements taken with AIN connected to a 2.048 reference (REF191 from Analog Devices) or GND. All "counts" data are aligned as 12-bit values. Noise-free data is determined by taking 128 readings and subtracting the minimum value from the maximum value. (6) Effective (RMS) data is determined from the standard deviation of 128 readings. In other words, this data represents _most_ readings, whereas noise-free data represents all readings.

Parameter Analog Outputs (DAC) Nominal Output Range (1) Resolution Absolute Accuracy Integral Linearity Error Differential Linearity Error Error Due To Loading Source Impedance Short Circuit Current (2) Slew Rate Digital I/O, Timers, Counters Low Level Input Voltage Hight Level Input Voltage Maximum Input Voltage (3) Output Low Voltage (4) --- FIO --- EIO/CIO --- EIO/CIO Output High Voltage (4) --- FIO --- EIO/CIO --- EIO/CIO Short Circuit Current (4) Output Impedance (4) Counter Input Frequency (5) Input Timer Total Edge Rate (6)

Conditions No Load @ 2.5 mA 5% to 95% FS

Min 0.04 0.225

Typical

Max 4.95 4.775

Units volts volts bits % FS counts counts % % mA V/ms volts volts volts volts volts volts volts volts volts volts volts volts mA mA MHz edges/s

@ 100 A @ 1 mA Max to GND

10 5 1 1 0.1 1 50 45 0.4 -0.3 2 -10 -6 0 0.55 0.18 0.9 3.3 2.75 3.12 2.4 6 18 550 180 8 30000 0.8 5.8 10 6

FIO EIO/CIO No Load Sinking 1 mA Sinking 1 mA Sinking 5 mA No Load Sourcing 1 mA Sourcing 1 mA Sourcing 5 mA FIO EIO/CIO FIO EIO/CIO Hardware V1.21+ No Stream, V1.21+

64

While Streaming

7000

edges/s

(1) Maximum and minimum analog output voltage is limited by the supply voltages (Vs and GND). The specifications assume Vs is 5.0 volts. Also, the ability of the DAC output bufffer to driver voltages close to the power rails, decreases with increasing output current, but in most applications the output is not sinking/sourcing much current as the output voltage approaches GND. (2) Continuous short circuit will not cause damage. (3) Maximum voltage to avoid damage to the device. Protection works whether the device is powered or not, but continuous voltages over 5.8 volts or less than -0.3 volts are not recommended when the U3 is unpowered, as the voltage will attempt to supply operating power to the U3 possible causing poor start-up behavior. (4) These specifications provide the answer to the question: "How much current can the digital I/O sink or source?". For instance, if EIO0 is configured as output-high and shorted to ground, the current sourced by EIO0 into ground will be about 18 mA (3.3/180). If connected to a load that draws 5 mA, EIO0 can provide that current but the voltage will droop to about 2.4 volts instead of the nominal 3.3 volts. If connected to a 180 ohm load to ground, the resulting voltage and current will be about 1.65 volts @ 9 mA. (5) Hardware counters. 0 to 3.3 volt square wave. Limit about 2 MHz with older hardware versions. (6) To avoid missing edges, keep the total number of applicable edges on all applicable timers below this limit. See Section 2.9 for more information. Limit about 10000 with older hardware versions.

Appendix B - Enclosure and PCB DrawingsVarious drawings follow. CAD drawings of the U3 attached to the bottom of this page (DWG, DXF, IGES, STEP).

65

U3 PCB drawing showing the coordinates (in Inches) for pin 1 of each connector. File attachment: U3 Enclosure CAD Drawings.zip

66