RS485 Device Not Communicating

Hi All,
I am using a Mega, with a RS485 module, and trying to communicate with a digital flowmeter. I can see that messages are being transmitted, but I don’t see anything coming back. Any ideas what might be going on here?

Mega Module Flowmeter
5V VCC
GND GND
19 DI
18 RO
3 DE&RE
A 485+
B 485-

/

/*-----( Import needed libraries )-----*/
#include <SoftwareSerial.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define SSerialRX        19  //Serial Receive pin
#define SSerialTX        18  //Serial Transmit pin

#define SSerialTxControl 3   //RS485 Direction control

#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         13

/*-----( Declare objects )-----*/
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX

/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(19200);
  Serial.println("YourDuino.com SoftwareSerial remote loop example");
  Serial.println("Use Serial Monitor, type in upper window, ENTER");
  
  pinMode(Pin13LED, OUTPUT);   
  pinMode(SSerialTxControl, OUTPUT);    
  
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver   
  
  // Start the software serial port, to another device
  RS485Serial.begin(9600);   // set the data rate 

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if (Serial.available())
  {
    byteReceived = Serial.read();
    
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit   
    RS485Serial.write(byteReceived);          // Send byte to Remote Arduino
    
    digitalWrite(Pin13LED, HIGH);  // Show activity    
    delay(10);
    digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit       
  }
  
  if (RS485Serial.available())  //Look for data from other Arduino
   {
    digitalWrite(Pin13LED, LOW);  // Show activity
    byteReceived = RS485Serial.read();    // Read received byte
    Serial.write(byteReceived);        // Show on Serial Monitor
    delay(10);
   }  

}//--(end main loop )---

Have you set up the meter properly to use the serial port? If so, what options did you select?

Is the logger enabled and is the output directed to serial?

Have you tried any of the meter’s built in serial debugging capabilities? I see that window M49 displays the incoming characters on the port.

jgatvl:
Hi All,
I am using a Mega, with a RS485 module, and trying to communicate with a digital flowmeter. I can see that messages are being transmitted, but I don’t see anything coming back. Any ideas what might be going on here?

Mega Module Flowmeter
5V VCC
GND GND
19 DI
18 RO
3 DE&RE
A 485+
B 485-

/

/-----( Import needed libraries )-----/
#include <SoftwareSerial.h>
/-----( Declare Constants and Pin Numbers )-----/
#define SSerialRX        19  //Serial Receive pin
#define SSerialTX        18  //Serial Transmit pin

#define SSerialTxControl 3   //RS485 Direction control

#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         13

/-----( Declare objects )-----/
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX

/-----( Declare Variables )-----/
int byteReceived;
int byteSend;

void setup()   /****** SETUP: RUNS ONCE ******/
{
 // Start the built-in serial port, probably to Serial Monitor
 Serial.begin(19200);
 Serial.println(“YourDuino.com SoftwareSerial remote loop example”);
 Serial.println(“Use Serial Monitor, type in upper window, ENTER”);
 
 pinMode(Pin13LED, OUTPUT);  
 pinMode(SSerialTxControl, OUTPUT);    
 
 digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver  
 
 // Start the software serial port, to another device
 RS485Serial.begin(9600);   // set the data rate

}//–(end setup )—

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
 if (Serial.available())
 {
   byteReceived = Serial.read();
   
   digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit  
   RS485Serial.write(byteReceived);          // Send byte to Remote Arduino
   
   digitalWrite(Pin13LED, HIGH);  // Show activity    
   delay(10);
   digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit      
 }
 
 if (RS485Serial.available())  //Look for data from other Arduino
  {
   digitalWrite(Pin13LED, LOW);  // Show activity
   byteReceived = RS485Serial.read();    // Read received byte
   Serial.write(byteReceived);        // Show on Serial Monitor
   delay(10);
  }

}//–(end main loop )—

It looks like you have TX and RX reversed,

Arduino Pin 18 it TX1, which should be connected to DI.
Arduino Pin 19 is RX1, which should be connected to RO.

Also, because your are switching from RX to TX modes, the RO signal goes from Active to TriState, and since the MAX485 it is not driving RO while it is Tri-Stated, The signal drifts to LOW, which cause the Arduino’s UART(SERIAL1) to think it is seeing a new block of bits, It starts building a byte, Usually 0xFF. To inhibit this erroneous action, put a weak(10k-50k) pullup resistor between VCC and RX1(pin 18).

