|| Back to Support & Help Documentation ||

Ardbox Analog 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 Analog HF!

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

 Ardbox Analog HF switches configuration 

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



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 serigraphy is only referenced to RS-485 it allows also the RS-232 protocol. 
Having this setup, I0.2 & I0.3 are disabled.



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.

Ardbox Analog HF jumpers configuration

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


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

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

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

  • SPI

  • TTL
    USB

  • Inputs: 8 out of 10 inputs, I0.0, I0.1 & I0.4 to I0.9. * If using I2C, I0.0 is also disabled.

  • Digital outputs: 9 of 10 outputs, Q0_2 is disabled. * If using I2C, Q0.6 is disabled.

  • Analog Outputs: 5 of 6 outputs. A0_2 is disabled If using I2C A0.6 is disabled.


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