Skip to Navigation

Mac OS X

ljacklm driver

The high-level U12 driver for Linux and Mac OS X.  The ljacklm driver is a port of the ljackuw Windows driver and contains the same functions documented in Section 4 of the U12 User's Guide, excluding Windows specific functions such as GetWinVersion.  The driver requires the Exodriver version 2.05 or above before installation.  The Exodriver web page and download can be found here:

Exodriver

The ljacklm.zip package contains the ljacklm driver's source code, installation instructions and C example code.  For more details on the driver and the contents of the package, please refer to the README in the zip.

 

File attachment: 

Comments

No comments yet. Speak up. We're listening.

Comments

No comments yet. Speak up. We're listening.

Advanced LJFuse: Timers and Counters with Modbus

This is an advanced section. Visit it only after you’ve outgrown the material on the LJFuse page.

Requirements

This section requires LJFuse created on 9/16/2010 or later.

Timers and Counters with Modbus

In this section, we will use LJFuse with the timers and counters on a U3. By default, LJFuse does not provide an interface to timers and counters. There are no connections for them in the connection/ subdirectory, and there are no Modbus addresses for them in the modbus/ directory. What we will do in this section is create the files in the modbus/ directory for the necessary Modbus registers. While working through this section, you’ll need a copy of the LabJack Modbus Map:

http://labjack.com/support/modbus

open in a new window.

Accessing the Modbus directory

All the commands in this section work only in the modbus/ subdirectory of a device, so go there first.

  
# Change to the modbus/ directory
$ cd root-ljfuse/My\ U3-LV/modbus/
$ pwd
/Users/mikec/src/LJFuse/root-ljfuse/My U3-LV/modbus
# View the Modbus registers
$ ls
0           5002        6002        6006        6102        6106
2           6           6003        6007        6103        6107
4           6000        6004        6100        6104        README.txt
5000        6001        6005        6101        6105
  

Using the counters

Looking at the LabJack Modbus Map (you do have that open, right?), notice that register 50502 is a “Counter Mask”. We can write to that register to enable a counter.

But wait, look at the output of “ls” above. There is no file for 50502. This is the key point of this whole section:

In the modbus/ directory, you may create files for the Modbus addresses that are missing.

p.

Comments

No comments yet. Speak up. We're listening.

LJFuse

LJFuse makes communicating with a LabJack device simple on Linux and Mac OS X. Really simple. Trivial, really.

Introduction

It’s been said (many, many, times) that everything’s a file in UNIX. LJFuse adopts that philosophy and makes the connections on a LabJack device into files on the filesystem. To do so, it uses FUSE on Linux and MacFUSE on Mac OS X.

For example, to read analog input AIN0, read a file named “AIN0”.

  
$ cat MyU6/connection/AIN0
3.300
  

To set DAC0 to 2.4V, write “2.4” to a file named “DAC0”.

  
$ echo 2.4 > MyU6/connection/DAC0
$ cat MyU6/connection/DAC0   # Read the DAC0 to verify it was set
2.400
  

To set FIO0 to digital output high, write a “1” to “FIO0”.

  
$ echo 1 > MyU6/connection/FIO0-dir  # Set the direction to output
$ echo 1 > MyU6/connection/FIO0      # Set the state to output high
$ cat MyU6/connection/FIO0           # Read the value back
1    
  

You can do this from any program that knows how read and write files. Your program doesn’t need to know about USB communication, drivers, or the LabJack API. The details are hidden by LJFuse.

Quickstart

Check the requirements (in short, a working LabJackPython installation on Linux or Mac OS X), and download the source code for LJFuse from GitHub. Click the “Download Source” button on the GitHub page to download.

Connect a LabJack and run LJFuse like this:

  
$ python ljfuse.py
  

p.

LJSocket

LJSocket provides a socket interface to a LabJack. It’s one of many ways to communicate with a USB LabJack over Ethernet or WiFi. Using LJSocket, anything that you could write to a LabJack over USB, you can now write over a TCP socket. This allows, for example, to send Modbus TCP packets to a U3 or U6. (The UE9 natively supports Modbus TCP over its Ethernet interface.)

Even without using Modbus, LJSocket is useful because a socket interface is easier than a USB interface. Any software or programming language that can communicate using sockets (e.g., LabVIEW or Python) can communicate with a LabJack without any drivers or knowledge about USB.

Because it uses TCP sockets, network transparency is built into LJSocket. You can plug a LabJack into a remote computer and access it from another.

In this picture, a Chumby is running LJSocket, and making the U3 available over the WiFi network.

LabJack U3 connected to Chumby

The source code for LJSocket is available on GitHub. If you use Windows there is an executable attached to the bottom of this page.

If you use Python to talk to LJSocket, start LJSocket on one computer (IP address 192.168.1.2 in this example) connect a U3, and on another computer on the local network, run this code:

  
>>> import u3
>>> d = u3.U3(LJSocket = "192.168.1.2:6000")
>>> d.configU3()
  

