Skip to main content

RevPi Flat S

Product Description

The RevPi Flat S is a robust, non-modular 24 V industrial PC for IIoT and automation projects based on the Raspberry Pi Compute Module 4S. Due to its flat design, the RevPi Flat S is suitable for installation in sub-distribution cabinets in accordance with DIN EN 18012.

Components

revpi-flat-s-aufbau

PositionComponentApplication
16 × status LEDLEDs
2ButtonFreely configurable push-button
32 × locking clipMounting the Device on a DIN Rail
4Micro USBOnly for RevPi Flat S variant:
Saving and Reinstalling the Image
54 × RJ45 EthernetEthernet Interfaces (RJ45),
Establishing a Network Connection
62× USB AUSB Interfaces
7Digital output (relay contact)Digital output (relay contact)
8POWER
(2-pin plug)
Connecting the Power Supply
9Analog input /
Analog output
(5-pin plug)
Analog Inputs and Outputs
10RS485-0
(3-pin plug)
Serial Devices (RS485)
11RS485-1
(RJ14 connection)
Serial Devices (RS485)
12RP-SMA socketWLAN and BT
13Ventilation SlotsMounting the Device on a DIN Rail

Compatible RevPi images for RevPi Flat S

  • RevPi Bookworm Image
  • RevPi Bullseye Image

See: RevPi Images.

Virtual Devices

The Virtual Devices are delivered with the RevPi image as components in PiCtory included:

Variants

Item No.:RAMeMMCMicro USB
RevPi Flat 1003711 GB32 GBNo
RevPi Flat S 1003301 GB8 GBYes

For available variants see Revolution Pi Shop.

The RevPi Flat was designed as a tamper-proof device. Therefore, it is not intended that you can flash the image of the device (in contrast to the RevPi Flat S product variant).

Scope of Delivery

The scope of delivery includes

  • RevPi Flat S or Rev Pi Flat (non-modular base module)
  • 2-pin plug POWER
  • 5-pin plug ANALOG
  • 3-pin plug RS-485-0
  • 2-pin plug for relay contact
  • Supplement

Mounting and Connecting

The RevPi was developed for use in a control cabinet. Observe the specifications for the Intended Use and all Safety Instructions.

Carry out the installation and connection in the following order :

  1. Mount your RevPi on a DIN rail.

  2. Connect all other devices such as sensors and actuators. The interfaces available to you for this can be found in the Components section.

  3. As the last step connect the power supply.

Connecting the Power Supply

warning

Danger to life due to electric shock

There is a risk of fatal electric shock when working on devices in the switch cabinet with 230 V mains voltage.

▷ Work in the switch cabinet may only be carried out by qualified electricians.

▷ Before carrying out any work in the switch cabinet, switch off the power supply properly.

NOTICE

Damage to the device due to impermissible power supply

▷ Observe the maximum voltage supply of 28.8 V DC.

▷ Only use the supplied plug and a suitable power supply unit.

▷ Ensure correct polarity when connecting.

▷ Ensure a stable power supply.

NOTICE

Damage to the device due to installation under voltage supply

While the RevPi device is connected to a power source, no other devices may be connected or disconnected, as this may cause damage to the devices.

▷ Do not connect the power supply until all other devices are connected correctly.

▷ Switch off the power supply before disconnecting a device from the system.

NOTICE

Damage to the device software due to disconnection from the power supply

If the device is disconnected from the power supply during operation, the file system of the eMMC memory may be destroyed. The device can then no longer be booted.

▷ Shut down the device properly before disconnecting it from the power supply.

NOTICE

Damage to the device due to different grounding

▷ Refer all connections to the same system ground.

▷ Connect external voltage inputs or outputs with different grounding externally.

This power supply requires cabling via the POWER plug.

You will also need:

✓ A power supply unit (min. 20 W, e.g. DIN rail switching power supply, article no. 200003)

✓ Wiring, cross section 0.35...2.5 mm

✓ Stripping and crimping pliers

