Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteris

How to use TTL on an industrial Arduino based PLC

Introduction

On this blog we will talk about the Serial communication TLL of our Arduino based industrial controller. Serial or sequential communication, in telecommunications and computers, is the process of sending data one bit at a time sequentially, over a communication channel or a bus. There is another way to send the information, in parallel, when all the bits are sent at the same time, so we have as many lines of communication as the bits we are sending.

The advantage of serial communication is that you need a smaller number of transmission lines than in a parallel communication transmiting the same data. 

Requirements

In order to work with serial TTL  communication, you will need any of our industrial programmable logioc controllers for industrial automation:

Hardware

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

In relation with the pins we use and the switch configuration for our industrial PLC controller Arduino, we need to know that in the Ardbox family we do not have Serial TTL, only by software.

Serial TTL for the M-Duino family, there are the pins RX1 (receiver) and TX1 (transmitter).

For the following models, we need to configure the switches that we see in the image. We need to know that the switches need to be in the OFF position beacuse the On position is not connected.

  • M-DUINO PLC Arduino 21 I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 19R I/Os Analog/Digital PLUS




For the next ones, we need to choose between RX1 , TX1 / I1.1 , I1.0.

  • M-DUINO PLC Arduino 38R I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 57R I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 38AR I/O Analog/Digital PLUS

  • M-DUINO PLC Arduino 53ARR I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 54ARA I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 50RRA I/Os Analog/Digital PLUS



For the next ones we need to choose between RX1 , TX1 / I1.6 , I1.5.

  • M-DUINO PLC Arduino 57AAR I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino  42 I/Os Analog/Digital PLUS

  • M-DUINO PLC Arduino 58 I/Os Analog/Digital PLUS


Software

IMPORTANT:  Make sure to download the Arduino based PLC boards for Arduino IDE. 

Software Configuration

Once the hardware configuration is done, it is possible to proceed with the software configuration and also its usage. Firstly, it is necessary to include the RS232.h library provided in our boards. Then please do not forget to implement the proper initialization of your communication on the setup() function:

In this example, the speed of transmission is 9600bps.

Serial.begin(9600);


Basic Serial TTL write example   

Reads an analog input on  I0.2, prints the result to the serial monitor.

Graphical representation is available using serial plotter (Tools > Serial Plotter menu) on Arduino IDE serial monitor.

// the setup routine runs once when you press reset:
void setup() {
  pinMode(I0_2, INPUT);
// initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(I0_2);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}

In the following example, you can see how to change the speed of transmission.

void setup() {
    Serial.begin(9600);
    Serial1.begin(38400);
    Serial2.begin(19200);
    Serial3.begin(4800);

Serial.println("Hello Computer");
    Serial1.println("Hello Serial 1");
    Serial2.println("Hello Serial 2");
    Serial3.println("Hello Serial 3");
}


Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send