element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog PHD ULTRA syringe pump communicate with Arduino
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Zainii
  • Date Created: 27 Jul 2024 3:49 AM Date Created
  • Views 457 views
  • Likes 1 like
  • Comments 4 comments
  • arduino uno
  • ttl
  • programming
  • syringe Pump
  • rs 232
Related
Recommended

PHD ULTRA syringe pump communicate with Arduino

Zainii
Zainii
27 Jul 2024

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:

#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 provide and the Setup picture is attached in the picture form.
If someone amend my code or tell where i am doing some error, i shall be very thankful to you.

{gallery}My Gallery Title

image

Pyhton Code

image

My setup prototype

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

REPLACE THIS TEXT WITH YOUR IMAGE

IMAGE TITLE: THEN IMAGE DESCRIPTION

  • Sign in to reply

Top Comments

  • beacon_dave
    beacon_dave 9 months ago +1
    "...However, when I attempted to use this code to establish communication, I encountered issues...." And what issues did you encounter ? Perhaps take a closer look at the serial configuration in…
  • beacon_dave
    beacon_dave 9 months ago

    Duplicate thread at:

    https://forum.allaboutcircuits.com/threads/phd-ultra-syringe-pump-communicate-with-the-arduino.202134/

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave 9 months ago in reply to Zainii

    Try

    pumpSerial.begin(9600, SERIAL_7O2);

    or

    Serial1.begin(9600, SERIAL_7O2);

    https://www.arduino.cc/reference/en/language/structure/further-syntax/define/

    https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Zainii
    Zainii 9 months ago in reply to beacon_dave

    Dear Sir.
    Thanks for your precious time.
    I worked on the code and do lot of changes in the code, can you look at the code and tell me if there is still any error or not.
    Moreover, i am going to buy Arduino Mega that has multiple port.
    I have little bit confusion about one line.
    can you tell me which one i should use.
    1:      pumpSerial1.begin (9600, SERIAL_7O2);
    2:      pumpSerial.begin (9600, SERIAL_7O2);

    The code is attached below

    #define pumpSerial Serial1
    
    void setup() {
      Serial.begin(9600);
      pumpSerial1.begin (9600, SERIAL_7O2);
      Serial.println("Arduino ready to communicate with syringe pump.");
      pumpSerial.print("run\r\n");
      delay(1000);
    }
    
    void loop() {
     static char Line[30];
    
      if (pumpSerial.available() > 0) {
        Line = pumpSerial.readString();
        Serial.print(Line);
      }
      
      if (Serial.available() > 0) {
        Line = Serial.readString();
        pumpSerial.print(Line);
      }
    
      // Wait before sending the next command (adjust as needed)
      delay(5000);
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave 9 months ago

    "...However, when I attempted to use this code to establish communication, I encountered issues...."

    And what issues did you encounter ?

    Perhaps take a closer look at the serial configuration in the Python code ?

    image

    You may need to modify the software serial library to support that serial configuration, or switch to an Arduino device that has two hardware UARTs.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube