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

Basics about digital inputs of an industrial controller

Learning how to do the basics when working with digital inputs of an industrial Arduino

Introduction

On this post, we are going to explain how to do the basics when working with digital inputs of Industrial Shields PLC controller. With this post, you will be able to understand how to connect and configure the PLCs to be sure you will be able to read the digital inputs.

Previous reading

We recommend you to read the following blogs in order to understand the program of this blog. We used the following blog posts to do this example:

Requeriments

In order to work with digital inputs you will need any of our PLC for industrial automation:

Configuring the switches

Almost all the digital inputs are always connected to the internal Arduino, but in a few cases, the user can choose a special peripheral configuration, or a GPIO normal working.

In these cases, the user can choose between two options through the switches

Each switch can select only one configuration. For example, in this case we are watching the GPIOs configuration of a M-Duino 57R+. If we put the switch to the right in the upper one, the input I2.1 will be activated and we will be able to work with this input as digital. If the switch is in the left position, we will activate the SCL line which will be used for I2C communication. Keep in mind each switch has two different configurations: you must select the right or the left option.

Odoo - Sample 1 for three columns

I2.1 input enabled - SCL disabled

Odoo - Sample 2 for three columns

I2.1 input disabled - SCL enabled

Input types

There are three different types of inputs in the Industrial Shields PLCs:

  • 7V - 24V input
  • 7V - 24V optoisolated input
  • 5V input

Each one has a particular draw in the case of the PLC. Remember only the Pin 2 and Pin 3 are 5V compatibles:

Odoo - Sample 1 for three columns

7V - 24V optoisolated input

 

Odoo - Sample 2 for three columns

7V - 24V input

 

Odoo - Sample 3 for three columns

5V input


Hardware

Not all the inputs must be connected in the same way. While the non-isolated inputs must be referenced to the same ground as the PLC, the isolated inputs can be connected to the input grounds, allowing to isolate systems from the PLC. Anyway, the optoisolated input can be connected to the PLC ground aswell.

The following images show how to connect the different inputs to the PLC for industrial automation:

Odoo - Sample 1 for three columns

7V - 24V optoisolated input

 

Odoo - Sample 2 for three columns

7V - 24V input

 

Odoo - Sample 3 for three columns

5V input


Software

In order to program the digitals GPIO, we must keep in mind we can read the values with the following command:

digitalRead(GPIO);

This function returns "0" or "1" depending of the actual value of the input. 
GPIO is the name of the input. Imagine we want to know the state of the "I0.4" input, then, we must write this line:

digitalRead(I0_4);

The inputs "2" and "3" does not have an special name, and for read them we must write:

digitalRead(2);
digitalRead(3);

We must keep in mind we do not need to configure the digital inputs of the PLC as digital ones, except with the 5V compatible inputs. It means we must configure the inputs in the setup before read them:

pinMode(2,INPUT);
pinMode(3,INPUT);

Examples

You can see a read digital GPIO example in the following paragraph:

// Digital read example
// This example reads the I0_10, I0_2 and Pin 2 inputs, and shows via serial if they are active

// Setup function
void setup()
{
    
    // Set the speed of the serial port
    Serial.begin(9600UL);

    // Configure Pin 2 as a digital input
    pinMode(2, INPUT);
}

// Loop function
void loop()
{
    // Check Pin 2
    if (digitalRead(2))
        Serial.println("Pin 2 active");    
    
    // Check I0_10
    if(digitalRead(I0_10))
        Serial.println("I0_10 active");
    
    // Check I0_2
    if(digitalRead(I0_2))
        Serial.println("I0_2 active");

Basics: Digital inputs in Arduino PLC


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