1
\$\begingroup\$

I would like to use a Raspberry Pi4 to control a syringe pump [(see datasheet here and in particular the quick start manual on page1)][1]

The connector cables I used are RJ11 from the Pump to RS232 (from the manufacturer) as well as a standard RS232 to USB converter cable from Benfei ([drivers can be downloaded here][2])

On Windows it worked fine after installing the drivers (was needed). The COM port was recognized and I could test the pump with Arduino.

On my Raspberry I am not getting it to work.

I am this far: The RS232 adapter is recognized:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port / Mobile Action MA-8910P
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> pi@raspberrypi:~ $ dmesg | grep "tty" [  960.932258] usb 1-1.3: pl2303
> converter now attached to ttyUSB0

When using this bare minimum code example:

import time
import serial

Serial = serial.Serial("/dev/ttyUSB0", baudrate = 19200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1)
#Rate Units
#mL/hr - MH
#µL/hr - UH
#mL/min - MM
#µL/min - UM

def test_syringe(diameter = 10.00, pumping_rate = 10.00, pumping_rate_unit = 'MH', volume_to_dispense = 20.00):
    Serial.write(("DIA " + str(diameter) + "\n").encode())
    message = Serial.read()
    print(message.decode())
    Serial.write("DIA \r".encode())
    message = Serial.read()
    print(message.decode())
    Serial.write("RAT ".encode() + str(pumping_rate).encode() + " ".encode() + pumping_rate_unit.encode())
    Serial.write("VOL ".encode() + str(volume_to_dispense).encode())
    Serial.write("DIR INF".encode())
    Serial.write("RUN \n".encode())


test_syringe()

I get at least some feedback from the pump:

b'\x02'
0

But it is not starting. The linux driver is only available for Redhat. I'm thinking about purchasing another RS232 adapter cable.

Is the code with the carrier return corect? [1]: https://www.syringepump.com/download/NE-500%20OEM%20Syringe%20Pump%20User%20Manual%20V3.9.pdf [2]: https://www.think-benfei.com/p_driver.html

\$\endgroup\$
3
  • \$\begingroup\$ Your example is not so minimal. Try sending simple binary strings b"like this" without encoding/formatting, and reproduce exactly what the Arduino did. \$\endgroup\$ Commented Apr 23, 2022 at 8:35
  • 1
    \$\begingroup\$ Also check how much data Serial.read() tries to read. In general you need to know how many bytes you want to read, or read one at a time until you get some kind of ending byte \$\endgroup\$ Commented Apr 23, 2022 at 10:52
  • \$\begingroup\$ Something like Serial.read_until(ETX) where ETX = 0x03 might be helpful to read an entire reply. \$\endgroup\$ Commented Apr 23, 2022 at 11:12

1 Answer 1

2
\$\begingroup\$

Controlling electronic devices with a computer is not an electrical engineering question.

The manual has a section what to do if communications are not working and one of the reasons is that the pump is using binary Safe Mode protocol and must be changed to Basic Mode protocol before trying to communicate with it in Basic Mode.

The 0x02 response from the pump is STX so it is a clear indication the pump is sending you a Safe Mode response back.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.