Analog Input 0-10V or 4-20mA
Description
This feature is present on OI-Mixed module (x4).
With these inputs, you can measure any voltage within the specified range. These inputs are especially suitable for applications with industrial sensors.
There are two modes available for reading industrial sensors:
Sensors with a 0-10V output
Sensors with a 4-20mA output.
It’s feasible to integrate both types of sensors, accommodating both current and voltage inputs, on the same board.
Requirements |
Value |
Remark |
---|---|---|
Resolution |
12 bits |
|
Sampling frequency |
4.8kHz |
Only ‘oneshot’ reading is supported |
Characteristics
Voltage mode
You have the option to define the voltage range directly in the code.
Below are available voltage range and the precision associated. Precision is ±5 step.
Requirements |
Value |
---|---|
Minimum input voltage |
0V |
Maximum input voltage |
12V |
Input impedance |
1MΩ |
Range |
Precision |
Step |
---|---|---|
0 to 1.28V |
± 1.56mV |
0.3125mV |
0 à 2.56V |
± 3.12 mV |
0.625mV |
0 à 5.12 V |
± 6.25mV |
1.25mV |
0 à 10.24V |
± 12.5mV |
2.5mV |
For example, if you want an optimal resolution when reading a sensor value within the 0-5V range, it is recommended to set the range from 0 to 5.12V. This adjustment will result in improved precision compared to the default range of 0 to 10.24V.
Current mode
Requirements |
Value |
---|---|
Minimum input current |
0mA |
Maximum input current |
24mA |
Input impedance |
100Ω |
Precision |
±30µA |
Step |
6.25µA |
If the input current is greater than 24mA, the module will automatically switch to voltage mode to preserve hardware.
Code examples
The example code above demonstrates how to read the voltage of an input on an OI-Mixed module.
#include "OpenIndus.h"
#include "Arduino.h"
OIMixed mixed;
float value = 0.0;
void setup(void)
{
Serial.begin(115200);
/* Init AIN */
mixed.analogInputMode(AIN_1, AIN_MODE_VOLTAGE);
mixed.analogInputMode(AIN_2, AIN_MODE_VOLTAGE);
mixed.analogInputMode(AIN_3, AIN_MODE_VOLTAGE);
mixed.analogInputMode(AIN_4, AIN_MODE_VOLTAGE);
}
void loop(void)
{
value = mixed.analogReadMilliVolt(AIN_1);
Serial.print("AIN_1 :");
Serial.print(value);
Serial.println("mV");
value = mixed.analogReadMilliVolt(AIN_2);
Serial.print("AIN_2 :");
Serial.print(value);
Serial.println("mV");
value = mixed.analogReadMilliVolt(AIN_3);
Serial.print("AIN_3 :");
Serial.print(value);
Serial.println("mV");
value = mixed.analogReadMilliVolt(AIN_4);
Serial.print("AIN_4 :");
Serial.print(value);
Serial.println("mV");
delay(1000);
}
The example code above demonstrates how to read the current of an input on an OI-Mixed module.
#include "OpenIndus.h"
#include "Arduino.h"
OIMixed mixed;
float value = 0.0;
void setup(void)
{
Serial.begin(115200);
/* Init AIN */
mixed.analogInputMode(AIN_1, AIN_MODE_CURRENT);
mixed.analogInputMode(AIN_2, AIN_MODE_CURRENT);
mixed.analogInputMode(AIN_3, AIN_MODE_CURRENT);
mixed.analogInputMode(AIN_4, AIN_MODE_CURRENT);
}
void loop(void)
{
value = mixed.analogReadMilliAmp(AIN_1);
Serial.print("AIN_1 :");
Serial.print(value);
Serial.println("mA");
value = mixed.analogReadMilliAmp(AIN_2);
Serial.print("AIN_2 :");
Serial.print(value);
Serial.println("mA");
value = mixed.analogReadMilliAmp(AIN_3);
Serial.print("AIN_3 :");
Serial.print(value);
Serial.println("mA");
value = mixed.analogReadMilliAmp(AIN_4);
Serial.print("AIN_4 :");
Serial.print(value);
Serial.println("m1");
delay(1000);
}
Software API
-
class AnalogInputsLV
Public Static Functions
-
static int analogRead(AnalogInput_Num_t num)
Read a voltage measure on analog pin and return the raw value.
- Parameters:
num – Analog input
- Returns:
Adc raw value
-
static float analogReadVolt(AnalogInput_Num_t num)
Read the value of AIN. The function return a float that correspond to the voltage of the AnalogInput.
- Parameters:
num – Analog input
- 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 – Analog input
- Returns:
Measure in mV
-
static float analogReadAmp(AnalogInput_Num_t num)
Read a current measure on analog pin.
- Parameters:
num – : Analog input
- Returns:
Measure in A
-
static float analogReadMilliAmp(AnalogInput_Num_t num)
Read a current measure on analog pin.
- Parameters:
num – : Analog input
- Returns:
Measure in mA
-
static void analogInputMode(AnalogInput_Num_t num, AnalogInput_Mode_t mode)
Set Adc Mode of the given input.
- Parameters:
num – Analog input
mode – Voltage or current measurement
-
static uint8_t analogInputGetMode(AnalogInput_Num_t num)
Get Adc Mode of the given input.
- Parameters:
num – Analog input
- Returns:
Mode (0: voltage, 1: current)
-
static void analogInputVoltageRange(AnalogInput_Num_t num, AnalogInput_VoltageRange_t range)
Set the voltage range of the given input.
- Parameters:
num – Analog input
range – Voltage range (5: 0-10.24V, 6: 0-5.12V, 7: 0-2.56V or 8: 0-1.28V)
-
static uint8_t analogInputGetVoltageRange(AnalogInput_Num_t num)
Get the Voltage range of the given input.
- Parameters:
num – Analog input
- Returns:
Voltage range (5: 0-10.24V, 6: 0-5.12V, 7: 0-2.56V or 8: 0-1.28V)
-
static int analogRead(AnalogInput_Num_t num)