and it would be just like your U3 was connected locally.

h3.

UE9 Modbus TCP Example

The UE9 natively supports Modbus TCP. Check the Modbus map for a list of addresses to send. This is an example using LabJackPython of what bytes to send on the wire to talk to the UE9 over Modbus TCP:

  
>>> import ue9
>>> d = ue9.UE9(ipAddress =  "192.168.1.209", ethernet = True)
>>> d.debug = True
>>> d.readRegister(0)  #Reads AIN0
Sending:  [0, 0, 0, 0, 0, 6, 255, 3, 0, 0, 0, 2]
Response:  [0, 0, 0, 0, 0, 7, 255, 3, 4, 59, 97, 232, 0]
0.0034470558166503906
>>> d.writeRegister(5000, 3.3)    #Sets DAC0 to 3.3 V
Sending:  [0, 0, 0, 0, 0, 11, 255, 16, 19, 136, 0, 2, 4, 64, 83, 51, 51]
Response:  [0, 0, 0, 0, 0, 6, 255, 16, 19, 136, 0, 2]
3.2999999999999998
>>> d.readRegister(0)    #Reads AIN0 again
Sending:  [0, 0, 0, 0, 0, 6, 255, 3, 0, 0, 0, 2]
Response:  [0, 0, 0, 0, 0, 7, 255, 3, 4, 64, 83, 52, 90]
3.3000702857971191
  

In the example above, each line that starts with “Sending” contains the bytes that the PC sends to the UE9. The “Response” lines contain what the UE9 sent back to the PC.

Comments

No comments yet. Speak up. We're listening.

LJTick-DAC Testing Utility

This application will allow you to configure and test LJTick-DACs attached to any UD family device. While the actual cross platform Python script is contained in the LabJack Python package, we provide a stand-alone application for the convenience of our customers running Microsoft Windows.

If you get an error message that says something like “This application has failed to start because the application configuration is incorrect …”, try downloading this update for your machine:

x86 (32-bit Windows)
Link to Microsoft Downloads for 32-bit machines

x64 (64-bit Windows)
Link to Microsoft Downloads for 64 bit machines

File attachment: 

Firmware

All LabJack devices, except the U12, have upgradable firmware. From time to time, we release a new firmware to fix any issues that are discovered or add new features. Find your device from the list below to download its firmware.

LJSelfUpgrade for upgrading using Windows

Use the latest version of LJSelfUpgrade to upgrade the firmware on Windows. In order to run, LJSelfUpgrade version 1.24 and above requires the installation of UD driver 3.15 on your system.

Python Firmware Upgrader for upgrading using Linux and Mac OS X

Linux and Mac users, or adventurous Windows users, can use a Python firmware upgrader from the list below. (Grab the correct one for your system, Python 2.7, 2.6 or 2.5.)

- Requires Internet access during programming.

- If you have UE9 Control firmware older than 1.78, you must use LJSelfUpgrade.

- If you have a U3A or U3B (hardware revisions 1.20 or 1.21), you can use the Python upgrader by manually downloading and specifying the proper firmware file (see readme file), but it is lightly tested.  If you run into problems, find a Windows machine and use LJSelfUpgrade to attempt to recover as described in Section 1.2.

Note: The Python Firmware Upgrader requires httplib2. It can be downloaded from its Google code page. Python 2.5 also requires simplejson, which can be downloaded here.

 

Linux and Mac OS X drivers

Introducing the Exodriver

The native USB drivers for Linux and Mac OS X have merged into a single driver: the Exodriver. The Exodriver is a thin interface (think exoskeleton) to LabJack devices. It’s written as a C library that uses libusb-1.0 for USB communication. The library can open, close, read from, and write to a LabJack U3, U6, UE9, and U12. Because it’s a library and doesn’t have any kernel code, it’s easy to build.

U12 users also have the option to use the ljacklm high-level driver, which requires the Exodriver. For more details visit the ljacklm web page .

Mac OS X Quickstart

Mac OS X users can use the pre-built installer rather than building the Exodriver from the source. The installer includes an patched copy of libusb 1.0.8 (source code). We also provide a simple Xcode project if you would like to use Xcode to build LabJack applications with the Exodriver. C language examples are provided with the Exodriver’s source code.

If you would prefer to build the Exodriver from the source, the instructions in the next section work on Mac OS X.

Two notes to U12 Users on Mac OS X: First, there is an issue with interrupt transfers and libusb that can be a huge problem for U12 users. There is an unofficial patch that should be included in the next release (1.0.9) of libusb. For now, we offer the libusb source with the patch applied. We have also updated the pre-built installer to use this version.

UE9 C Native TCP Example

For Linux, Mac OS X, and Windows. This package contains example code (written in C) for calling low-level UE9 functions over a TCP connection (no special drivers required). Refer to the readme file in the zip for more information. Aug 8, 2008, 49 KB.

File attachment: 

Comments

No comments yet. Speak up. We're listening.