|| Back to Support & Help Documentation ||

Ardbox Relay RS-485

Serial Communication Standard 

RS-485 also known as TIA-485(-A), EIA-485, is a standard defining the electrical characteristics of drivers and receivers for use in serial communications systems. Electrical signaling is balanced, and multipoint systems are supported.

Our Arduino Based PLCs incorporate the integrated circuit MAX485.

MAX485 is a low-power and slew-rate-limited transceiver used for RS-485 communication. It works at a single +5V power supply and the rated current is 300 μA. Adopting half-duplex communication to implement the function of converting TTL level into RS-485 level, it can achieve a maximum transmission rate of 2.5Mbps. MAX485 transceiver draws supply current of between 120μA and 500μA under the unloaded or fully loaded conditions when the driver is disabled.

There is internally installed a half duplex MAX485 and MAX485 transmitter. If you are working on full duplex you will use the MAX485 half duplex to receive data and MAX485 transmitter to send the data.



MAX485 pin configuration and Typical Operating Circuit

Hardware

Check the new Ardbox Relay HF!

IMPORTANT: Make sure that your Ethernet PLC is powered (12-24Vdc).

 

 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

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



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

Using this jumpers configuration, your Ardbox Relay HF is able to:

Available communications protocol & connections
  • Hardware Serial RS-485.

  • I2C If I2C is active, I0.0 & R5 are disabled.

  • SPI

  • TTL
    USB

  • Inputs: All 10 inputs except for input I0.4, I0.5 as they are disabled from the LEFT ZONE switch. * If using I2C, I0.0 is also disabled.

  • Relay outputs: From R1 to R6. * If using I2C, R5 is disabled. R7 and R8 are disabled from the TOP ZONE switch.

  • Analog Outputs:  A0.0 & A0.1 if RS-485 is working in Half Duplex. They are disabled if using RS-485 Full Duplex. See the JUMPER ZONE 1 from above.


Connections
Connections will be different depending on whether we want to use RS-485 in half-duplex or full-duplex.
To do the full duplex test you must connct the A, B (receivers) to the Y, X(transmitters). For half duplex you must connect with another device with RS-485 and select if you want to transmit or receive data by Software (shown below).

Software

IMPORTANT: Make sure to download the  Arduino based PLC boards for Arduino IDE.
Software Configuration:
    Once the hardware configuration is done, it's possible to proceed with the software configuration and also its usage. Firstable            it's necessary to include the RS485.h library provided in our boards.    

    To check if the RS-485 port is working it is easy to use the serial monitor from the Arduino IDE using the right sentence inside     the setup() function:
      

Serial.begin(9600);

Then don’t forget to implement the proper initialization of your communication on the setup() function

RS485.begin(38400);

NOTE: Check the velocity of transmition between the PLC and the Laptop and from the PLC to the device connected by RS-485.


RS-485 Library - Functions

* Remember that all the devices have to communicate at the same baudrate.



RS485.begin(baud); //sets the baud rate for RS485 data transmision
RS485.read(); //reads incoming RS485 data
RS485.write(byteToSend); //write binary data to RS485 port
RS485.write(dataToSend, dataLength); //write binary data to RS485 port
RS485.available() //returns the number of bytes available for reading on RS485 port


 This is all it’s necessary to know to use RS-485 on Industrial Shields equipments. Finally it is showed an example using RS-485.


Example Codes


Basic RS-485 write example (send):

// Include Industrial Shields libraries
#include <RS485.h>

//// IMPORTANT: check switches configuration

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
	Serial.begin(9600);

  // Begin RS485 port
  RS485.begin(38400);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Wait bytes in the serial port
  if (Serial.available()) {
    byte tx = Serial.read();

    // Echo the byte to the serial port again
    Serial.write(tx);

    // And send it to the RS-485 port
    RS485.write(tx);
  }
}


Basic RS-485 read example (receive):

// Include Industrial Shields libraries
#include <RS485.h>

//// IMPORTANT: check switches configuration

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
	Serial.begin(9600);

  // Begin RS485 port
  RS485.begin(38400);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Print received byte when available
  if (RS485.available()) {
    byte rx = RS485.read();

    // Hexadecimal representation
    Serial.print("HEX: ");
    Serial.print(rx, HEX);

    // Decimal representation
    Serial.print(", DEC: ");
    Serial.println(rx, DEC);
  }
}

Basic RS-485 full-duplex example:

* Remember that to do the full duplex test you must connect the A, B (receivers) to the Y, X(transmitters).

// Include Industrial Shields libraries

#include <RS485.h>


//// IMPORTANT: check switches configuration

//// IMPORTANT: Full duplex mode is only available when device supports it


////////////////////////////////////////////////////////////////////////////////////////////////////

void setup() {

  // Begin serial port

Serial.begin(9600);


  // Begin RS485 port

  RS485.begin(38400, FULLDUPLEX);

}


////////////////////////////////////////////////////////////////////////////////////////////////////

void loop() {

  // Wait bytes from the RS-485

  if (RS485.available()) {

    byte tx = RS485.read();


    // In full-duplex mode it is possible to send and receive data

    // at the same time in a secure way

    RS485.write(tx);


    // Echo the byte to the serial port

    Serial.write(tx);

  }

}

By following these steps carefully, you will be able to achieve the use of the RS-485 protocol using the Industrial Shields equipments.


1 Star 2 Star 3 Star 4 Star 5 Star