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.

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:

Requirements

A U3, U6, or UE9 over USB with the latest firmware. At minimum for Modbus support, the U3 requires firmware 1.26; the U6 requires firmware 1.15; and the UE9 requires Control firmware 2.13 and Comm firmware 1.5.

On Windows, you have the option to run LJSocket as a Windows service. This is further discussed in the "Running LJSocket as a Windows Service" section.

On Windows, Mac OS X and Linux, to run the LJSocket source code in Python, you will need the following Python software installed: Python 2.6 or 2.7, LabJackPython release 5-26-2015 or older, and Twisted. To run LJSocket, refer to the LJSocket source code's README file or the "Running LJSocket on Ubuntu 10.04" section

Running LJSocket as a Windows Service

Open the installLJSocket.bat program to install LJSocket as a service. For Windows Vista and 7 users, open the installLJSocket.bat program as administrator. The program will start LJSocket and will configure it to start automatically after a reboot. To manually start and stop the LJSocket, use the Control Panel > Administrative Tools > Services application:

Here’s how to find the Services application. (It took me a few tries.)

Modbus port

The LJSocket source code defines the MODBUS_PORT in LJSocket.py (near the top) as 502x so that it can be run on Linux and Mac OS X without administrator privileges. So for a single device, the port number will typically be 5021.

SCADA applications

ScadaMobile Lite

We have successfully connected LJSocket with ScadaMobile Lite for the iPhone. Here is a screenshot viewing the state of FIO6 on a U3:

Here is the CSV file loaded to ScadaMobile Lite to configure the application to connect to FIO6:

Reading carefully, note that the CSV file defines holding register 6007 (HR6007). From the LabJack Modbus map the digital I/O states start at Modbus port 6000, so FIO6 is at 6006. ScadaMobile Lite starts numbering at 1 instead of 0, so the CSV file adds one to get 6007.

Wonderware

We have also had a report from a customer that Wonderware can be made to work, but it requires some configuration. To read a float from AIN0 on a U3-HV, the customer read register 40001. The LabJack Modbus map states the address should be 0. The 40000 is to tell Wonderware to read a holding register. The 1 is the same off-by-one problem as ScadaMobile Lite. Also, the response from LJSocket is a float in big-endian format; Wonderware expects little-endian bytes by default.

Mango

Based on a customer suggestion we also successfully connected Mango to LJSocket. In our brief experience with Mango, it was easy to setup and the most flexible in terms of Modbus TCP options. Here is a screenshot configuring LJSocket as a data source:

Note how we set the host and port (192.168.1.103 and 5020 on Mac OS X) to where LJSocket is running. After defining LJSocket (“My U3”) as the data source, we add two data points. AIN0 is a holding register, with 4-byte float as its Modbus data type, and an offset of 0. It is not settable. As shown in the screenshot above, FIO6 is a holding register, with 2-byte signed integer as its Modbus data type, and an offset of 6006. (In a moment of rare SCADA-software sanity, the offset is zero-based.) It is settable.

After defining the data points, activate them and collect data. Below is a screenshot of AIN0 floating (unconnected to a signal), then briefly connected to VS (5 V) and GND (0 V):

DAQFactory

AzeoTech’s free QuickMod application can also connect to LJSocket and collect data. QuickMod users with a DAQFactory license can further customize its behavior.

Launch QuickMod, select “Modbus TCP over Ethernet”, and click “Configure”. Add LJSocket’s IP address and port in the dialog box as shown in this example:

To read AIN0, change ID 1’s Type to “Float” and set “# pts” to 1. Leave the Function as “Holding Register” and the “Tag #” at 0. The value of AIN0 will show in the list and plot below:

In our experience, QuickMod sets the current record for “shortest time from download to looking at data” via LJSocket.

ModScan32

A customer in our forum has tried this software with the UE9. As we noted in the forum topic, the software has a one-based offset instead of a zero-based offset, so subtract 1 from the address to read.

This Python code opens the U3 over a TCP/IP socket, not its USB interface. Run this code on another computer on the same network (and substitute the Ubuntu computer’s IP address for “localhost”) to utilize LJSocket’s network transparency.

I am tring to use LJSocket with U3 and I want to use the socket programming with C#. Is this possible. I have little knowledge on sockets. Can you please give me sample code to achieve this. I want to read and write digital I/O.