Analog inputs are needed to read sensors for temperature, level, distance and much more. The Coolmay L02ML24T/R has 4 analog inputs that can read 0-10 volts. These 0-10 volts form a value between 0 and 4095, which the PLC can then calculate with. For my example, I connected a 10 k.Ohm to the PLC and read it out with the Melsoft GX Works 2.
To change the 24VDC to 10VDC I used a 10 k.Ohm resistor. Since the potentiometer is a voltage divider, VCC and GND are connected and the output of the potentiometer is connected to input AD0.
The analogous functions can be found either in the selection bar or on the right with the elements.
Both times it's the same functions, one time you have to type them in yourself, whereas they are on the right with the element with abbreviations.
With analog functions, you must always pay attention to the correct "value" or the correct variable. There are several ways to query the analog input. In the example below, the same AD0 is always queried, but always with a different "abbreviation".
- Via a global variable, which I called "analogue" here
- Via the abbreviation D8030
- Via the abbreviation %MW0.8030
In the online mode below you can see that it is always the same value. The next analog input is then the D8031 or %MW0.8031.
If you want to query the analog input via a global variable, you must create a variable of the type "Word unsigned", enter D8030 as "Device" and %MW0.8030 as "Address".
In online mode you will then see that the value of the analog input is always the same. Since the input is a "Word", the analog value can be read directly in many cases, for example with GT (greater than) or LE (less than). If you want to calculate with this value (here ADD) you need an integer variable. The "WORD_TO_INT" function is required for this.
In order to display the whole thing on the Coolmay HMI, it only needs two "lamps" and two "number fields".
Create a new folder for "TAG" and then enter the appropriate digital variables.
Enter the same for the analog variables and you're done.
The whole thing should then be displayed on the HMI. When turning the potentiometer, the two values should change and the lamps should come on one after the other.