For my experiments with zebrafish, I typically generate dynamic odor landscapes for the fish / fish brain explant by varying the speed of the wheels of an Ismatec peristaltic pump, thereby changing the concentration of the applied stimuli over time. Recently, I bought one of their digital pumps (Reglo ICC with four independent channels), but the company only provides a Labview code sample for custom implementation.
I wrote a small Matlab adapter class to interface with the pump. In order to spare other people from this effort, here is my implementation on Github. It allows to change pump speed, pumping direction etc by a serial protocol that is transmitted via USB and a virtual COM port. – It should be easy to use this as a starting point for a similar code snippet in Python.
Clearly, this will be useful for only a small number of people, but I at least would have been glad to find a sample code in the internet that could have spared me the time to write the code by myself. Hopefully Google will find its way to direct people in need to these links. Here are some guiding tags: Reglo ICC, Ismatec, Cole-Parmer, serial port, USB, COM, serial object, adapter class, object-oriented Matlab.
Pingback: Whole-cell patch clamp, part 2: Line-frequency pick-up via the perfusion system | A blog about neurophysiology
Thanks for this! It really helped me getting started in programming the pump via Python!
Great to hear that you made it work with Python as well!
Hey I am also working on that currently. Could you help me how you did it with Python
Hi!
Did you end up writing any python for the pump program?
Hey I am also working on that currently. Could you help me how you did it with Python
Dear Hemanth,
the key part in the Matlab code are the pieces of serial code like “fprintf(obj.serialobj,’%s’,strcat(num2str(channel),’S’,13));”
This means, use a print function (“fprintf”) on the serial port defined by “obj.serialobj” and write a message, e.g., “%s2S” + carriage return, here with the channel ID “2”.
To interact with a serial port in Python, there are many possible packages (and maybe Nicola can comment on that?), like https://pyserial.readthedocs.io/en/latest/pyserial_api.html.
Good luck with your project!
Yes i am trying to convert the code in Python.
Currenty I stuck here in your code trying to understand it, When setting the speed of a channel, exactly at the speedstring to the end . Also in your previous comment regarding 13, I did not understand it clearly. Could you please eleaborate it clearly
% set speed for a single channel in RPM
function obj = setSpeed(obj,channel,speed) % in RPM, with RPM 100; disp(‘Speed higher than maximum (100 RPM), reduced to maximum.’); end
speed = max(min(speed,100),0);
speedstring = strcat(sprintf(‘%03d’,floor(speed)), num2str(floor((speed-floor(speed))*100)));
obj.speed(channel) = speed;
fprintf(obj.serialobj,’%s’,strcat(num2str(channel),’S0′,speedstring,13));
end
Hi,
I do currently not have access to these pumps, so I cannot help you directly.
All the commands for this serial communication can be checked in the manual of the pump, available currently here: https://us.vwr.com/assetsvc/asset/en_US/id/39457649/contents/manual-masterflex-ismatec-reglo-independent-channel-control-icc-peristaltic-pumps.pdf
Hopefully this, together with the example Matlab code that I have written, gives you already a good starting point.
Each time you send a command through the serial port, you have to provide a command string, then hit “Enter”, also called “carriage return”. In Matlab, “13” or “char(13)” is the character for carriage return. For your code you will probably have to replace it by something like “\r” in Python. I think this should give you enough information to get started by googling for “carriage return Python serial port” or something like that.
If you don’t understand other aspects of the code, let me know.
Hello Rupprecht,
Thanks for your reply. I will try this for sure and will let you know if I face any difficulties, if possible could be provide me your Gmail Id so that I can contact you from there. Or just write me to this EmailID I will write you.
[e-mail deleted by Peter Rupprecht]
Hi, I sent you my email address. I’ve deleted your email address from your blog comment so that you will not receive too much spam by that.
Best, Peter
Hello Rupprecht,
Thanks for your reply. I have run the code with Matlab and runs perfect, but I am very bad at matlab. I am trying to convert the code but it feels difficult for me. I am losing it.
Hi, are you trying to convert the program to a different language (like Python)? Or are you adapting the Matlab program for your purposes? If you can clearly define the problem where you are stuck, I can maybe point you to a possible solution.
– Peter