I have 2 devices. Device 01 of the manufacturer, well connected to the pump. I use the device 02 connected in series with equipment 01 and pump shaft. I read data the device 01 send for the pump:
Device send frame: 4 40 51 5 and pump answered: 4
This is my Transmission Sequence
But when I disconnect device 01, only connect device 02 and pump. And to send the 4 40 51 5 to the pump , no feedback from the pump . This is my code:
#include <SoftwareSerial.h>
#define SSerialRX 0 //Serial Receive pin
#define SSerialTX 1 //Serial Transmit pin
#define SSerialTxControl 2 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX
int msg1[] = {0x4, 0x40, 0x51, 0x5};
int Received;
int i;
void setup()
{
Serial.begin(19200);
pinMode(SSerialTxControl, OUTPUT);
digitalWrite(SSerialTxControl, RS485Receive); //
RS485Serial.begin(19200);
}
void loop()
{ /
digitalWrite(SSerialTxControl, RS485Transmit); //
for (i = 0; i < sizeof(msg1); i++) {
RS485Serial.write(msg1[i]);
delay(1.7);
} // gửi dữ l
delay(1.7);
digitalWrite(SSerialTxControl, RS485Receive); //
if (RS485Serial.available())
{
Received = RS485Serial.read(); //gets one byte from serial buffer
Serial.println(Received, HEX);
}
}
when you connect multiple devices onto a common network there normally is some form of unique identifier (address) that you would need to send along with your request so that you get a reply from the device you are targeting.
do you know if device 1 and 2 have and address identifier and if yes what are they?
Device 01 is master to control Pump.
My Pump with address: 01
EOT: 4 (Start bit)
SA: 40 (Station address: 40<=>@ <=> 01)
UA: 51 (Method Polling)
ENQ: 5 (Stop bit)
If the pump receives the data (4 40 51 5), it will respond to the data (4)
shinsozach:
Device 01 is master to control Pump.
My Pump with address: 01
EOT: 4 (Start bit)
SA: 40 (Station address: 40<=>@ <=> 01)
UA: 51 (Method Polling)
ENQ: 5 (Stop bit)
If the pump receives the data (4 40 51 5), it will respond to the data (4)
what about device 2... that the issue you raise in you original post. what is its address?
You wrote in the first post:"I have 2 devices. Device 01 of the manufacturer, well connected to the pump. I use the device 02 connected in series with equipment 01 and pump shaft. I read data the device 01 send for the pump:".
But your diagram shows device 1 and 2 are connected in parallel to the pump.
Out of interest, other than going through the datasheet/manual to get the message set, did not sniff the rs485 network when Device1 was connected to see what was ACTUALLY transmitted?
There might just be more to it that just those few bytes which could be why you are not getting any response...
I use Arduino Mega2560. This is my code when not connected to the pump
#define SSerialTxControl 2 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
byte msg1[] = {0x4};
byte Received;
int i;
void setup()
{
Serial.begin(19200);
Serial1.begin(19200);
}
void loop()
{
Serial1.write(msg1[0]);
if (Serial1.available())
{
Received = Serial1.read(); //gets one byte from serial buffer
Serial.println(Received);
}
}