Browsed by
Tag: Input

Isolated Inputs Ardbox/M-Duino

Isolated Inputs Ardbox/M-Duino

In this post it is described how to use the galvanically isolated inputs in Idustrial Shields PLCs (Ardbox and M-Duino).

As shown in the Figure below, isolated inputs always have two available connections and both of these connections need to be wired for a proper performance of the inputs. The configuration if the inputs is PNP. All isolated inputs are DIGITAL,  not ANALOG.

Isolated inputs

Ix.x    –> Signal. Voltage up to 24V

(-) Ix.x –> reference or COM of the input signal.  

IMPORTANT: BOTH connections are required for the Inputs to work properly.

Ioslated_inputs_v1

The next peice of code shows how to read one isolated input. The example is based on M-Duino Relay, for other PLCs  the pin 2 should be replaced according to the PLC pinout.

int I00 = 2 // modify pin 2 accordingly to PLC pinout;

void setup() {

  pinMode(I00, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  Serial.println(digitalRead(I00));
  delay(2000); //wait 2 seconds
}
Read Digital Inputs Ardbox/MDuino

Read Digital Inputs Ardbox/MDuino

Digital  Inputs (0-24Vdc):

Ardbox

  • Analog: I0.0 (Digital); I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Digital).
  • Relay:  I0.0, I0.1, I0.2, I0.3, I0.4 (Digital); I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Digital).

M-Duino

  • M-Duino 21: I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6 (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12 (configurable Digital).
  • M-Duino 42:  I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I1.0, I1.1, I1.2, I1.3, I1.4, I1.5, I1.6 (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12  (configurable Digital).
  • M-Duino 58: I0.0, I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I1.0, I1.1, I1.2, I1.3, I1.4, I1.5, I1.6, I2.0, I121, I2.2, I2.3, I12.4 (NC), I2.5, I2.6  (Digital); I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12, I2.7, I2.8, I2.9, I2.10, I2.11 (NC), I2.12 (NC)  (configurable Digital).
  • M-Duino 19R: I0.0, I0.1 (Digital); I0.2, I0.3, I0.4, I0.5 (configurable Digital).
  • M-Duino 38R: I0.0, I0.1 , I1.0, I1.1 (Digital); I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5 (configurable Digital).
  • M-Duino 57R: I0.0, I0.1 , I1.0, I1.1, I2.0, I2.1 (Digital); I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5, I2.2, I2.3, I2.4, I2.5 (configurable Digital).

In this post we are going to learn how to read digital inputs. The example shows how to obtain the  value for the digital input I0.0 (Ardbox Analog)  and print it  on the serial monitor every 2 seconds.

int I00 = 2;
int value_I00;
void setup() {

  pinMode(I00, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  value_I01 = digitalRead(I00);
  Serial.println(value_I00);   //print value on serial Monitor
  delay(2000); //wait 2 seconds
}

Digital inpus operate at 0 or 24Vdc. The read value digitalRead() will be 0  for 0Vcd signal or 1 for ~ 24Vdc signal. In order to monitor the digital input values the Serial Monitor is used.  It can be appreciated that the read value is either 0 or 1, depending  on the attached sensor state. In the event of no sensor attached, the value will be constant to 0.

AB_Analogread_serial_monitor     AB_digread_serial_monitor

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other inputs the pin number should be replaced by the pin matching the new digital input . i.e. (for Ardbox Analog):

int I01 = 12;

void setup(){
pinMode(I01, INPUT);

}
Read Analog Input Ardbox/MDuino

Read Analog Input Ardbox/MDuino

Analog  Inputs (0-10V / 10  bits):

Ardbox

  • Analog: I0.1, I0.2, I0.3, I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Analog).
  • Relay: I0.4, I0.5, I0.6, I0.7, I0.8, I0.9 (configurable Analog).

MDuino

  • M-Duino 21:  I0.7, I0.8, I0.9, I0.10, I0.11, I0.12 (configurable Analog).
  • M-Duino 42:  I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12  (configurable Analog).
  • M-Duino 58: I0.7, I0.8, I0.9, I0.10, I0.11, I0.12, I1.7, I1.8, I1.9, I1.10, I1.11, I1.12, I2.7, I2.8, I2.9, I2.10, I2.11 (NC), I2.12 (NC)  (configurable Analog).
  • M-Duino 19R: I0.2, I0.3, I0.4, I0.5 (configurable Analog).
  • M-Duino 38R: I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5 (configurable Analog).
  • M-Duino 57R:  I0.2, I0.3, I0.4, I0.5 , I1.2, I1.3, I1.4, I1.5, I2.2, I2.3, I2.4, I2.5 (configurable Analog).

In this post we are going to learn how to read analog inputs. The example shows how to obtain the  value for analog input I0.1 (ardbox Analog)  and print it  on the serial monitor every 2 seconds.

int I01 = 12;
int value_I01;
void setup() {

  pinMode(I01, INPUT);
  
  Serial.begin(9600); 	// Set up serial communication. It will allow to monitor the analog input value.
}

void loop() {

  value_I01 = analogRead(I01);
  Serial.println(value_I01);
  delay(2000); //wait 2 seconds
}

The values for the analog inputs (10 bits)  range is 0 – 1023 (see graph below).  If the value of sensor is (3V), the analogRead value is 3*1023/10 = 307.

AB_analogread

In order to monitor the analog Input values the Serial Monitor is used.  It can be appreciated that the read value is a random number, this is because the input connector is floating since there is no sensor attached. To prove that we can ground I0.1 iput (connect it to GND)  and it should show a value close to zero.

AB_Analogread_serial_monitorAB_Analogread_serial_monitor

The digital outputs pinout can be checked on the User Guides for each PLC. Otherwise,  Arduino IDE start files contain all I/O already declared and with the suitable pinMode defined. To reproduce the same code for the other outputs the pin number should be replaced by the corresponding Arduino pin matching the new Output.
i.e. (Ardbox Relay):

int I02 = 8;

void setup(){
pinMode(I02, INPUT);

}
How to read a digital Input

How to read a digital Input

You can read the data of a Digital Input through:

...
int myDigital;
...
void setup() {
   pinMode (5,INPUT);
}

void loop() {
   myDigital = digitalRead(5);
}

With this piece of code you’ll read the voltage of a PLC pin. As our digital input works between 0-24V, the read value (myDigital) will be a value: 0 or ~24V.
 
Note: The example pin “5”, is only an example. You need to check in your PLC which pin to use for reading, writing, or reading and writing. Only if your PLC is able to work as a digital input, then, you can send this code into it.

How to read an Analog Input

How to read an Analog Input

You can read the data of an Analog Input through:

...
int myAnalog;
...
void setup() {}

void loop() {
   myAnalog = analogRead(A0);
}

With this piece of code you’ll read the voltage of a sensor. As our analog input works between 0-10V, the read value (myAnalog) will be a value between 0-1023.

If the value of sensor is (3V), myAnalog value is 3*1023/10 = 307.