Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteris
Learning the basics about analog inputs of an industrial PLC
On this post, we are going to explain how to do the basics in order to work with analog inputs of Industrial Shields' programmable logic controllers. Reading this post, you will be able to understand how to connect and configure the analog inputs of your industrial Arduino PLC controller.
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:
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 analog inputs 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 a M-Duino 57R+. If we put the switch to the right position (ON) in the upper one, the input I2.1 will be activated and we will be able to work with this as input. If the switch is in the left position (OFF) 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 (ON) or the left (OFF) option.
I2.1 input enabled - SCL disabled
I2.1 input disabled- SCL enabled
In all of the Industrial Shields Arduino based PLCs, analog inputs can work at:
0V - 10V analog input
Analog inputs have a special draw in the case of the PLC:
0V - 10Vdc Analog input
All the analog inputs are not opto-isolated (they use the same GNDs as the PLC). The following image shows how to connect an analog input to the PLC:
0V - 10Vdc Analog input
In order to program the analog GPIOs, we must keep in mind that we can read the values with the following command:
This function returns a value between 0 and 1023 depending on the applied voltage level to the input (0V it is equal to 0, and 10V it is equal to 1023).
GPIO is the name of the input. Imagine we want to know the state of the "I0.12" input, then, we must write this line:
We must know we do not need to configure the analog inputs as analog. Industrial Shields' libraries do all the work for us.
You can see a read analog GPIO example in the following paragraph:
// Analog read example// Set the speed of the serial port
// This example reads the I0_12 and shows via serial the value
// Setup function
}int value = analogRead(I0_12);
// Loop function