Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PHD ULTRA syringe Pump communicate with the Arduino

Kamran786

Newbie level 6
Newbie level 6
Joined
Jul 11, 2024
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
207
I have a PHD ULTRA syringe pump from Harvard Apparatus. I want to establish communication between an Arduino and the syringe pump. The company provided me with a Python code, but Arduino does not support Python. Therefore, I converted this code to C++ to make it compatible with the Arduino. I am using an RS-232 to TTL converter between the Arduino and the syringe pump.

However, when I attempted to use this code to establish communication, I encountered issues. Could someone please help me amend this code if there are any errors? I have attached a diagram of my setup and will also attach the Python code provided by the company.

Note: The syringe pump successfully responds and turns ON and OFF when using the pump terminal software provided by the company.

The C++ Code is:
C++:
#include <SoftwareSerial.h>

// Define the pins for RX and TX
#define RX_PIN 2
#define TX_PIN 3

SoftwareSerial pumpSerial(RX_PIN, TX_PIN);

void setup() {
  // Initialize hardware serial for debugging
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect
  }

  // Initialize software serial for pump communication
  pumpSerial.begin(9600);

  Serial.println("Arduino ready to communicate with syringe pump.");
}

void loop() {
  // Command to send
  String command = "run\r\n";

  // Send the command
  Serial.print("Sending command: ");
  Serial.print(command);
  pumpSerial.print(command);

  // Wait for 1 second
  delay(1000);

  // Read and print the response
  String response = "";
  while (pumpSerial.available() > 0) {
    char inChar = (char)pumpSerial.read();
    response += inChar;
  }

  // Print the response if not empty
  if (response != "") {
    Serial.print("Response received: ");
    Serial.println(response);
  } else {
    Serial.println("No response received.");
  }

  // Wait before sending the next command (adjust as needed)
  delay(5000);
}

The python code that the company provided is attached in the picture along with my setup protocol.
If there is some werror in the c++ code, kindly amend it. Thanks inadvance
 

Attachments

  • Syringe protocol.png
    Syringe protocol.png
    452.5 KB · Views: 39
  • python code.png
    python code.png
    26.8 KB · Views: 48
Hi

I can not find where you set up your serial interface for "ODD, 7 bits, 2 stop bits"

You need to do this.

Btw "Arduino" tells us nothing about your used hardware. Please give complete informations.

Klaus
 
Hi

I can not find where you set up your serial interface for "ODD, 7 bits, 2 stop bits"

You need to do this.

Btw "Arduino" tells us nothing about your used hardware. Please give complete informations.

Klaus
Dear Sir.
Thanks for the reply.
I have amended the program and make a new one.
can you check the program and verify its correct or not.
For that ODD, 7 bits, 2 stop bits, io wrote 7O2 in the program,
the program is attached in the reply.
 

Attachments

  • Arduno code by Arduino Forum.txt
    562 bytes · Views: 45

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top