Skip to content

Ardbox Q - I/O and Communications

Before proceeding

Info

Certain functionalities of the device depend on hardware jumpers and switches to be configured. The board will only behave as expected when jumpers and switches are set consistently for the chosen mode. Verify and set jumpers/switches carefully before powering or programming the board. Incorrect configurations can disable interfaces or have unwanted pin functions. See Switches and jumpers.

Digital inputs

Digital inputs can read only two states: LOW and HIGH:

InputsArdbox Q ADArdbox Q ADR
I0.0, I0.1 (optically isolated)5-24 Vdc5-24 Vdc
I0.2, I0.37-24 Vdc7-24 Vdc
I0.4-I0.9 (also analog)7-24 Vdc7-24 Vdc
TotalUp to 10 digital inputsUp to 10 digital inputs

Some inputs share their pin with other functions: I0.0 with PIN2, I0.2 and I0.3 with the RS-232 of jumper zone 2, and I0.8/I0.9 (AD) or I0.4/I0.5 (ADR) with the RS-485 control. On the Ardbox Q AD, I0.8 and I0.9 detect 24 Vdc signals with digitalRead; to detect signals from 7 V, read them as analog inputs.

Danger

The inputs are rated for 24 Vdc. Exceeding this voltage may cause malfunction or damage to the PLC.

Example usage

// Support for Monitor (Ardbox Q)
#include <Arduino_RouterBridge.h>

//// IMPORTANT: check jumpers and switches

void setup() {
  pinMode(I0_2, INPUT);
}

void loop() {
  int read = digitalRead(I0_2);
  Monitor.print("Read of I0.2 is ");
  Monitor.println(read);
  delay(1000);
}

Warning

To use an input as digital you must call pinMode on it. Furthermore, after calling pinMode on the input, you will not be able to use it as an analog input!

Warning

Ensure correct jumper and switch configuration to enable digital mode.

Analog inputs

Voltage can vary continuously between 0 and 10 V. The input will return a value between 0 and 2^N - 1, where N is the number of bits of precision.

The default precision is 10 bits, but it can be configured up to 14 bits. The precision can be changed by calling analogReadResolution(N_BITS);.

Ardbox Q ADArdbox Q ADR
Up to 6 analog inputs (I0.4-I0.9). Up to 6 analog inputs (I0.4-I0.9).

Info

On the Ardbox Q AD, I0.8 and I0.9 measure linearly up to 25.7 V, so 10 V is not the end of the scale: use 12 or 14 bits. At 12 bits, 10 V reads about 1592 of 4095.

Danger

The inputs are rated for 24 Vdc. Exceeding this voltage may cause malfunction or damage to the PLC.

Example usage

// Support for Monitor (Ardbox Q)
#include <Arduino_RouterBridge.h>

//// IMPORTANT: check jumpers and switches

void setup() {
  // Do nothing
}

void loop() {
  unsigned int read = analogRead(I0_7);
  Monitor.print("Read of I0.7 is ");
  Monitor.println(read);
  delay(1000);
}

Warning

To use an input as analog you must not call pinMode on it.

Warning

Ensure correct jumper and switch configuration to enable analog mode.

Digital outputs

Digital outputs can switch between two states only: LOW (GND) and HIGH (+QVdc):

Ardbox Q ADArdbox Q ADR
Up to 10 optically isolated digital outputs (Q0.0-Q0.9), 5-24 Vdc, 70 mA max each. 0 digital outputs.

Danger

Exceeding 24 V on the QVdc pin may cause malfunction or damage to the PLC.

Example usage

void setup() {
  pinMode(Q0_0, OUTPUT);
}

void loop() {
  digitalWrite(Q0_0, HIGH);
  delay(1000);
  digitalWrite(Q0_0, LOW);
  delay(1000);
}

Warning

To use an output as digital you must call pinMode on it. Furthermore, after calling pinMode on the output, you will not be able to use it as an analog/PWM output!

Warning

Ensure correct jumper and switch configuration to enable digital mode.

PWM outputs

PWM outputs switch between two states only. Alternating LOW (GND) and HIGH (+QVdc) states in a fast sequence, creating what is known as "pulse-width modulation". The PWM frequency is 500 Hz.