✓ If you use stranded wire, apply suitable wire end sleeves

✓ A small slotted screwdriver

▷ First disconnect connected devices from their respective power supply.

▷ Connect a power supply between 10.7 ... 27.8 V to the pin marked 24 V on the POWER plug.

▷ Connect the 0 V supply to the pin marked GND.

Access to the Device

The RevPi is accessed in two steps:

  1. Establishing a Network Connection.

  2. Login on the device.

Install all available Updates as soon as the RevPi is connected to the Internet so that the system is always up to date with security-relevant features.

See also:

Configuration

Basic Configuration

From the RevPi Bookworm image (10/2024) onwards, the basic configuration of the RevPi devices is carried out via the Cockpit web application.

Until the RevPi Bullseye Image (04/2024), the basic configuration of the RevPi devices is carried out via the RevPi Status web application.

Configuring the Base Module in PiCtory

▷ Start PiCtory.

▷ Select the RevPi base module from the Device Catalog and drag and drop it onto the empty slot with position number 0.

     ❯ The configurable values appear in the Value Editor.

▷ Save the configuration as the start configuration with File > Safe as Start-Config.

❯❯ The start configuration is called up directly after each boot process.Start PiCtorySystem Configuration with PiCtory

ValueFunction
INP AInInput values of the analog inputs
INP AIn_StatusStatus of the analog inputs
INP_AOut_StatusStatus of the analog outputs
INP Core_TemperatureCPU Temperature
INP Core_FrequencyCPU Frequency
INP Top_ButtonInput value of the push-button
OUT RevPiLEDStatus byte for LEDs
OUT AOutOutput value for analog output
OUT DOutOutput value for digital output
MEM AInModeMode for the analog input:
Voltage 0 - 10V for voltage measurement
Current 0 - 20mA for current measurement

Serial Devices (RS485)

The RevPi has two RS485 interfaces. This allows you to use serial protocols such as Modbus and to integrate devices such as smart meters or solar inverters into your the Revolution Pi system.

The interfaces are labeled with RS485-0 and RS485-1 . Both interfaces are isolated galvanically from each other and from the RevPi.

Under Linux, the interfaces can be addressed with:

  • ttyAMA0( RS485-0)
  • ttyS0( RS485-1)

RS485-0

RS485-0 is connected to a 3-pole terminal. The data lines are marked with P (positive) and N (negative). For other devices, these lines are often referred to as D+ and D- or A and B.

revpi-flat-rs485-pinout

Only the lines N and P are required for the actual data transmission. We recommend a twisted pair for longer line lengths or larger baud rates.

revpi-flat-rs485-0-pinout

RS485-1

An RJ11 socket is available for RS485-1.

revpi-flat-rs485-1-pinout

PinWiring
1
2GND
3Negative
4Positive
5GRD
6

Reference Potential

Should a reference potential be necessary, you can use the “GND” electrical circuit ground of the respective RS485 bus for this purpose. Since the two RS485 systems have complete galvanic isolation from each other and from the rest of the RevPi Flat circuitry, these “GND” connections are also isolated galvanically from each other and from the RevPi Flat GND connection.

Shielding

Cables having a length over 30 meters and cables leaving the building should be shielded. To further improve the EMC properties of the shield, you can connect the shield to the equipotential bonding rail of the distribution box if necessary. Such a connection can easily be made with a contact force spring.

Bit Rates

Linux addresses the interfaces via the character devices “/dev/ttyAMA0” and “/dev/ttyS0”. You can configure bit rates from 50 to 3,000,000 for “/dev/ttyAMA0” and from 1,200 to 4,000,000 for “/dev/ttyS0”. However, occasional reception errors may occur at more than 230,400 bits. The reason is that the UART of the Raspberry Pi, to which the interface is connected, has only a 16 byte FIFO and does not support DMA. The higher the bit rate, the more often the FIFO is not read out fast enough and received data is lost. For example, there are 1 - 2 errors per 50 MByte received at 460,800 bits and there are about 10 errors at 921,600 bits. If your RevPi Flat mainly sends data and only rarely receives it, you can also use higher bit rates. Otherwise we recommend to not set more than 230,400 baud.

