Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

UPDATE: After ensuring my commands, serial config, and terminator ('\r') were correct I got this working on 1 of 5 computers. This leads me to believe it is an adapter issue. I plan on calling the company to see about ordering a USB/RJ11 adapter (I had been using a Keyspan USB->DB9->RJ11 adapter on my mac)


I've read 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 ports:

$ 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

I'm not even sure if it is sending the commands. Not getting any errors or feedback. Nothing is happening on the pump and nothing is getting returned (out string is always empty)

This is my output:

(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

My ultimate goal:

  • set up pumps parameters
  • there are three phases that are specified:
  • phase 1: push liquid to end of tube
  • phase 2: dispense liquid in specific rate and volume
  • phase 3: pull liquid back up
  • the liquid is pulled back up (phase 3) so that it won't drip from the manifold, and so the subject can't suck it out. As such, phase 1 is needed to push the
  • liquid back to the outflow point.
  • volume and dispense rate can be changed. Use the following formula:
  • rate= volume/sec * 60
  • example: .5/4 x 60 (deliver .5 ml over a 4 sec duration)=7.5
like image 200
broinjc Avatar asked Oct 20 '22 00:10

broinjc


1 Answers

The pumps are very easy to talk to - but if you experience much trouble - then there must be a problem waiting to be fixed.

Before you worry about sending commands to pumps from your programming code, it's a good idea to test the pump is ready to make a computer connection.

From years of experience with these pumps I can tell you broken cables are the MOST common problem when you experience this level of difficulty communicating with pumps, Number 2 is plugging them into the correct hole on the back of the pump.

I suggest grabbing a known working application from a 3rd party - like mine http://www.SyringePumpPro.com, installing it and using it to confirm that your pump will communicate with a known functioning piece of software. If all is well with the pumps and cables, SyringePumpPro will detect and display your pump's activities in seconds. It wont cost you anything and it will let you know the pump, serial adapter and cables are all working properly.

Your program...

I will leave aside the issue of whether your tty port is being opened etc, however if you send the pumps anything they will answer - usually with a sequence like

00S? for an unknown command.

Looking at your python code - I am concerned that you repeat the commands twice. The pump only needs these commands uploaded once and will remember them through power cycles.

Assuming your commands were getting to the pump none of them would cause the pump to pump - they are loading the pump's memory with what to do but not actually doing it. You need the command RUN to get the pump to run what your uploading.

The pump commands can all be uploaded in one upload and then RUN. Then it's all about synchronizing the pumping and the stimulation in your python code.

That pumping sequence above can be done in a PPL or pump program language file and uploaded once.

There's example PPL files in the back of the pump manual and the example you might be interested in is Example 2.

It's called repeated dispense with suck back.

As it happens I made a looooong training video about this which is on youtube. It might really help explain how the pumps work, how the pump's programming language works and how to upload pump programs.

Good luck

like image 142
SyringePumpPro Avatar answered Oct 21 '22 15:10

SyringePumpPro