How to use a MAX232 with Arduino based PLC
11 December, 2018 by
How to use a MAX232 with Arduino based PLC
Alejandro Jabalquinto

Introduction

This post it is showed how to connect a Max3232 to an M-Duino PLC family.                                      M-Duino PLC family

Max3232 has two lines of RS-232 communication and their respective two channels of TTL and also power supply pins (3-5,5V-GND). 


Requirements

Ethernet or 20 I/Os PLC:      Ethernet PLC >>>       

Industrial Shields boards:   Industrial Shields Boards >>>


Implementation

How to connect M-Duino PLC with the Max232?

M-Duino has two available serial TTL, RX1/TX1 (or Serial1) and RX3/TX3 (or serial3). Connecting RX1/TX1 with T1IN/R1OUT and RX3/TX3 with T2IN/R2OUT the MAX3232 is ready to transmit and receive the data (don’t forget to connect the power supply). Next, it is shown an electric connections diagram:

 electric connections diagram

Once the connections are set it’s possible to proceed to upload a sketch to test if the MAX232 is working as expected. On this sketch, it’s just used one of them because the other it’s just a copy. Actually, the MAX232 is doing all the hard work, for the user just have to code as a normal TTL serial port using serial1 or serial3 as is shown below.

Example

Next, it is shown the test sketch:

#define TTL Serial1 // Serial1 or Serial3

/////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("ttl started");

  TTL.begin(115200L);
}

/////////////////////////////////////////////////////////////////////////////
void loop() {
  if (Serial.available()) {
    byte in = Serial.read();
    TTL.write(in);
  }

  if (TTL.available()) {
    byte in = TTL.read();
    Serial.write(in);
  }
}

 

Hardware Solutions - Programmable Logic Controllers

Open Source based solutions for automation, monitoring and control

PLC Based on Arduino, Raspberry Pi and ESP 32











Find what you are looking for
Search in our Blog

How to use a MAX232 with Arduino based PLC
Alejandro Jabalquinto
11 December, 2018
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!