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