The default precision is 8 bits, but it can be configured up to 12 bits. The precision can be changed by calling analogWriteResolution(N_BITS);.

Ardbox Q ADArdbox Q ADR
Up to 8 PWM outputs (Q0.0-Q0.7). 0 PWM outputs.

Example usage

void setup() {
  // Do nothing
}

void loop() {
  analogWrite(Q0_4, 0);
  delay(500);
  analogWrite(Q0_4, 64);
  delay(500);
  analogWrite(Q0_4, 128);
  delay(500);
  analogWrite(Q0_4, 192);
  delay(500);
  analogWrite(Q0_4, 255);
  delay(500);
}

Warning

To use an output as PWM, you must not call pinMode on it.

Warning

Ensure correct switch configuration to enable PWM mode.

Analog outputs

Voltage can vary continuously between 0 and 10 V. Each analog output provides an output according to a digital value.

The default precision is 8 bits, but it can be configured up to 12 bits. The precision can be changed by calling analogWriteResolution(N_BITS);.

Ardbox Q ADArdbox Q ADR
Up to 7 analog outputs (A0.0-A0.6), 5 mA max each (load of 2 kΩ or more). They share pins with Q0.0-Q0.6. Up to 2 analog outputs (A0.0, A0.1), on the terminals Y+/A0.0 and Z-/A0.1 selected with the jumpers of zone 1 (the RS-485 can then only work in half duplex).

Info

On the Ardbox Q AD, the full 0-10 V range needs a 24 Vdc supply. With a 12 Vdc supply the analog outputs may not reach 10 V.

Example usage

void setup() {
  // Do nothing
}

void loop() {
  analogWrite(A0_1, 0);
  delay(500);
  analogWrite(A0_1, 64);
  delay(500);
  analogWrite(A0_1, 128);
  delay(500);
  analogWrite(A0_1, 192);
  delay(500);
  analogWrite(A0_1, 255);
  delay(500);
}

Warning

To use an output as analog, you must not call pinMode on it.

Warning

Ensure correct jumper and switch configuration to enable analog mode.

Relays

Relays can switch between two states only: LOW (open contact) and HIGH (closed contact):

Ardbox Q ADArdbox Q ADR
0 relays. 8 relays (R1-R8).

R5 shares its pin with PIN3, and R7 and R8 share their pins with the serial port (RS-485 or RS-232): see the switches of the Ardbox Q ADR.

Danger

Each relay contact is rated for 3 A at 30 Vdc. Exceeding this rating may cause the relay to overheat, burn, or fail catastrophically.

Example usage

void setup() {
  pinMode(R3, OUTPUT);
}

void loop() {
  digitalWrite(R3, HIGH);
  delay(1000);
  digitalWrite(R3, LOW);
  delay(1000);
}

Warning

To use a relay you must call pinMode on it.

Warning

Ensure correct switch configuration to enable the relays.

RS485

RS485 is a serial communication standard that allows data transmission over long distances and between multiple devices using a single pair of wires. It is resistant to electrical noise and commonly used in industrial environments.

Important features and values ​​to consider

Interface typeRS-485 half/full duplex
Communication speed (baud rate)Configurable
Connectors and wiringPlug-in terminal block (A+ and B-; Y+ and Z- for full duplex)
Termination resistor120 ohms, fitted on the board

Recommendation

It's recommended to use twisted pair to minimize electromagnetic interference (EMI). If you're in a noisy environment, use shielded twisted pair (STP).

Configurations

The Ardbox Q provides an RS485 communication interface that can be used with our libraries (you can install them following these instructions). You don't need to manually toggle the DE/RE pins, as they are controlled automatically thanks to our library. But you first need to configure the jumpers and switches for the RS-485 to work correctly.

1. Configure the jumpers and switches correctly

ad-config
Ardbox Q AD configuration
adr-config
Ardbox Q ADR configuration

You can check the details on the Switches and jumpers: Ardbox Q AD or Switches and jumpers: Ardbox Q ADR sections.

2. Program example

// Support for Monitor (Ardbox Q)
#include <Arduino_RouterBridge.h>

// Include Industrial Shields libraries
#include <RS485.h>

