How to Control the Longer WT600-2J(1J)(3J) Pump via Python ?

How to Control the Longer WT600-2J(1J)(3J) Pump via Python ?

If you are looking for a powerful peristaltic pump designed for laboratory and industrial applications, you might want to check out the Longer WT600-2J. This pump can deliver flow rates ranging between 4.2 mL/min and 6000 mL/min. It has a high torque maintenance-free brushless motor that allows mounting up to 4 pump heads on the same driver.

The WT600-2J can be controlled remotely from your computer which can give you more flexibility and convenience, especially if you want to run complex pumping programs with loops, pauses, and varying rotation speeds.

In this blog post, we will show you how to communicate with the WT600-2J using the LONGER RS485 protocol, which is a serial communication protocol that allows you to send commands and receive responses from the pump. We will also provide some examples and code snippets on how to use Python to write and send control command strings to the pump.

What do you need to communicate with the WT600-2J ?

To communicate with the WT600-2J using the LONGER RS485 protocol, you will need the following:

  • A WT600-2J pump with a pump head and a tubing of your choice
  • A RS485 control module that plugs into the DB15 port on the rear of the pump
  • A DB15 connector that is wired to the RS485 control module
  • A serial cable that connects the RS485 control module to your computer or device
  • A programming platform (Python in the case herein)
  • A basic understanding of the data format, command format, and pdu format of the LONGER RS485 protocol (explained below 👇)

How to Set Up the Communication Port ?

Before you can start sending and receiving data from the pump, you need to set up the communication port correctly. Here are the steps to follow:

  • Connect the DB15 connector to the DB15 port on the rear of the pump
  • Turn on the pump
  • Make sure the communication parameters on your programming platform match the ones of the WT600-2J, which are:
    • 1 start bit
    • 8 data bits
    • 1 even parity
    • 1 stop bit
    • a baud rate of 1200 bits/s

How to Write Control Command Strings to the WT600-2J ?

Once you have set up the communication port, you can start writing and sending control command strings to the pump. A control command string is a sequence of hexadecimal characters that follows a specific format, which consists of:

  • a start flag (E9H)
  • a pump address (1 to 30, or 31 for broadcast)
  • a length of the pdu (protocol data unit)
  • a pdu, which contains the command characters and the parameters for the desired application
  • a frame check sequence (fcs), which is obtained by calculating the XOR of the pump address, the length of the pdu, and the pdu itself (compute your fcs using our online frame check sequence XOR calculator)

The pdu and its length depend on the application requested from the pump. The common applications are:

  • Set running parameter (rotation speed)
  • Read running parameter (rotation speed)
  • Write pump address
  • Read pump address

For each application, there is a corresponding set of command characters and parameters that you need to include in the pdu. These parameters are detailed below.

Set running parameter (rotation speed)

This application consists of writing to the pump. The overall length of the pdu is 6 bytes where the control command string consists of (in the exact same order):

WJSet SpeedState 1State 2
2 bytes2 bytes1 byte1 byte
  • WJ, control command string of 2 bytes, 57 4A
  • Set rotation speed (2 bytes) with a maximum speed of 600 rpm (02 58)
  • State 1 (1 byte): 
    • bit 0 – start/stop bit where 1 is to start the pump and 0 is to stop it
    • bit 1 – prime bit where 1 is to prime the pump at the max speed of 600 rpm and 0 is to run the pump at a normal speed
  • State 2 (1 byte):
    • bit 0 – sets the rotation direction where 1 is for clockwise and 0 is for counter-clockwise

The pump will respond with WJ and will display on its front screen the rotation speed after receiving the control command string.

Read running parameter (rotation speed)

This application consists of reading from the pump. The overall length of the pdu is 2 bytes where the control command string is RJ.

The pump’s response consists of:

RJShow SpeedState 1State 2
2 bytes2 bytes1 byte1 byte
  • RJ, control command string of 2 bytes, 52 4A

Write pump address

This application consists of writing to the pump. The overall length of the pdu is 4 bytes where the control command string consists of:

WIDNew pump I.D.#.
3 bytes1 byte
  • WID, control command string of 3 bytes, 57 49 44
  • New pump address (1 byte), can be pump address (1-30) or broadcast address (31); the default pump address is 1

The pump will respond with WID.

Read pump address

This application consists of reading from the pump. The overall length of the pdu is 3 bytes where the control command string is RID.

In a command string from the control computer, if the address is one pump’s address (1-30), not the broadcast address (31), the corresponding pump will respond with RID.

Examples of control command strings

  • Set the WT600-2J to run clockwise at a rotating speed of 150 rpm

