Your RevPi MIO has eight analog inputs, with which you can measure voltage from 0 to 10 V in millivolts. The inputs have an overhead with a buffer of 0.76 V. Measurements above 10.76 V are blocked.
Analog Inputs as Digital Inputs
Variable switching thresholds enable analog inputs to behave as digital inputs. You can define the switching thresholds for each channel. The result, i.e. whether the switching threshold at a channel has been exceeded, is shown in the process image in the fields AnalogInputLogicLevel_1-8.
To increase the accuracy of the AD converter, the signal is “oversampled”. With oversampling, an average value is calculated. All measurements (64) in a measurement period (approx. 8 ms/125 Hz) are added and the result is divided by the correction factor 8. The analog inputs are sampled with 15-bit resolution and are available in the process image as a millivolt value (0 to 10000).
If your signal is too severely affected by noise, you can set a moving average filter for the analog inputs. This filter ensures that any disturbance values such as measurement noise are filtered out of your sensor’s signal.
Note: If you use the moving average filter, the maximum frequency that can be detected is reduced. The signal’s bandwidth is reduced as a result.
A system ground (GND) is available for the analog inputs. This ensures that all connections have the same reference level for the measurements. Connect the system ground with low impedance.
If you do not connect the system ground, your output values may be distorted.
Each analog input is high impedance with a 100-kΩ input resistance and has a hardware filter with a cut-off frequency of 1.5 kHz. Each input is also protected against ESD pulses with a protective diode.
Note: Do not connect voltages over 33 V to the analog inputs. That would destroy the protective diodes that protect your device from ESD pulses, or cause a short circuit that would destroy your analog input.
Analog input 8
Analog input 7
Analog input 6
Analog input 5
Analog input 4
Analog input 3
Analog input 2
Analog input 1
Resistance and Current Measurement
Resistance and current measurements are not yet implemented in the software. Currently, you need to derive these from a voltage measurement in the RevPi Connect. Here we explain how to do this.
For resistance measurement you can use a voltage divider.
The voltage divider consists of the resistor RT to be measured and a reference resistor R1.
The resistance RT can be calculated from the voltage VT, which is tapped between the resistors with the analog input.
VT = (Vref*R1)/(R1+RT) à RT = R1*((VREF/VT)-1)
We assume the following values in this example: VT = 8000 mV; R1=1000 Ohm, VREF = 10000 mV
The reference voltage is to be generated with analog output 1 and the voltage VT is measured at analog input 1.
- Set the reference voltage at analog output 1 to 10000 mV:
piTest -w AnalogOutput_1,10000
- Measure the voltage at analog input 1 (in this example 8000mV):
piTest -r AnalogInput_1
You can now calculate the resistance RT with the function described above.
RT = 1000 Ohm * (10000 mV/8000 mV – 1) = 250 Ohm
You can measure small currents via a shunt resistor.
For measuring current between 0 mA and 20 mA a shunt resistor of 430 Ohm is suitable.
If you measure the voltage at the analog input and divide it by the resistor value, you get the measured current.
I = U_in/R_shunt