Basics about digital outputs of an industrial PLC

November 21, 2019 by
Basics about digital outputs of an industrial PLC
Alejandro Jabalquinto


Index

Introduction

In 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 read the following posts in order to understand the program of this blog. We used the following blog posts to do this example:

Requirements

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

Industrial Shields controllers:

Configuring the switches

Most of the digital outputs are always connected to the internal Arduino, but in a 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.

Q0.0 enabled - A0.0 disabled

Q0.0 enabled - A0.0 disabled

Q0.0 disabled - A0.0 enabled

Q0.0 disabled - A0.0 enabled

Output 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 that the output that can handle PWM is the same as the other digital outputs, but we will talk about it in another blog post:

Digital Output

Digital output

Digital output (PWM optional)

Digital output (PWM optional)

Hardware

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

5Vdc - 24Vdc Digital output

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 to 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 digital GPIO written 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);
pinMode(Q0_0,OUTPUT); // Only required in ESP32 family products

}

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

Basics: Digital outputs in Arduino PLC



​Search in our Blog

Basics about digital outputs of an industrial PLC
Alejandro Jabalquinto November 21, 2019

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