Why are you using SoftwareSerial.h, Just use Serial1

/*-----( Import needed libraries )-----*/

#define SSerialTxControl 3   //RS485 Direction control

#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         13

/*-----( Declare objects )-----*/

/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(19200);
  Serial.println("YourDuino.com SoftwareSerial remote loop example");
  Serial.println("Use Serial Monitor, type in upper window, ENTER");
  
  pinMode(Pin13LED, OUTPUT);   
  pinMode(SSerialTxControl, OUTPUT);    
  
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver   
  
  // Start the software serial port, to another device
  Serial1.begin(9600);
 
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if (Serial.available())
  {
    byteReceived = Serial.read();
    
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit   
    Serial1.write(byteReceived);          // Send byte to Remote Arduino
    
    digitalWrite(Pin13LED, HIGH);  // Show activity    
    Serial1.flush(); //delay(10);
    digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit       
  }
  
  if (Serial1.available())  //Look for data from other Arduino
   {
    digitalWrite(Pin13LED, LOW);  // Show activity
    byteReceived = Serial1.read();    // Read received byte
    Serial.write(byteReceived);        // Show on Serial Monitor
    Serial.flush();// delay(10);
   }  

}//--(end main loop )---

Chuck.

Hi guys-

Thanks very much for the replies. From following this, I now have transmission abilities, and am seeing the sent messages on the meter via M49. I am having some issues receiving responses now; I have a 10k pull up between VCC and RX1 (pin19) per Chuck's recommendation, but there is basically no reply from the meter. I'm not sure if this is because of a hardware issue, or not sending the right ASCII/RTU codes to the meter. I've tried both ASCII and RTU settings in M63 using the example text on page 40 of the manual. Have also tried different variations of this; changing the formatting, unit #, ect. I've also read that this might need to be converted to hex before sending, but that doesn't seem to make sense to me.

Additionally, under the ASCII selection, there is a sub-menu for "Compatible Protocol", which has 15 options including CRL-G, SCL-61D, SCL-6, SCL-7X, ect. The unit seems to default to SCL-61D.

Any ideas? Thanks again!

jgatvl: Hi guys-

Thanks very much for the replies. From following this, I now have transmission abilities, and am seeing the sent messages on the meter via M49. I am having some issues receiving responses now; I have a 10k pull up between VCC and RX1 (pin19) per Chuck's recommendation, but there is basically no reply from the meter. I'm not sure if this is because of a hardware issue, or not sending the right ASCII/RTU codes to the meter. I've tried both ASCII and RTU settings in M63 using the example text on page 40 of the manual. Have also tried different variations of this; changing the formatting, unit #, ect. I've also read that this might need to be converted to hex before sending, but that doesn't seem to make sense to me.

Additionally, under the ASCII selection, there is a sub-menu for "Compatible Protocol", which has 15 options including CRL-G, SCL-61D, SCL-6, SCL-7X, ect. The unit seems to default to SCL-61D.

Any ideas? Thanks again!

If you can either upload the reference guide or provide a link, we might be able to decode the instructions. Without it, I've done everything I know.

Chuck.

Apologies Chuck- the manual is linked in my original post, or here. Thanks again for the help!

jgatvl: Apologies Chuck- the manual is linked in my original post, or here. Thanks again for the help!

Reading through the manual, What are the values for the following 'Windows"

M46 M49 M52 M62 M63

Chuck

Chuck- Thanks again so much for the help; I've added comments to the quote below. Please let me know if there's anything else than can be useful!

chucktodd: Reading through the manual, What are the values for the following 'Windows"

M46 - 1 M49 - shows whatever I send via Arduino IDE Serial M52 - 0. Internal SerBus M62 - 9600,None,8,1 M63 - MODBUS ASCII+ TDS7 (though I've changed this to try RTU with no luck either)

Chuck

To add, it looks like M52 is just for the data-logger. I’ve changed this to “Send to RS485”, but still don’t see any response.

Seems that maybe some of the passive components on the RX side of the breakout module were bad. I replaced it and have good comms! Thanks Chuck.

jgatvl: Seems that maybe some of the passive components on the RX side of the breakout module were bad. I replaced it and have good comms! Thanks Chuck.

Have fun measuring the World!

Chuck.