Controlling a syringe pump with arduino Mega

Hi guys,

I'm working on a medical project and I need to control this pump:

So my connection goes:

Computer->USB->Arduino Mega-> RS232 shield->RS232 cable-> pump

Here's my sample code (I set my jumper to pin 0):

int val = 0;
float Q=1;

void setup() {
Serial.begin(9600, SERIAL_8N1); // Baud rate: 9600, configuration: CSERIAL_8N1

delay(1000);

Serial.println("baud 9600");

Serial.println("force 25"); //set force level to 50% for syringe size of 20 mL or less (100% for greater than 20 mL)

Serial.println("stop");
Serial.println("irun");

}

and that's my entire code.

However, nothing worked and the pump setting didn't change at all. The light Transmit light on the shield blinks though.

Please help.

Thank you

I'm working on a medical project and I need to control this pump:

Medical??? Something involving people's lives or health??? Are you a doctor, or are you just nuts! :smiley: :smiley: :smiley:

Computer->USB->Arduino Mega-> RS232 shield->RS232 cable-> pump

How about just an RS-232 port for your computer?

In any case, I'd suggest you start on a computer with an RS-232 port and a [u]terminal application[/u]. That will allow you to "manually" send one command at a time (and receive if your pump transmits). That will allow you to confirm the RS-232 configuration (including handshaking, etc). before you try to program anything.

Do as DVDdoug wrote, test it with a computer. Then you know that it is working, and you get some 'feeling' how the device works.

Please connect the device to Serial1, Serial2 or Serial3. That way you can still communicate with the Arduino Mega 2560 via the serial monitor (of the Arduino IDE) and you can still upload sketches.

The next test could be the Arduino in between, and a sketch that transfers from the serial monitor to the device in both directions. Start with the simple "ver" and "status" commands.

The next test is the Arduino sending those commands, and show the result to the serial monitor.

The Arduino Leonardo and Micro have also a spare hardware serial port. You can use those boards as well, if you want a smaller board someday.

The RS-232-to-ttl modules are sometimes very confusing. Some manufacturers exchange RX and TX, or use inverted RX and TX signals. Some devices use 0V for the low level which is not always compatible with the RS-232-to-ttl modules.
The Arduino RX is the input of the Arduino board, the TX is the output of the Arduino board, and the signal is idle high.

PHD Ultra device:
9600...921600 baud. Because of the crystal of 16MHz of the Arduino Mega board, the baudrate is not very precise. Use 9600 for testing.
You use Serial.println(), that prints an extra LineFeed (or was it CarriageReturn + LineFeed ?). According to the documentation, that is not needed.

DVDdoug:
Medical??? Something involving people's lives or health??? Are you a doctor, or are you just nuts! :smiley: :smiley: :smiley:

How about just an RS-232 port for your computer?

In any case, I'd suggest you start on a computer with an RS-232 port and a [u]terminal application[/u]. That will allow you to "manually" send one command at a time (and receive if your pump transmits). That will allow you to confirm the RS-232 configuration (including handshaking, etc). before you try to program anything.

Something involving living cells and hydrogels.
I tried to communicate with the pump and computer through matlab program using USB connection and it worked. But the same process never work when the arduino is in between. I don't have access to a computer with RS232 serial port though. Is there anything else I can do?

Thank you.

Tell us which RS-232-to-ttl module you have. Can you give a link to it ?
Connect it to Serial1. Make a sketch that passes data from one to the other. Type the command in the serial monitor and try to exchange the RX and TX of the RS-232-to-ttl module.