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

Basics about digital outputs of an industrial PLC


Introduction

On this post, we are going to explain how to do the basics in order to work with digital outputs of Industrial Shields' programmable logic controllers. Reading this post, you will be able to understand how to connect and configure the digital outputs of your industrial Arduino PLC controller.

Previous reading

We recommend you to read the following posts 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 outputs you will need any of our industrial controllers for industrial automation:

Configuring the switches

Most of the digital outputs are always connected to the internal Arduino, but in few cases, the user can choose between a special peripheral configuration or a GPIO by changing the position of the Dip Switches.

Each switch can select only one configuration. For example, in this case we are watching the GPIOs configuration of an M-Duino 21+. If we put the switch to the right position (ON) in the lower one, the output Q0.0 will be activated and we will be able to work this as digital. If the switch is in the left position (OFF) we will activate the output as analog. Keep in mind each switch has two different configurations: you must select the right (ON) or the left (OFF) option.

Odoo - Sample 1 for three columns

Q0.0 enabled - A0.0 disabled

Odoo - Sample 2 for three columns

Q0.0 disabled - A0.0 enabled

Input types

In all of the Industrial Shields Arduino based PLCs, digital outputs can work at:

  • 5V -24V digital output

Digital outputs have a special draw in the case of the PLC. Keep in mind the output which can handle PWM is the same as the other digital outputs, but we will talk about it in other blog post:

Odoo - Sample 1 for three columns

Digital output

Odoo - Sample 2 for three columns

Digital output (PWM optional)

Hardware

All the digital outputs are opto-isolated (they use the same GNDs as the PLC). The image below shows how to connect a digital output to the PLC:

Odoo - Sample 2 for three columns

5Vdc - 24Vdc Digital output

Software

In order to program the digital outputs, we must keep in mind that we can write the values with the following command:

digitalWrite(GPIO,value);

This function writes a "HIGH" or "LOW" in the "GPIO" selected. Imagine we want write a "HIGH" in the "Q0.6" output, then, we must write this line:

digitalWrite(Q0_6,HIGH);

We must know we do not need to configure the digital outputs as digital. Industrial Shields' libraries do all the work for us.

Example

You can see a write digital GPIO in the following paragraph:

// Digital write example
// This example writes the Q0_0 and shows via serial the value

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

// Loop function
void loop()
{
    Serial.println("1");    
    digitalWrite(Q0_0, HIGH);
    Serial.println("0");
    digitalWrite(Q0_0, LOW);
}

Basics: Digital outputs 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