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.
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:
How to program our industrial PLC with Arduino IDE: Installing the Industrial Shields's boards in the Arduino ID.
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 disabled - A0.0 enabled
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 (PWM optional)
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
In order to program the digital outputs, we must keep in mind that we can write the values with the following command:
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:
We must know we do not need to configure the digital outputs as digital. Industrial Shields' libraries do all the work for us.
You can see a digital GPIO written in the following paragraph:
// Digital write example// Set the speed of the serial port
// This example writes the Q0_0 and shows via serial the value
// Setup function
pinMode(Q0_0,OUTPUT); // Only required in ESP32 family products
// Loop function