Termination

The interface has an integrated 120 ohm terminating resistor. This termination is switched off after booting. This is safest, as no communication is possible if several devices on the RS485 bus switch on their termination. Short cables allow for communication also without termination. For longer distances you should switch the termination on if your RevPi Flat is at the end of the bus line.

Switch the termination on and off as follows:

▷ Open the character device /dev/ttyAMA0 or /dev/ttyS0 with open().

▷ Read out the current RS485 configuration with the command:
TIOCGRS485 ioctl()

▷ Set or delete the flag SER_RS485_TERMINATE_BUS in the struct serial_rs485

▷ Activate the changed RS485 configuration by a Command TIOCSRS485 ioctl(
▷ If necessary, send or receive the data with read() or write().

▷ Close the character device by the command close()

You have to repeat these steps after each boot if you want to enable termination.

A C listing with these steps is prepared and can be compiled directly:

/*

* Copyright (c) 2020, KUNBUS GmbH

*

* Permission is hereby granted, free of charge, to any person obtaining a

* copy of this software and associated documentation files (the “Software”),

* to deal in the Software without restriction, including without limitation

* the rights to use, copy, modify, merge, publish, distribute, sublicense,

* and/or sell copies of the Software, and to permit persons to whom the

* Software is furnished to do so.

*

* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR

* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,

* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR

* OTHER DEALINGS IN THE SOFTWARE.

*/


```#include <errno.h>```

```#include <fcntl.h>```

```#include <stdio.h>```

```#include <string.h>```

```#include <unistd.h>```

```#include <linux/serial.h>```

```#include <sys/ioctl.h>```

```#define RCV_LEN 3```

int main(int argc, char **argv)

{

struct serial_rs485 rs485conf;

int fd, ret;

char buf[RCV_LEN];


```if (argc != 2) {```

```printf("Usage: %s <device>\n", argv[0]);```

```return 0;```

```}```

fd = open(argv[1], O_RDWR);

if (fd < 0) {

printf("Cannot open: %s\n", strerror(errno));

return errno;

}


```ret = ioctl(fd, TIOCGRS485, &rs485conf);```

```if (ret < 0) {```

```printf("Cannot get rs485 config: %s\n", strerror(errno));```

```return errno;```

```}```

rs485conf.flags ^= SER_RS485_TERMINATE_BUS;


```ret = ioctl(fd, TIOCSRS485, &rs485conf);```

```if (ret < 0) {```

```printf("Cannot set rs485 config: %s\n", strerror(errno));```

```return errno;```

```}```

```ret = write(fd, "abc", 3);```

```ret |= read(fd, buf, RCV_LEN);```

```if (ret < 0) {```

```printf("send or receive error: %s\n", strerror(errno));```

```return errno;```

```}```

ret = close(fd);

if (ret < 0) {

printf("Cannot close: %s\n", strerror(errno));

return errno;

}

}

By default, after booting, /dev/ttyAMA0 is used as the console terminal with the following configurations:

pi@RevPi0000:~ $ sudo stty -F /dev/ttyAMA0

speed 115200 baud; line = 0;

lnext = <undef>; min = 1; time = 0;

-brkint -icrnl ixoff -imaxbel iutf8

-icanon -iexten -echo

See also:

Ethernet Interfaces (RJ45)

The RevPi has two 10/100 Ethernet interfaces with one or three RJ45 sockets for two or four independent MAC addresses. With active autonegotiation, they support half and full duplex.

A transmission rate of 100 Mbit/s is available for each interface. All Ethernet interfaces are connected to the internal USB hub. As USB interfaces and Ethernet interfaces share a USB bandwidth, the transfer rate may be reduced if additional USB devices are connected.

revpi-flat-usb-schema

LAN 0

The MAC address for LAN 0 is printed on the front of the housing. Under Linux, the interface can be addressed with :

  • eth0

LAN 1 (switch) or LAN 1 ... LAN 3

Up to three additional devices can be connected to a network via the three RJ45 sockets for LAN1. They are connected to the internal USB hub via a 1:3 switch. The MAC address for LAN 1 is printed on the front of the housing. Under Linux, the interface can be addressed with:

  • eth1

The three connections for LAN 1 can be assigned to independent MAC addresses via DSA. The storage location for the MAC addresses is

  • /boot/config.txt

If no addresses are entered in this file or after a new image has been installed, the factory MAC addresses are used.

WLAN and BT

Prerequisites

✓ RevPi base module with WLAN interface

✓ DHCP-capable WLAN router

✓ Optional: external RP-SMA WLAN antenna

The WLAN interface operates at 2.4 and 5 GHz and complies with the IEEE802.11a/b/g/n/ac specification.

Under Linux, you can address the WLAN interface with , provided no other WLAN devices are used:

  • wlan0

Activate WLAN via RevPi status

▷ Start RevPi Status.

▷ Activate the Enable/Disable build-in WLAN option in the CONFIG tab.

Restart the RevPi.

Set up WLAN country code via raspi-config

The regulations and frequency ranges for WLAN networks are different for each country. Configure the WLAN country code so that the RevPi does not transmit in prohibited areas or cause interference.

▷ Log in to the RevPi via a terminal.

▷ Open raspi-config with the command:
sudo raspi-config

▷ Use the arrow keys to navigate to the Localization Optionsmenu.

▷ Select the WLAN Countryoption.

▷ Select the appropriate country from the country list and confirm with ENTER.

Restart the RevPi..

❯❯ The WLAN country code is active.

Set up WLAN connection via NetworkManager

The WLAN connection is set up via the NetworkManager nmtui. The NetworkManager is a terminal-based user interface for managing network connections under Linux.

▷ Log in to the RevPi via a terminal.

▷ Start nmtui with the command
sudo nmtui

❯❯ The nmtui user interface appears.

Use the arrow and ENTER buttons to navigate within nmtui.

▷ Select Edit a connection.

▷ Select the appropriate Wi-Fi network.

▷ Enter the WLAN password under Password and configure any other WLAN settings.

▷ Save the settings with OK and return to the home screen with *Back *.

▷ Select Activate a connection.

▷ Select the Wi-Fi network and activate the connection with the ENTER button.

     ❯ The status message Connecting ... appears.

     ❯ The WLAN connection is established.

Setting up BT Interface

BT interface Standard 5.0 is also available via the same SMA socket as for the WLAN interface.

▷ Log in to the RevPi via a terminal.

▷ Activate the HCI interface with the command:
sudo systemctl enable hciuart

▷ Start the hciuart service with the command:
sudo systemctl start hciuart

▷ Start the BT daemon with:
sudo systemctl start bluetooth

See also:

USB Interfaces

The RevPi has two USB-A Interfaces. This allows USB 2.0 client devices such as USB hard disks, surf sticks, keyboards or mice to be connected.

the power consumption of the connected devices must not exceed 2.5 W (500 mA @ 5 V) per port. In the event of an overload, the power is switched off at the corresponding USB interface.

The USB interfaces share a USB hub on the RevPi with the two Ethernet interfaces and a Bluetooth interface. This can influence the maximum bandwidth.

The USB interface is suitable for a maximum of 64 DAM-based USB devices.

You can display the USB devices connected to the USB subsystem with the following:

pi@RevPi0000:~ $ lsusb -t

/:    Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M

|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M

|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M

|__ Port 4: Dev 4, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M

|__ Port 5: Dev 5, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M

LEDs

LED PWR

The PWR (Power) LED indicates the device status.

SignalFunction
GreenPower supply is connected.
RedThere is a communication fault between connected modules.

LED A1 – A5

LEDs A1 to A5 are customizable.

The LEDs can be used for user-specific requirements such as indicating a network connection, indicating that a memory limit has been exceeded, monitoring a process and indicating faults.

The LEDs can be switched in the command line application piTest with the variable RevPiLED.

The RevPiLED output has a defined byte length and therefore has a certain number of bits that are read from right to left. Certain bit positions are each assigned to an LED. The LED is switched by setting the respective bits to 0 or 1.

LEDAssigned bit position
A10 and 1
A22 and 3
A34 and 5
A46 and 7
A58 and 9

An LED signal is set in the command line with the command piTest -w RevPiLED,x where x corresponds to the decimal value calculated from the respective bit pattern.

LEDSignalBit patternDecimal value
A1 – A5off0000 0000 00000
A1green0000 0000 00011
red0000 0000 00102
orange0000 0000 00113
A2green0000 0000 01004
red0000 0000 10008
orange0000 0000 110012
A3green0000 0001 000016
red0000 0010 000032
orange0000 0011 000048
A4green0000 0100 000064
red0000 1000 0000128
orange0000 1100 0000192
A5green0001 0000 0000256
red0010 0000 0000512
orange0011 0000 0000768

To switch several LEDs simultaneously, the respective decimal values have to be added up.

Example: If LED A1 shall flash red and LED A2 green at the same time, the command is piTest -w RevPiLED,6 (bit pattern: 0000 0110 = decimal values 2+4).

:::tip:::note

If a signal is to be added to an existing LED circuit, the value for all required signals must be recalculated and rewritten.

:::

Digital output (relay contact)

You can use the digital output to switch external devices on and off, for example. It is designed as a potential-free relay contact. Control is therefore effected via a mechanical connection of the pins.

revpi-flat digital output relay

The relay contact may be loaded with a maximum of 30 V DC or 24 V AC and 2 A.

A suppressor diode is connected in parallel to the relay contact to reduce the switching sparks that occur when switching inductive loads. This reduces wear. An external freewheeling diode or similar is not required.

Control with piTest

You can switch the relay via piTest with the -w option:

▷ Activate the relay with the command piTest -w DOut,1

▷ Deactivate the relay with the command piTest -W DOut,0

Direct Control

You can use the gpio program for direct control of the relay via operating system functions. First you must switch the corresponding GPIO - pin – in this case pin 28 – as the output. Then you can set the output with 1 for switch on and 0 for switch off. The example below shows the corresponding sequence of commands:

▷ Set the pin as the output with the command gpio mode 28 out

▷ Switch the output on with the command gpio write 28 1

▷ Switch the output off with the command gpio write 28 0

Analog Inputs and Outputs

The RevPi has one analog input and one analog output on the 5-pin ANALOG connector.

Analog input

The analog input can be used to measure either voltage or current.

  • U IN: Voltage measurement 0 … 10 V DC
  • I IN: Current measurement 0… 20 mA DC

Current and voltage input must not be connected at the same time, otherwise the measurement result will be distorted.

The current is converted into a proportional voltage via an internal 240 ohm resistor.

The MCP3550-50 analog-to-digital converter (ADC) used for this purpose offers a high usable resolution of 21 bits, but at 85 milliseconds per measurement, it requires a comparatively long time.

There are two ways to access the interfaces: either by reading and writing the Linux sysfs or by using our RevPi configuration tool PiCtory and the software tool piTest, which allows you to access the process image of the system. In the following we describe both methods separately for input and output.

Reading out Values with Linux sysfs

Read out voltage 0 ... 10 V:

▷ Enter the following command to obtain the input value of the ADC:
cat /sys/bus/iio/devices/*/in_voltage0*

▷ Convert the raw value read out to in_voltage0-voltage1_raw with the formula ($raw * 12500) >> 20) + 12500 to obtain the voltage in mV.

Read out current 0 ... 20 mA:

✓ The current should be on the port I IN: are available.

▷ Divide the read out voltage (see above) by a resistance of 240 ohms to obtain the current in mA.

Reading out Values with piTest

You can configure the current/voltage mode for the RevPi Flat in PiCtory with the variables AInMode :

  • AInMode Voltage 0-10V (standard)
  • AInMode Current 0- -20mA

▷ Simply read out the current or voltage value by entering
piTest -r AIn

Analog output

You can connect actuators such as frequency converters to the analog output. It can output a voltage between 0 and 10 V.

The DAC121S101 digital-to-analog converter (DAC) used for this purpose has a resolution of 12 bits.

Entering Values with Linux sysfs

▷ Enter the following command to enter the value in the DAC:
echo2047 | sudo tee /sys/bus/iio/devices/*/out_voltage0_raw

▷ Enter a value between 0 and 4095 into the DAC out_voltage0_raw to output a voltage between 0 and 10 V.

Entering Values with piTest

▷ Enter the analog value in mV in the variable AOut e.g. 5000 mV for the analog output:
piTest-w AOut,5000

More information on implementation

On the software side, the DAC121S101 and MCP3550-50 are treated like IIO modules whose interface is implemented in sysf as “/sys/bus/iio/devices/” also here.

After the converters are successfully registered, the following kernel log usually appears.

pi@RevPi0000:~ $ dmesg | grep "spi.*consumer"

[ 4.461004] mcp320x spi0.1: Linked as a consumer to regulator.1

[ 5.747592] ad5446 spi0.0: Linked as a consumer to regulator.2

Two subfolders are added to the folder sysfs for the converters as /sys/bus/iio/devices/iio:deviceX. You can use X to distinguish between the converters here. The order depends on the registration of the devices and therefore has no fixed assignment. The assignment becomes apparent, however, when you look at the contents of the folders. The folder with the files out_voltage* is the output module and therefore the DAC module. The folder with the files in_voltage* is the input module and therefore the ADC module.

In the method with piTest, piControl retains these values permanently in the process image and you can read and write the values with piTest.

See also:

Watchdog

The RevPi has two independent watchdogs. The first is part of the BCM2837 SoC, which is also used on the Raspberry Pi 3. The second is the Maxim MAX6370 external watchdog module.

BCM2837

The BCM2837 watchdog is the preferred watchdog because it behaves like other watchdogs under Linux. You can access it either via the device file /dev/watchdog0 or as a default watchdog via the device file /dev/watchdog.

MAX6370

The MAX6370 can be accessed via the device file /dev/watchdog1.

To activate it, GPIO4 must be set high once. It can no longer be deactivated via this GPIO, however. For activation via the command line, you can use the gpiod tool: gpioset -m time -u 1000 pinctrl-bcm2835 4=1

gpiod package

The command “gpioset” is part of the gpiod package. If this is not installed, you can install it yourself with sudo apt install gpiod.

If you want to operate the GPIO from your application, the “libgpiod” is right for you. This also provides a Python interface.

You will need the following packages: libgpiod-dev libgpiod2 python3-libgpiod

The timeout of the MAX6370 is fixed at 60 seconds and cannot be changed.

Once activated, the Watchdogs MAX6370 can only be deactivated by disconnecting the power supply. A restart does not deactivate the watchdog. This means that a restart must not take longer than 60 seconds when the watchdog is active, otherwise the hardware will be reset.

Watchdog under Linux

There are several ways to use a watchdog under Linux. The RevPi image and Raspbian rely on “systemd”. This is therefore also the preferred method of using the watchdog. “systemd” can be used to trigger a hardware watchdog. Applications that are to be monitored by the watchdog are then monitored by “systemd”. This has the advantage that several applications can be monitored. Consequently, the entire system does not necessarily have to be restarted, but instead only the individual application.

See also:

Freely configurable push-button

The RevPi has a freely configurable button. The input value of the button can be evaluated via GPIO13 and then used for certain actions, e.g. for a controlled shutdown of the RevPi.

In the PiCtory Value Editor, the input value of the push-button is entered under Top_Button displayed.

It can be retrieved by software in the same way as a keyboard entry. The KEY_UNKNOWN key code is used (corresponds to value 240).