%% Medium Changer 2
% This is an m-file for remotely operating a perfusion system in order to replace a 1 mL
% volume of medium twice in a row. The perfusion system comprises two Harvard Apparatus
% mL Flow Modular Pumping Components (MPCs) for infusion as well as a vacuum-line valve
% controlled by a Parker Hannifin Valve Driver II for aspiration. The program controls
% one mL Flow MPC via serial port COM2 and sends TTL pulses out the parallel port to pin
% 4 of the Parker Hannifin Valve Driver II terminal strip. This program can be used in
% conjunction with the m-file "Medium Changer 1" to conduct medium-change (i.e., drug-
% effect-type) experiments with two types of media.
% Copyright 2004 - 2007 Matthew A. I. Ua Cruadhlaoich
% Creates a digital I/O object named "valveswitch" associated with the parallel port LPT1.
valveswitch = digitalio('parallel','LPT1');
% Adds output hardware line 2 (which corresponds to parallel port pin 4) to valveswitch.
addline(valveswitch,2,'out');
% Creates a serial port object named "pump2" linked to serial port COM2.
pump2 = serial('COM2');
% Communication settings taken from p. 9 of the mL Flow MPC manual (1 start bit is sent by
% default).
set(pump2,'BaudRate',9600,'DataBits',8,'Parity','none','StopBits',2);
fopen(pump2)
% Clears syringe pump 2 volume accumulator to zero.
fprintf(pump2,['CLV' char(13)]);
pause(1)
% Sets diameter of syringe in mm. (Flow rate is reset to 0 following this command.)
fprintf(pump2,['MMD 26.7' char(13)]);
pause(1)
% Sets syringe pump 2 flow rate to max for B-D 60 mL syringe, in mL/min (26.56, from pp.
% 12-13 of the MPC manual).
fprintf(pump2,['MLM 26.56' char(13)]);
pause(1)
% Sets syringe pump 2 target volume to 1 mL.
fprintf(pump2,['MLT 1' char(13)]);
pause(1)
% Begins sucking off old medium.
putvalue(valveswitch,1);
pause(10)
% Ends sucking.
putvalue(valveswitch,0);
% Infuses 1 mL of medium.
fprintf(pump2,['RUN' char(13)]);
pause(3)
% Clears syringe pump 2 volume accumulator to zero.
fprintf(pump2,['CLV' char(13)]);
pause(1)
% Begins sucking off old medium.
putvalue(valveswitch,1);
pause(10)
% Ends sucking.
putvalue(valveswitch,0);
% Infuses 1 mL of medium.
fprintf(pump2,['RUN' char(13)]);
pause(3)
% Clears syringe pump 2 volume accumulator to zero.
fprintf(pump2,['CLV' char(13)]);
pause(1)
% Removes valveswitch from memory and from the workspace.
delete(valveswitch)
clear valveswitch
% Closes pump2, clears it from memory, and removes it from the workspace.
fclose(pump2)
delete(pump2)
clear pump2