Look for in our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

RS485 Troubleshooting Guide

Troubleshooting of RS485, step by step:

  • Ensure that the controller is powered between 12-24 Vdc.

  • Half Duplex Communication: Ensure that you are connecting the pin A+ of your Industrial Shields controller with the pin A+ of the other RS485 device. And the pin B- of your Industrial Shields controller with the pin B- of the other RS485 device. Full Duplex Communication: Ensure that you are connecting the pin A+ of your Industrial Shields controller with the pin Y+ of the other RS485 device. And the pin B- of your Industrial Shields controller with the pin Z- of the other RS485 device.
    Proper connections: 

Industrial Shields Unit (Half Duplex)RS485 Device (Half Duplex)
A+A+
B-B-
Industrial Shields Unit (Full Duplex)RS485 Device (Full Duplex)
A+Y+
B-Z-
  • Proper switch and jumper configuration to use the RS-485 port.


M-Duino family:


For the RS-485 communication protocol there is only one switch that affects in this communication. The RS-485 protocol will be always enabled, the only switch that affects is the one called "FD rs-485 HD". This switch makes the choosing between RS-485 HalfDuplex (ON Position) or RS-485 Full Duplex (OFF Position).




Ardbox family:


Ardbox Analog HF:


In order to enable the Hardware Serial RS-485 the total configuration of the Ardbox Analog HF will be: 


TOP ZONE:

SWITCHMODE
I0.3OFF
RS485 HSON
I0.2OFF
RS485 HS
ON

Note: Having this setup, I0.2 & I0.3 are disabled.


LEFT ZONE:

SWITCHMODE
DE-RS485ON
D10 / A0.2 - Q0.2OFF
RE-RS485ON
D11 / A0.1 - Q1.1OFF
SDA - D2 / I0.0-
SCL - D3 / Q0.6-

Note: In order to enable the RS-485 communication protocol it is necessary that the switches of the left zone are configured as it is showed in the table. The ones marked with "-" mean that they don't affect the RS-485 protocol configuration.


Jumpers Configuration

In order to enable the Hardware Serial RS-485 the total configuration of the Ardbox Analog HF will be:




Ardbox Relay HF:

In order to enable the Hardware Serial RS-485 the total configuration of the Ardbox Relay HF will be:

Ardbox Relay HF switches configuration 



Note: In order to enable the RS-485 protocol the TOP ZONE must be configured as it is shown in the table. Although the switch name is only referenced to RS-485 it is also the same for the RS-232.


Note: The H/F can be set up as ON or OFF. If it is wished to use the RS-485 Half Duplex (A+, B-) it has to be ON. For using the RS-485 Full Duplex (A+, B-, Y+, Z-) it has to be OFF.


The switch RE-RS485 and DE-RS485 must be set in ON mode. As these pins are set to ON, the other 2 (I0.4, I0.5) must be set to OFF. Being in OFF mode they are completely disabled. The switches marked as “ – “ don’t interfere with the RS-485 communication protocol.

Ardbox Relay HF jumpers configuration




Note: Jumper zone 2 has no effect on the RS-485 protocol but it allows us having I0.2 & I0.3 available.



Installing industrial Shields boards


*Attention do not use old libraries like MDuino.h or Ardbox.h, these libraries are deprecated and can cause mapping issues to your controller. 


M-Duino family: 

Arduino Mega 2560 Rev3 is the controller of the M-Duino and RS-485 is controlled with the Serial0 of Arduino Mega 2560 Rev3. If for some reason you are not using our boards make sure that you are using Serial0 to control RS-485. 


Ardbox Analog HF w/HW RS232:

If you use the Ardbox Analog HF w/HW RS232 hardware serial you just have to include RS485.h library in your sketch and select the right board ARDBOX Analog HF w/HW RS485. Use object RS485 to write and read values though your RS485 serial port. See the below code example of how to use RS485 object.


Ardbox Relay HF w/HW RS232:

If you use the Ardbox Relay HF w/HW RS485 (hardware serial) you just have to include RS485.h library in your sketch and select the right board ARDBOX Relay HF w/HW RS485. Use object RS485 to write and read values though your RS485 serial port. See the below code example of how to use RS485 object.


Software Example:

To verify that the reception and the transmision work, we have done this program that at the same board we receive or transmit a byte. Because of this we use the FULLDUPLEX configuration. In this example we only sends a byte through the Serial, receive it, print it and send it through the RS485. Then, we receive the same byte and print it. 

#include <RS485.h>

void setup() {
  // Begin Serial port
  Serial.begin(9600);
  // Begin RS485 port
  RS485.begin(9600, FULLDUPLEX);
}

void loop() {
  //Send one byte for the serial, receive this byte by rs485
  if (Serial.available()){
    read_from_serial();
  }
  if (RS485.available()){
    read_from_rs485();
  }
}

static void read_from_serial(void){
  char tx = Serial.read(); //Read byte
  if (tx != '\n') Serial.println(tx); //Print the byte 
  RS485.write(tx); //Transmit by rs485
}

static void read_from_rs485(void){
  char rx = RS485.read(); //Receive the same byte
  if (rx != '\n') Serial.println(rx); //Print the byte
}