|| Back to Support & Help Documentation ||

Ardbox Relay RS-232

Serial Communication Standard

RS-232 protocol formally defines the signals connecting between DTE (Data Terminal Equipment) such as a computer terminal, and DCE (Data Circuit-terminating Equipment or Data Communication Equipment), such as a modem.

Our Arduino Based PLCs incorporate the integrated circuit MAX232.

MAX232 converts signals from to TIA-232 (RS-232) serial port to signals suitable for use in TTL-compatible digital logic circuits. The MAX232 is a dual transmitter / dual receiver that is used to convert the RX, TX, CTS, RTS signals.

MAX220, MAX232, MAX232A: Pin Configuration and Typical Operating Circuit 


MAX232 Pin Configuration and Typical Operating Circuit


Hardware

Check the new Ardbox Relay HF!

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

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

Ardbox Relay HF switches configuration

                                    

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


                                    

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.

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

Available communication protocols & connections:
  • Hardware Serial RS-232

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

  • SPI

  • TTL

  • USB

  • Inputs: All 10 inputs, I0.0 to I0.9. * If using I2C, I0.0 is disabled.

  • Relay Outputs: From R1 to R6. * If using I2C, R5 is disabled. R7 & R8 are disabled from the TOP ZONE Switch.

  • Analog Outputs: A0.0 & A0.1.

 Connections

The right connections between the desired devices are showed 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 RS232.h library provided in our boards.

#include <RS232.h> 

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

 RS232.begin(9600);


RS-232 Library - Functions

* Remember that both devices have to communicate on the same baud rate. 

Now everything is ready to start using the RS232 functions or methods. RS232 is a class that can use the same methods than Serial class. Take a look on Arduino web site references to see the different available functions. The most used methods that every Industrial Shields developed has to know are:



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


 This is all it’s necessary to know to use RS232 on Industrial Shields equipment’s. Finally it is showed an example using RS232.

Example codes


Basic RS-232 write example:

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

//// IMPORTANT: check switches configuration

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

  // Begin RS232 port
  RS232.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-232 port
    RS232.write(tx);
  }
}

 Basic RS-232 read example:

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

//// IMPORTANT: check switches configuration

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

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

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

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

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


1 Star 2 Star 3 Star 4 Star 5 Star