//// IMPORTANT: check jumpers and switches

void setup() {
  // Begin serial port
  Monitor.begin(9600);

  // Begin RS485 port, with 38400 bps, 8 data bits, even parity, and 1 stop bit.
  RS485.begin(38400, SERIAL_8E1);
}

void loop() {
  // Print received byte when available
  if (RS485.available()) {
    byte rx = RS485.read();

    // Hexadecimal representation
    Monitor.print("HEX: ");
    Monitor.print(rx, HEX);

    // Decimal representation
    Monitor.print(", DEC: ");
    Monitor.println(rx, DEC);

    // Echo the data back
    RS485.write(rx);
  }
}

3. Additional Notes

  • Ensure that all devices connected to the RS485 bus share the same baud rate and serial communication parameters (data bits, parity, and stop bits).
  • The RS-485 and the RS-232 use the same serial port of the Arduino UNO Q (D0/D1): they cannot be used at the same time.

RS232

RS232 is a serial communication standard for point-to-point data transmission between two devices.

Important features and values ​​to consider

Interface typeRS-232 (full duplex)
Communication speedConfigurable
Connectors and wiringPlug-in terminal block (TX and RX)

Recommendation

It's recommended to use shielded cable in noisy environments.

Configurations

The Ardbox Q provides an RS232 communication interface that can be used with our libraries (you can install them following these instructions). To use it, you will first need to configure the jumpers and switches for the RS-232 to work correctly: the RS-232 uses the serial port of the Arduino UNO Q (D0/D1), so the RS-485 is not available at the same time.

1. Configure the jumpers and switches correctly

ad-config
Ardbox Q AD configuration
adr-config
Ardbox Q ADR configuration

In both versions, keep the jumpers of zone 2 in the input position (I0.2 and I0.3).

2. Program example

// Support for Monitor (Ardbox Q)
#include <Arduino_RouterBridge.h>

// Include Industrial Shields libraries
#include <RS232.h>

//// IMPORTANT: check jumpers and switches

void setup() {
  // Begin serial port
  Monitor.begin(9600);

  // Begin RS232 port, with 38400 bps, 8 data bits, no parity, and 1 stop bit.
  RS232.begin(38400, SERIAL_8N1);
}

void loop() {
  // Print received byte when available
  if (RS232.available()) {
    byte rx = RS232.read();

    // Hexadecimal representation
    Monitor.print("HEX: ");
    Monitor.print(rx, HEX);

    // Decimal representation
    Monitor.print(", DEC: ");
    Monitor.println(rx, DEC);

    // Echo the data back
    RS232.write(rx);
  }
}

3. Additional Notes

  • Ensure that both devices share the same baud rate and serial communication parameters (data bits, parity, and stop bits).

SPI

The Serial Peripheral Interface (SPI) is a synchronous serial communication standard that enables high-speed data exchange over short distances between a master and one or more slave devices using separate data and clock lines.

Danger

The SPI signals of the Ardbox Q are 3.3 V logic. Do not connect 5 V devices directly: use level shifters and ensure a common ground.

Example usage

// Support for Monitor (Ardbox Q)
#include <Arduino_RouterBridge.h>

// Include SPI library
#include <SPI.h>

const unsigned int CS_PIN = D3;

void setup() {
  // Setup CS pin
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);

  // Setup SPI
  SPI.begin();
}

void loop() {
  // Start a SPI transaction
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
  digitalWrite(CS_PIN, LOW);

  // Write 1 bytes while reading 1 bytes
  uint16_t read1 = SPI.transfer(0x24);
  Monitor.print("read1 is: ");
  Monitor.println(read1);

  // Write 2 bytes while reading 2 bytes
  uint16_t read2 = SPI.transfer16(0xF00F);
  Monitor.print("read2 is: ");
  Monitor.println(read2);

  // End the transaction
  digitalWrite(CS_PIN, HIGH);
  SPI.endTransaction();

  delay(1000);
}

Info

SPI doesn't need any switch or jumper configuration to properly work. However, you may want to use PIN2 or PIN3 as chip select pins. To have them free on the terminals, set the PIN2 and PIN3 switches OFF (see Switches and jumpers).