In detail tutorial for AIO scaling configuration

Topics about the Software of Revolution Pi
Post Reply
S_wauters
Posts: 7
Joined: 02 Aug 2022, 17:37
Answers: 0

In detail tutorial for AIO scaling configuration

Post by S_wauters »

I wonder if there is an in detail configuration for the scaling of the AIO input/output values.
I have looked far and wide but only manage to come across the same example:

A proximity sensor outputs the voltage 0 to 10 V in the range between 30 and 300 millimeters. To have the distance in mm in the process image, you must select the parameters as follows:

Multiplier = 270, Divisor = 10000, Offset = 30

If the sensor works with 4-20 mA instead, the values must be defined by you as follows:

Multiplier = 270, Divisor = 16000, Offset = -38


This shows some values but barely explains how you get to these values. I can imagine the voltage one as offset = 30 / Multiplier = 300 - 30 and divisor = 10000 (10v) but even then i'm not sure if this is correct. But how do you get to the values for the analog version? I like the revolution pi and its features but have found that most of the information often only scratches the surface making it less than ideal if you want to use it in an industrial installation where you need documentation fast. Hope someone can help to explain this to me and maby also add it to the tutorial page.
User avatar
dirk
KUNBUS
Posts: 1948
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: In detail tutorial for AIO scaling configuration

Post by dirk »

Hi S_wauters, look here, I have asked the expert for the analogue IO module and with his permission, I bring you this information this way:
AIO Troubleshooting with Jannis
AIO Troubleshooting with Jannis
AIO Troubleshooting mit Jannis.jpg (148.14 KiB) Viewed 2013 times
I have to admit that I also only now really understood these things after the troubleshooting. Basically, the point is that you have an extra feature with the scaling, which makes it possible, for example, to normalize different sensor data into one value. This allows you to take application-relevant conditions into account during the measurement.

Among other things, we have two sensors here that each work in the measuring range 0–10 volts. However, the values are for different distances.

There are two different distance sensors.
  • Distance sensor A is connected to AIN1. It can measure a distance of 30 ... 300 mm. The distance is converted into an analogue voltage of 0…10V.
  • Distance sensor B is connected to AIN2. It can measure a distance of 0 ... 300 mm. The distance is converted into an analogue voltage of 0...10V.

Here's the thing - you can actually choose two paths here that are available to you as a creative Revolution Pi user:
a) Scale the measurement via PiCtory configuration
b) The application normalizes the values, e.g. in Python code

Mostly, b) is the preferred way, as the application is usually easier to maintain than adjusting the PiCtory configuration.

I hope that Jannis and I have been able to shed some light on this.
User avatar
dirk
KUNBUS
Posts: 1948
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: In detail tutorial for AIO scaling configuration

Post by dirk »

Here is the explanation from the troubleshooting and the structure
Jannis Setup
Jannis Setup
Jannis Aufbau.jpg (260.77 KiB) Viewed 1982 times
2 analogue inputs
2 analogue inputs
2 AIO Eingänge.jpg (299.65 KiB) Viewed 1982 times
.

Here is an example code written in Python

Code: Select all

import revpimodio2

rpi = revpimodio2.RevPiModIO(autorefresh=True)
ain_1 = rpi.io["InputValue_1"].value
ain_2 = rpi.io["InputValue_2"].value

print(str(ain_1))
print(str(ain_2))

# Distance meter A
m_1 = (300-30)/(10000-0)
b_1 = 30
y_1 = m_1 * ain_1 + b_1

# Distance meter B
m_2 = (300-0)/(10000-0)
b_2 = 0
y_2 = m_2 * ain_2 + b_2

print("Distance meter A shows: " + str(y_1) + " cm")
print("Distance meter B shows: " + str(y_2) + " cm")

rpi.exit()
This is the output of the Python script
Python output
Python output
Python Output.png (6.38 KiB) Viewed 1886 times
So and instead of using the code you can use the following PiCtory configuration to scale the values during measurement.
PiCtory AIO Settings
PiCtory AIO Settings
PiCtory AIO Settings.png (10.15 KiB) Viewed 1985 times
Then you can grap the distance values as follows
Scaled values
Scaled values
Process Image.png (7.39 KiB) Viewed 1985 times
S_wauters
Posts: 7
Joined: 02 Aug 2022, 17:37
Answers: 0

Re: In detail tutorial for AIO scaling configuration

Post by S_wauters »

Hi Dirk,

Thank you for the explanation. Sorry for the late reply but the project has been on hold at the client till now.
This cleared up some things for me, however not everything is clear to me.
How the example comes to -38 for 4-20ma for example is still a mystery to me.

What i learned so far ( hopefully helpfull for others that find this topic)

Analog signals always come in as their value representation when no scaling is applied, not as a consistent range independent of sensor type as common in other plc's ((4-20ma or 0-10v)-> 0-30000 for example).
ie: 10V -> 10000, 4ma -> 4000, 16ma -> 16000 .....

When ignoring the pictory scaling since this is not an intuitive way of doing it, the simplest formula to me is shown in my example.

in the example we use a sensor that measures between 0-25 bar

//what is the lowest value of the input signal?
//ie: sensor measures from 5 to 50 meters -> lowRange is 5.
var lowRange = 0;
//what is the highest value of the input signal?
//ie: sensor measures from 5 to 50 meters -> HighRange is 50.
var highRange = 25;

rangeDelta = highRange - lowRange;

4-20ma

//devide the measurement range by 16000 (20-4ma -> 20000 - 4000)
//subtract 4000 from the input value since this is 4ma -> equal to sensor low point
output = ((rangeDelta / 16000)*(inputvalue-4000)) + lowRange;

10v
//devide the measurement range by 10000 (10-0v -> 10000 - 0)
output = ((rangeDelta / 10000)*inputvalue) + lowRange;


Another topic is how confusing the wiring of a current sensor is. i eventually found an solution that seems to work in this forum but how this is not in the official documentation is beyond me.
Currently i am using wiring as shown in my image for a 4-20ma sensor. This seems to work at first glance.
analog input.png
analog input.png (24.55 KiB) Viewed 1612 times
i love the revolution pi and the way this is a low cost solution, but at this time it is hard to recomend these plc's to anyone other than a hobbyist since the documentation lacks so much vital information.
In my humble opinion at this point in time good documentation is more vital for the revolution pi than adding new features.
The forum will provide you with answers but a profession does not have the time to go through the entire forum to find a solution to something as simple as how to configure an industry standard sensor.
JuanLopez
Posts: 1
Joined: 23 May 2023, 08:23
Answers: 0

Re: In detail tutorial for AIO scaling configuration

Post by JuanLopez »

Hello,

i have the same issue at the moment. I have 2 AIO with different sensors to messure temperature, pressure and gas quantity and have no idea how to scale and i find no
documentation realted or a good explanation of it. It whould be nice to have some examples to undertand better this scaling, for me better for 4-20mA.

Thank you in advice
S_wauters
Posts: 7
Joined: 02 Aug 2022, 17:37
Answers: 0

Re: In detail tutorial for AIO scaling configuration

Post by S_wauters »

Hi JuanLopez,

I have not used the temperature inputs so i can not help you with them.
what software do you want to use? Node red? Codesys?
What are the sensor interfaces? ( 4-20ma or 0-10v or other )

The simplest way to do it i found was just configure the input with values 1 and 1 which will give you a value of the signal with 3 floating points.
For instance 10v would be 10000 or 16ma would be 16000. the conversion can be done as i mentioned in my last message.

Hope this helps i found it super confusing as well coming from Siemens/Beckhoff/Festo(codesys)
Post Reply