Analog Input 0-30V
Description
This feature is present on all several modules:
OI-Core/OI-CoreLite (x2)
OI-Discrete (x2)
It enables the reading of conditioned voltage within the range of 0 to 30V, making it especially handy for monitoring supply voltage or sensor outputs.
Note
When using these analog input, you have to take into account the low input impedance (4.8kΩ). If the application need an a analog reading with high impedance and better precision, please check spec of OI-AnalogLS or OI-Mixed.
Characteristics
Requirements |
Value |
Remark |
---|---|---|
Resolution |
12 bits |
|
Sampling frequency |
500Hz |
Only ‘oneshot’ reading is supported |
Minimum input voltage |
0V |
|
Maximum input voltage |
30V |
|
Input impedance (Voltage mode) |
4.8kΩ |
|
Precision |
100mV |
Code examples
The example code above demonstrates how to read the voltage of an input on an OI-Discrete module.
#include "OpenIndus.h"
#include "Arduino.h"
OICore core;
int value = 0;
void setup(void)
{
Serial.begin(115200);
}
void loop(void)
{
value = core.analogRead(AIN_1);
Serial.print("AIN_1 :");
Serial.println(value);
value = core.analogRead(AIN_2);
Serial.print("AIN_1 :");
Serial.println(value);
value = core.analogReadMilliVolt(AIN_1);
Serial.print("AIN_1 :");
Serial.print(value);
Serial.println("mV");
value = core.analogReadMilliVolt(AIN_2);
Serial.print("AIN_2 :");
Serial.print(value);
Serial.println("mV");
delay(1000);
}
Software API
-
class AnalogInputsHV
Public Static Functions
-
static int analogRead(AnalogInput_Num_t num)
Read the value of AIN. The function return an integer that correspond to the internal voltage of the Analog Input in mV. This value is not calibrated and not converted to the real Analog Input voltage. It is strongly recommended to use analogReadVolts or analogReadMillivolts instead.
- Parameters:
num – ANA input number.
- Returns:
Value of the AIN input.
-
static float analogReadVolt(AnalogInput_Num_t num)
Read the value of AIN. The function return a float that correspond to the voltage of the ANA (from 0 to 30V).
- Parameters:
num – ANA input number.
- Returns:
Value of the AIN input.
-
static float analogReadMilliVolt(AnalogInput_Num_t num)
Read the value of AIN. The function return a float that correspond to the voltage of the ANA (from 0 to 30000mV).
- Parameters:
num – ANA input number.
- Returns:
Value of the AIN input.
-
static int setAnalogCoeffs(float *a, float *b)
Set the Analog Coeffs object.
- Parameters:
a – slope coefficient
b – y-intercept
- Returns:
0 if success, -1 if error
-
static void getAnalogCoeffs(float *as, float *bs)
Get the Analog Coeffs object.
- Parameters:
as – slope coefficient of each Analog Inputs
bs – y-intercept of each Analog Inputs
-
static int analogRead(AnalogInput_Num_t num)