I have a syringe pump with a controller, and it should be possible based on the instruction manual to communicate the controller directly through UART (4 pins), sending commands like "q1h1d".
I've been searching quite a lot but couldn't find something very usefulll to me!
I would like first to test this possibility independently from Arduino, using a UART USB cable and maybe a software like puTTY. Maybe does someone have a better idea?
Using Arduino (or Matlab) would be ideal, but I don't even really understand even how to wire it. If someone would have some hints for a completely newby in this UART / data packets exchange story, this would be great!
There is only one page in the chinese manual, stating following:
"support the USB communication and serial UART communication, and can drive the host computer following UART to RS232 and CAN bus. It can be directly driven by the computer".
The rest are the commands to be sent to execute some actions like "q6h1d" for "save parameters" etc, which would be otherwise done by pushing the buttons of the controllers.
Hope this helps to understand the situation better
do you have a link to the technical documentation?
if there is an UART interface, you need to know the configuration (baud rate, stop bits, etc) and of course the command format and response if any (the communication protocol)
It looks like the device has an RS232 Serial interface. If so, then it is not directly compatible with the output from an Arduino and you will need a TTL to RS232 converter between the two of them
that's already a good start.... we don't know exactly the interface if it's 5V UART...
if you are bold enough to give it a try, possibly with a suitable adapter on pin 2 and 3, I would try simple code like this that issues those 3 commands with a trailing CR/LF (which might not be needed or will confuse the module, in which case try with print() instead of println())
/*
RX is digital pin 2 (connect to TX of other device)
TX is digital pin 3 (connect to RX of other device)
GND are connected
*/
#include <SoftwareSerial.h>
SoftwareSerial syringe(2, 3); // RX, TX
const char * manualFwd = "q6h4d";
const char * manualBwd = "q6h5d";
const char * manualStop = "q6h6d";
void setup()
{
Serial.begin(115200);
syringe.begin(9600);
delay(2000); // wait a bit in case system needs to settle
// go forward for 1s
syringe.println(manualFwd);
delay(1000);
// stop
syringe.println(manualStop);
delay(1000);
// go backward for 1s
syringe.println(manualBwd);
delay(1000);
// stop
syringe.println(manualStop);
}
void loop() {
// print anything at we get back
if (syringe.available()) {
int c = syringe.read();
if (isprint(c)) Serial.write(c);
else {
switch (c) {
case '\r': Serial.print(F("<CR>")); break;
case '\n': Serial.print(F("<LF>")); break;
case '\t': Serial.print(F("<TAB>")); break;
default:
Serial.print(F("0x"));
if (c < 0x10) Serial.write('0');
Serial.print(c, HEX);
}
}
Serial.write(' ');
}
}
if that works then you can explore the other commands
Thanks a lot! Before I try, just to be sure for the wiring:
On the left the connection to the pump itself
On the right, the communication port where I installed some cables
My first choice would also be trying to talk to it over puTTY or another serial terminal.
BTW: there is also this project on github for DIY infusion pump using arduino & the CNC shield that works pretty well. It includes CAD files for 3D printing a holder for the stepper motors and syringes. Haven't used it personally, but I'm working with someone who does.
[edit]
I guess a lot happened in the last few hours before I finished my reponse
pins 0 and 1 are what's connected to the USB and your serial monitor to see what's going on as well as uploading code. (it's Serial basically - you don't want to mess with it until your code is rock solid and you don't need to upload anymore)
so you needed a second serial port and the UNO does not have hardware one. So using SoftwareSerial we created a "fake" one on pins 2 and 3 which we use to discuss with the syringe