Control command string: E9 01 06 57 4A 00 96 01 01 8C

  • E9 as the flag
  • 01 as the address 1 of the pump
  • 06 as the length of the pdu (57 4A 00 96 01 01)
  • 57 4A as command characters WJ
  • 00 96 refers to the rotation speed, 0096(hex) = 150(dec) (check our online base conversion tool)
  • 01 to start the pump at normal speed
  • 01 to run the pump clockwise
  • 8C as the XOR result of 01 (pump address), 06 (pdu length) and 57 4A 00 96 01 01 (pdu) 
  • Set the address (initially 1) of the WT600-2J to address 7

Control command string: E9 01 04 57 49 44 07 58

  • E9 as the flag
  • 01 as the initial address 1 of the pump
  • 04 as the length of the pdu (57 49 44 07)
  • 57 49 44 as command characters WID
  • 07  as the new pump address
  • 58 as the XOR result of 01 (pump address), 04 (pdu length) and 57 49 44 07 (pdu) 

🚨Do not hesitate to use our user-friendly online command string generator to effortlessly generate precise control command strings for your WT600-2J.

How to communicate with the WT600-2J using Python ?

Python code snippets showing how to open the serial port, write and send control command strings to the pump and write a simple pumping program are presented below.

From the first example just presented above, the following Python code snippet makes the WT600-2J run clockwise at a rotating speed of 150 rpm.

				
					### RUN PUMP 1, CLOCKWISE, AT A ROTATING SPEED OF 150 RPM

# To use the pySerial package
import serial

# Open the serial port with the data format corresponding to the WT600-2J
ser = serial.Serial('COM6', 1200, parity=serial.PARITY_EVEN, bytesize=8, stopbits=1, timeout=None, xonxoff=0, rtscts=0)

# Write the corresponding control command string in hexadecimal
Data = bytearray(b'\xE9\x01\x06\x57\x4A\x00\x96\x01\x01\x8C')

# Write the Data to the pump
ser.write(Data)

				
			
  • In a second code snippet, let’s make the pump (address 4) run clockwise at a rotating speed of 320 rpm for 10s, then make it run counter-clockwise at a rotating speed of 50 rpm for 30s before stopping it.
				
					### RUN PUMP 4 CLOCKWISE AT A ROTATING SPEED OF 320 RPM FOR 10s, THEN COUNTER−CLOCKWISE AT A ROTATING SPEED OF 50 RPM FOR 30s BEFORE STOPPING IT

# To use the pySerial package
import serial
# To use the time package
import time
# Open the serial port with the data format corresponding to the WT600-2J
ser = serial.Serial('COM6', 1200, parity=serial.PARITY_EVEN, bytesize=8, stopbits=1, timeout=None, xonxoff=0, rtscts=0)

# Run pump 4 clockwise at a rotating speed of 320 rpm for 10s
Data = bytearray(b'\xE9\x04\x06\x57\x4A\x01\x40\x01\x01\x5E') # corresponding control command string in hexadecimal; 320(dec) = 01 40(hex)

ser.write(Data) # Write the Data to the pump

Pumping_time = 10;
while Pumping_time > 0:
    print(Pumping_time)
    time.sleep(1)
    Pumping_time = Pumping_time - 1
end # 10s delay with a visible timer

# Run pump 4 counter-clockwise at a rotating speed of 50 rpm for 30s
Data = bytearray(b'\xE9\x04\x06\x57\x4A\x00\x32\x01\x00\x2C') # corresponding control command string in hexadecimal; 50(dec) = 00 32(hex)

ser.write(Data) # Write the Data to the pump

Pumping_time = 30;
while Pumping_time > 0:
    print(Pumping_time)
    time.sleep(1)
    Pumping_time = Pumping_time - 1
end # 30s delay with a visible timer

# Stop the pump
Data = bytearray(b'\xE9\x04\x06\x57\x4A\x00\x32\x00\x00\x2D') # corresponding control command string in hexadecimal: we took the previous command string and changed the State 1 byte from 01 (start pump) to 00 (stop pump) and of course computed the new fcs

ser.write(Data) # Write the Data to the pump

				
			

Conclusion

We hope this blog post has helped you understand how to control the Longer WT600-2J multichannel peristaltic pump remotely via Python using the LONGER RS485 protocol. You can also use other programming platforms such as Matlab to write and send control command strings to the pump and read and interpret the responses from the pump. For more details about this topic, check our blog post “How to Control the Longer WT600-2J(1J)(3J) Pump via Matlab ?”.

If you have any questions or feedback, please feel free to contact us at contact@darwin-microfluidics.com.