BrainTree Scientific, Inc. 注射泵(型号 bs-8000)rs232 的串行命令

Serial Commands for BrainTree Scientific, Inc. Syringe Pump (model bs-8000) rs232

更新: 在确保我的命令、串行配置和终止符('\r')正确后,我在 5 台计算机中的 1 台上运行。这让我相信这是一个适配器问题。我打算打电话给公司,了解如何订购 USB/RJ11 适配器(我一直在 mac 上使用 Keyspan USB->DB9->RJ11 适配器)


我读过 this but I am still unable to communicate with this pump. This is the python script I modified (source),

import time
import serial

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
  port='/dev/tty.USA19H142P1.1', # /dev/tty.KeySerial1 ?
  baudrate=19200,
  parity=serial.PARITY_NONE,
  stopbits=serial.STOPBITS_ONE,
  bytesize=serial.EIGHTBITS
)


if not ser.isOpen():
  ser.open()

print ser
commands = ['dia26.59', 'phn01', 'funrat', 'rat15mm', 'vol0.7', 'dirinf',
            'phn02', 'funrat', 'rat7.5mm', 'vol.5', 'dirinf', 'phn03',
            'funrat', 'rat15mm', 'vol0.7', 'dirwdr', 'phn04', 'funstp',
            'dia26.59', 'phn01', 'funrat', 'rat15mm', 'vol1.0', 'dirinf',
            'phn02', 'funrat', 'rat7.5mm', 'vol.5', 'dirinf', 'phn03',
            'funrat', 'rat15mm', 'vol1.0', 'dirwdr', 'phn04', 'funstp']

for cmd in commands:
  print cmd
  ser.write(cmd + '\r')
  time.sleep(1)
  out = ''
  while ser.inWaiting() > 0:
    out += ser.read(1)
  if out != '':
    print '>>' + out

tty 端口:

$ ls -lt /dev/tty* | head
crw--w----  1 nathann  tty     16,   0 Oct 13 14:13 /dev/ttys000
crw-rw-rw-  1 root     wheel   31,   6 Oct 13 14:12 /dev/tty.KeySerial1
crw-rw-rw-  1 root     wheel   31,   8 Oct 13 13:52 /dev/tty.USA19H142P1.1
crw-rw-rw-  1 root     wheel    2,   0 Oct 13 10:00 /dev/tty
crw-rw-rw-  1 root     wheel   31,   4 Oct 12 11:34 /dev/tty.Bluetooth-Incoming-Port
crw-rw-rw-  1 root     wheel    4,   0 Oct 12 11:34 /dev/ttyp0
crw-rw-rw-  1 root     wheel    4,   1 Oct 12 11:34 /dev/ttyp1
crw-rw-rw-  1 root     wheel    4,   2 Oct 12 11:34 /dev/ttyp2
crw-rw-rw-  1 root     wheel    4,   3 Oct 12 11:34 /dev/ttyp3
crw-rw-rw-  1 root     wheel    4,   4 Oct 12 11:34 /dev/ttyp4

我什至不确定它是否在发送命令。没有收到任何错误或反馈。泵上没有发生任何事情,也没有返回任何东西(out 字符串始终为空)

这是我的输出:

(sweetcrave)nathann@glitch sweetcrave (master) $ python pumptest.py
Serial<id=0x1093af290, open=True>(port='/dev/tty.USA19H142P1.1', baudrate=19200, bytesize=7, parity='O', stopbits=2, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)
dia26.59
>>
phn01
funrat
rat15mm
vol0.7
^CTraceback (most recent call last):
  File "pumptest.py", line 28, in <module>
    time.sleep(1)
KeyboardInterrupt

我的终极目标:

泵很容易交谈 - 但如果您遇到很多麻烦 - 那么一定有问题需要解决。

在担心从您的编程代码向泵发送命令之前,最好先测试一下泵是否已准备好建立计算机连接。

根据多年使用这些泵的经验,我可以告诉您,当您遇到与泵通信这种程度的困难时,最常见的问题是电缆断裂,2 号是将它们插入泵背面的正确孔中。

我建议从第 3 方获取一个已知的工作应用程序 - 就像我的 http://www.SyringePumpPro.com,安装它并使用它来确认你的泵将与一个已知的功能软件通信。如果泵和电缆一切正常,SyringePumpPro 将在几秒钟内检测并显示泵的活动。它不会花费您任何费用,它会让您知道泵、串行适配器和电缆都在正常工作。

你的程序...

我将搁置您的 tty 端口是否正在打开等问题,但是如果您向泵发送任何内容,它们都会回答 - 通常使用

这样的序列

00S?对于未知命令。

查看您的 python 代码 - 我担心您重复命令两次。泵只需要将这些命令上传一次,并会通过电源循环记住它们。

假设您的命令到达泵 none 将导致泵泵送 - 它们正在向泵的内存加载要执行的操作,但实际上并没有执行。您需要命令 运行 将泵送至 运行 您上传的内容。

可以一次上传泵命令,然后再上传运行。然后就是在 python 代码中同步泵送和刺激。

上面的泵送序列可以在 PPL 或泵程序语言文件中完成并上传一次。

泵手册后面有示例 PPL 文件,您可能感兴趣的示例是示例 2。

这叫反复免除吸回。

碰巧我在 youtube 上制作了一个很长的培训视频。它可能真的有助于解释泵的工作原理、泵的编程语言如何工作以及如何上传泵程序。

祝你好运