Basics about analog outputs of an industrial PLC

December 3, 2019 by
Basics about analog 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 analog outputs of Industrial Shields' programmable logic controllers. Reading this post, you will be able to understand how to connect and configure the analog outputs of your industrial Arduino Controller.

Previous readings

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:

Requirements

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

Industrial Shields controllers: 

Configuring the switches

Most of the analog 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 o 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, analog outputs can work at:

  • 0V - 10V analog output

Analog outputs have a special draw in the case of the PLC:

Analog output Serigraphy

Analog output Serigraphy

Hardware

The following image shows how to connect an analog output to the PLC:

Hardware Analog output 0Vdc -10Vdc

0Vdc -10Vdc Analog output


Software

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

analogWrite(GPIO,value);

This function puts the value of the analog output "A0.0" to 255 (meaning 10V):

analogWrite(A0_0,255);

Example

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

// Analog write example
// This example writes the A0_0 and shows via serial the value

// Setup function
void setup()
{
    // Set the speed of the serial port
    Serial.begin(9600UL);
pinMode(A0_0,OUTPUT); // Only required in ESP32 based PLCs
}

// Loop function
void loop()
{
    Serial.println("Value: 0");    
    analogWrite(A0_0, 0);    
    delay(1000);
    Serial.println("Value: 100");    
    analogWrite(A0_0,100);
    delay(1000);
    Serial.println("Value: 255");
    analogWrite(A0_0,255);
    delay(1000);
}

Basics: Analog outputs in Arduino PLC

​Search in our Blog

Basics about analog outputs of an industrial PLC
Alejandro Jabalquinto December 3, 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 >>>