LabJack U12 User’s Guide Revision 1.04 11/5/2002 Meilhaus Electronic GmbH www.meilhaus.com support@meilhaus.
For the latest version of the user’s guide, the quickstart guide, or software, go to www.labjack.com. The LabJack U12 is a measurement and automation peripheral that enables the connection of a PC to the real-world. Although the LabJack U12 has various redundant protection mechanisms, it is possible, in the case of improper and/or unreasonable use, to damage the LabJack and even the PC to which it is connected. LabJack Corporation will not be liable for any such damage.
Table Of Contents 1. Installation ................................................................................................................................5 1.1 Hardware Installation..........................................................................................................5 1.2 Software Installation ...........................................................................................................5 2. Hardware Description.........................................................
Table Of Figures Figure 2-1. LabJack U12 top surface. ..........................................................................................7 Figure 2-2. Single-ended measurement.......................................................................................8 Figure 2-3. Differential measurement...........................................................................................9 Figure 2-4. Single-ended measurement with voltage divider circuit...........................................
1. Installation The LabJack U12 requires a PC running Windows 98SE, ME, 2000, or XP. To determine your operating system version, go to Start => Settings => Control Panel => System => General and make sure the version number is 4.10.2222 or higher (Win98SE=4.10.2222, WinME=4.90.3000, Win2000=5.0.2195, WinXP=5.1.XXXX). It does not matter if the hardware or software is installed first.
Virus scanners can often interfere with the installation of the LVRTE. If you have trouble running the example applications, repeat the LabJack software installation to make sure the LVRTE is installed. To test the installation, start LJtest by selecting Start => Programs => LabJack => LJtest. Make sure “Test Fixture Installed” and “Continuous” are not selected, and press the “Run” button. LJtest will step through 8 separate tests and all should pass.
2. Hardware Description The external features of the LabJack U12 are: • USB connector, • DB25 digital I/O connector, • Status LED, • 30 screw terminals. The USB connection provides power and communication. No external power supply is needed. The +5 volt connections available at various locations are outputs, do not connect a power supply. Figure 2-1. LabJack U12 top surface. Figure 2-1 shows the top surface of the LabJack U12. Not shown is the USB and DB25 connector, which are both on the top edge.
2.1 AI0 – AI7 Hardware The LabJack U12 has 8 screw terminals for analog input signals. These can be configured individually and on-the-fly as 8 single-ended channels, 4 differential channels, or combinations in between. Each input has a 12-bit resolution and an input bias current of ±90 µA. • Single-Ended: The input range for a single-ended measurement is ±10 volts.
small, but the voltage from both AI0 and AI1 to ground will have a maximum value near 170 volts, and will seriously damage the LabJack. Whether or not the ground (GND) connection is needed (Figure 2-3) will depend on the nature of Vs. Figure 2-3. Differential measurement. Figure 2-4 shows a single-ended connection used to measure the output voltage of a typical voltage-divider circuit.
Figure 2-4. Single-ended measurement with voltage divider circuit. Because the input bias current is known, as a function of input voltage, the simple voltage divider equation can be modified as follows to account for input bias current: R2 = Va / [((Vs-Va)/R1) – (8.181µ * Va) + 11.67µ] As an alternative to the equation above, Va can be buffered by a single-supply rail-to-rail operational amplifier, and the original simple voltage divider equation can be used.
sampleRate = scanRate * numChannels AIStreamRead is called periodically during a stream acquisition started by AIStreamStart. Each call retrieves multiple samples of 1-4 channels from the LabJack stream buffer, along with the states of the IO pins (read every 4 samples). Hardware-timed sample rates of up 1200 Hz are available. 2.2 AO0 & AO1 The LabJack U12 has 2 screw terminals for analog output voltages.
Figure 2-5. IO used to detect the state of a switch. While providing overvoltage/short-circuit protection, the 1.5 k Ω series resistor on each IO pin also limits the output current capability. For instance, with an output current of 1 mA, the series resistor will drop 1.5 volts, resulting in an output voltage of about 3.5 volts. Software The easy functions EDigitalIn or EDigitalOut are used to read or set the state of one digital line, and both take up to 20 ms to execute.
• • • Shorting a high output to ground (or any potential other than +5V). Shorting a low output to a nonzero voltage (such as +5V). Exceeding the voltage limits specified in Appendix A. Software The easy functions EDigitalIn or EDigitalOut are used to read or set the state of one digital line, and both take up to 20 ms to execute. The functions AOUpdate and DigitalIO are used to set the direction, set the state, and/or read the state, of each D pin.
3. Example Applications The LabJack U12 CD installs 7 example applications: LJconfig, LJcounter, LJfg, LJlogger, LJscope, LJstream, and LJtest. • LJconfig: Lists all LabJacks connected to the USB and allows the local ID to be set on each. • LJcounter: Reads the LabJack counter and provides the current frequency or count. • LJfg (Function Generator): Outputs basic waveforms on AO0 (analog output zero).
Figure 3-2. LJconfig Change Local ID Enter a new local ID between 0 and 255 and push the “Change” button. The new local ID will be written and the LabJack will be forced to re-enumerate. 3.2 LJcounter Reads the LabJack counter and provides the current frequency or count. Figure 3-3. LJcounter Figure 3-3 shows the LJcounter window: • Interval (seconds): Specifies the interval, in seconds, between calls to the DLL function “Counter”.
Figure 3-4. LJfg 3.4 LJlogger LJlogger sends and receives data in command/response mode by making 2 DLL calls to “AISample” and 1 DLL call to “AOUpdate”. It is capable of saving data to disk, writing data to an HTML page on the Internet, and performing various actions (including email) on trigger events. Figure 3-5. LJlogger The main window for LJlogger is shown in Figure 3-5. The white colored items and the “SDX” buttons are controls to be edited/selected by the user.
which display various information about the LabJack. Clicking the button labeled “Save Panel Settings” will save the current values of the controls as the default values. If SDX is activated for a given analog input, the corresponding SDX DLL will be used to determine the scaled data. Users can make their own SDX DLLs (see the source code for more information), to provide more complex scaling or scaling that depends on other analog inputs.
Figure 3-7. LJlogger Internet Configuration Figure 3-8.
Figure 3-9. LJlogger Trigger Configuration Figure 3-9 shows 9 example triggers: • Trigger #0: If the scaled data from analog input row 7 (Figure 3-5) is greater than 5, then set AO1 to 5 volts. Once triggered, there is a 10 second delay before it can be triggered again. • Trigger #1: If IO3 is high, set IO2 high. Reset delay is zero so this trigger can occur every iteration (every 0.1 seconds) if IO3 is high. • Trigger #2: If D15 is low, set D14 low.
3.5 LJscope LJscope simulates an oscilloscope by reading data from 2 analog input channels in burst mode. Figure 3-10. LJscope There are two graphs on the LJscope main window (Figure 3-10), which show voltage versus time and voltage versus frequency. Both graphs have a palette to control various features such as autoscaling and zooming: 1. 2. 3. 4. 5. 6. 7. When you press this button it locks button 3 on (autoscale) position. When you press this button it locks button 4 on (autoscale) position.
Other LJscope controls include: • Channel A/B: Select the two AI channels that will be acquired. If a differential channel, is selected, the gain selection control will appear. • Hide Channel B: When selected channel B will not be shown on the graph. • Scan Rate [Hz]: (256 to 4096) Determines the scans/second for both channels. • Number of Scans: (32 to 2048) Determines the number of scans that will be collected, and thus the total acquisition period.
Figure 3-12. LJstream Figure 3-13 shows the LJstream channel configuration window. Here you can select analog inputs and gains and enter scaling equations. Use “Test Data” to see the effect of the scaling equations (“v” column is the measured voltage and the “y” column is the output of the scaling equations). “Manual/Sampled” determines where the “Test Data” in the “v” column originates. Figure 3-13.
3.7 LJtest LJtest runs a sequence of tests on the LabJack itself. Users will generally leave “Test Fixture Installed” unselected and execute the tests with nothing connected to the LabJack (except the USB of course). Figure 3-14.
4. Programming Reference The LabJack U12 CD installs high-level drivers (ljackuw.dll), an ActiveX interface to the highlevel drivers (ljackuwx.ocx), and LabVIEW6 VIs which call all the DLL functions. The DLL and OCX are installed in the Windows System directory. If the installation program can determine the LabVIEW6 directory, it copies the LabVIEW VIs into that directory (\vi.lib\addons\) so they show up on the function palette.
4.2 EAnalogOut Easy function. This is a simplified version of AOUpdate. Sets the voltage of both analog outputs. Execution time for this function is 20 milliseconds or less. Declaration: long EAnalogOut ( long *idnum, long demo, float analogOut0, float analogOut1 ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • *idnum – Local ID, serial number, or -1 for first found. • demo – Send 0 for normal operation, >0 for demo mode.
Note that this is a simplified version of the lower level function DigitalIO, which operates on all 20 digital lines. The DLL (ljackuw) attempts to keep track of the current direction and output state of all lines, so that this easy function can operate on a single line without changing the others. When the DLL is first loaded, though, it does not know the direction and state of the lines and assumes all directions are input and output states are low.
• state – If >0, the line is set, otherwise the line is cleared. • *idnum – Returns the local ID or –1 if no LabJack is found. Outputs: 4.6 AISample Reads the voltages from 1,2, or 4 analog inputs. Also controls/reads the 4 IO ports. Execution time for this function is 20 milliseconds or less.
The “channels” and “gains” arrays are replaced with “channelsPacked” and “gainsPacked”. The OCX has a function “FourPack” which will convert 4 elements to a packed value. The packed value is determined as: element[0] + (element[1] * 2^8) + (element[2] * 2^16) + (element[3] * 2^24). The “voltages” array is replaced with 4 individual parameters.
Inputs: • • • • • • • • • • • • • • • • • *idnum – Local ID, serial number, or -1 for first found. demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack. *stateIOin – Output states for IO0-IO3. updateIO – If >0, state values will be written. Otherwise, just a read is performed. ledOn – If >0, the LabJack LED is turned on. numChannels – Number of analog input channels to read (1,2, or 4).
The “voltages” and “stateIOout” arrays are represented as strings. Floating point data is returned as 13 characters per number (XXXX.XXXXXXXX) and integers are returned as 10 characters per number (XXXXXXXXXX). Zeros are used for padding where necessary. The total number of bytes in the “voltages” string is 13*numSamples. The total number of bytes in the “stateIOout” string is 10*numScans.
• • • • • • • • • updateIO – If >0, state values will be written. Otherwise, just a read is performed. ledOn – If >0, the LabJack LED is turned on. numChannels – Number of analog input channels to read (1,2, or 4). If readCount is >0, numChannels should be 4. *channels – Pointer to an array of channel commands with at least numChannels elements. Each channel command is 0-7 for single-ended, or 8-11 for differential. *gains – Pointer to an array of gain commands with at least numChannels elements.
long timeout, float (*voltages)[4], long *stateIOout, long *reserved, long *ljScanBacklog, long *overVoltage ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • localID – Send the local ID from AIStreamStart. • numScans – Function will wait until this number of scans is available. Minimum is 1. Maximum numSamples is 4096, where numSamples is numScans * numChannels.
Declaration: long AIStreamClear ( long localID ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Input: • localID – Send the local ID from AIStreamStart/Read. 4.11 AOUpdate Sets the voltages of the analog outputs. Also controls/reads all 20 digital I/O and the counter. Execution time for this function is 20 milliseconds or less.
long demo, long trisD, long trisIO, long FAR* stateD, long FAR* stateIO, long updateDigital, long resetCounter, double FAR* count, float analogOut0, float analogOut1) 4.12 BitsToVolts Converts a 12-bit (0-4095) binary value into a LabJack voltage. Volts=((2*Bits*Vmax/4096)-Vmax)/Gain where Vmax=10 for SE, 20 for Diff. Declaration: long BitsToVolts ( long chnum, long chgain, long bits, float *volts ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • chnum – Channel index.
4.14 Counter Controls and reads the counter. The counter is disabled if the watchdog timer is enabled. Execution time for this function is 20 milliseconds or less. Declaration: long Counter ( long *idnum, long demo, long *stateD, long *stateIO, long resetCounter, long enableSTB, unsigned long *count ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • *idnum – Local ID, serial number, or -1 for first found. • demo – Send 0 for normal operation, >0 for demo mode.
• • *stateIO – Output states for IO0-IO3. updateDigital – If >0, tris and state values will be written. Otherwise, just a read is performed. • • • • • *idnum – Returns the local ID or –1 if no LabJack is found. *trisD – Returns a read of the direction registers for D0-D15. *stateD – States of D0-D15. *stateIO – States of IO0-IO3. *outputD – Returns a read of the output registers for D0-D15. Outputs: 4.16 GetDriverVersion Returns the version number of ljackuw.dll.
Inputs: • *idnum – Local ID, serial number, or -1 for first found. • *idnum – Returns the local ID or –1 if no LabJack is found. Outputs: 4.19 GetWinVersion Uses a Windows API function to get the OS version. Declaration: long GetWinVersion ( unsigned long *majorVersion, unsigned long *minorVersion, unsigned long *buildNumber, unsigned long *platformID, unsigned long *servicePackMajor, unsigned long *servicePackMinor ) Parameter Description: Returns: LabJack errorcodes or 0 for no error.
• • *powerList – Pointer to a 127 element array. Send filled with zeros. *calMatrix – Pointer to a 127 by 20 element array. Send filled with zeros. • *serialnumList – Pointer to a 127 element array where serial numbers are returned. Unused locations are filled with 9999.0. *localIDList – Pointer to a 127 element array where local ID numbers are returned. Unused locations are filled with 9999.0. *numberFound – Number of LabJacks found on the USB.
Declaration: long NoThread ( long *idnum, long noThread ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • *idnum – Local ID, serial number, or -1 for first found. • noThread – If >0, the thread will not be used. Outputs: • *idnum – Returns the local ID or –1 if no LabJack is found. 4.23 ReEnum Causes the LabJack to electrically detach from and re-attach to the USB so it will re-enumerate. The local ID and calibration constants are updated at this time.
Declaration: long Watchdog ( long *idnum, long demo, long active, long timeout, long reset, long activeD0, long activeD1, long activeD8, long stateD0, long stateD1, long stateD8 ) Parameter Description: Returns: LabJack errorcodes or 0 for no error. Inputs: • *idnum – Local ID, serial number, or -1 for first found. • demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack. • active – Enables the LabJack watchdog function.
4.27 WriteMem Writes 4 bytes to the LabJack's 8,192 byte nonvolatile memory at a specified address. The data is read back and verified after the write. Memory 0-511 is reserved for configuration and calibration data. Memory from 512-1023 is unused by the LabJack and available for the user (this corresponds to starting addresses from 512-1020). Memory 1024-8191 is used as a data buffer in hardware timed AI modes (burst and stream). Execution time for this function is 20 milliseconds or less.
long updateIO, long stateIOin ) Parameter Description: Returns: optionBits Inputs: • demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack. • ledOn – If >0, the LabJack LED is turned on. • disableCal – If >0, voltages returned will be raw readings that are not corrected using calibration constants. • transferMode – Set to 0 (automatic). • updateIO – If >0, state values will be written. Otherwise, just a read is performed.
• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 12 – Read error. 13 – Read timeout error. 14 – Write error. 15 – Turbo error. 16 – Illegal channel index. 17 – Illegal gain index. 18 – Illegal AI command. 19 – Illegal AO command. 20 – Bits out of range. 21 – Illegal number of channels. 22 – Illegal scan rate. 23 – Illegal number of samples. 24 – AI response error. 25 – LabJack RAM checksum error. 26 – AI sequence error. 27 – Maximum number of streams.
A.
Parameter IO Low Level Input Voltage High Level Input Voltage Input Leakage Current Output Short-Circuit Current (7) Output Voltage (7) D Low Level Input Voltage (8) High Level Input Voltage (8) Input Leakage Current Output Current (8) Conditions Min Typical 3 Output High No Load At 1 mA Vs - 0.4 D0 - D12 D13 - D15 D0 - D12 D13 - D15 Max Units 0.8 15 volts volts µA mA volts volts 0.8 1 Vs + 0.3 Vs + 0.3 volts volts volts volts µA mA mA volts volts ±1 3.3 Vs Vs - 1.