|| Back to Support & Help Documentation ||

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

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 Analog HF switches configuration



Ardbox Analog 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 Analog HF is able to:

Available communication protocols & connections:

  • Hardware Serial RS-232

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

  • SPI

  • TTL

  • USB

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

  • Digital Outputs: All 10 Outputs. If using I2C, Q0.6 is disabled.

  • Analog Outputs: From A0.0 to A0.6. If using I2C, A0.6 is disabled.

Note: The switches of the left zone of the RS-485 don’t interfere in the RS-232 HS, the thing is that as pins 0 & 1 are reserved for the RS-232, the RS-485 is totally disabled. As it is disabled, there is no point on configuring these switches as RS-485 mode.

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