EsPiFF

An ESP32-WROVER with an RP2040 co-processor in a Raspberry Pi 4 form factor

Dec 19, 2022

Project update 3 of 7

Industrial Applications

by Michael Schmid, Steffen Wittenburg

Welcome to the latest update on EsPiFF! Today we want to show you how EsPiFF can be used as an industrial PLC application.

EsPiFF-PLC

Thanks to its reliability and fast IO capacity, EsPiFF makes a great base for a rock-solid PLC (Pogrammable Logic Controller). We’ve created two HATs for it that can be stacked on right on the EsPiFF, and a 3D printed enclosure suitable for using EsPiFF as a PLC. The schematics for the digital HAT are available on GitHub, as are the schematics for the analog HAT. (Schematics are in an alpha state because we could not yet test all functions). As mentioned, you can also download a3D printer file, for an enclosure.

To see how EsPiFF-PLC compares with what the market offers, let’s compare EsPiFF-PLC with two popular PLCs, one on an Arduino base (Industruino) and another based on Raspberry Pi, (Pixtend V2 -S-). We had worked with both of them before we decided to make EsPiFF. Finally, we added the brand new Arduino Opta for comparison.

We do not cover PLCs without C/C++ programming, because Ladder Logic/FBD/ST from companies like Siemens, ABB, Rockwell, Mitsubishi etc. is out of scope for most makers. Also, most of them require an initial investment of several thousand dollars for their proprietary IDE / tools before you can even start.

Comparisons

EsPiFF-PLCIndustruinoPixtend-V2 -S-Arduino Opta
PLC processor RP2040 ATSAMD21G ATMega324A STM32H747XI
Digital inputsUp to 8 Up to 8 8 8
Digital outputsUp to 8 Up to 8 4 0
Digital block isolatedYes Yes No No
Analog inputs4 (16-bit) 4 (18-bit) 2 (10-bit) up to 8
Analog outputs4 (12-bit) 2 (12-bit) 2 (V only) None
Analog block isolatedYes Yes No No
Relay outputs2 0 4 4
Retain memory2 kBytes 0 32 Bytes 0
External RTCYes Yes Yes Unknown
External supervisiorYes No No Unknown
Buffered RTCYes No Yes Unknown
PLC processing2x133 MHz 48 MHz 20 MHz 240 MHz
EthernetYes External (via SPI) Yes Yes
Price$169.00 $272.72 $279.21 $177.10

It’s clear that both competitors have serious limitations: The Pixtend has no galvanic isolation, only four digital outputs, only 10-bit analog inputs and analog outputs. So it’s impossible to drive four 20 mA actuators like proportional valves. The analog resolution with just 10-bit ADCs does not allow accurate measurements, which limits Pixtend’s usefulness to a few low resolution applications.

While the Pixtend offers enormous processing power via the Raspberry Pi, the real-time processing power is very limited by the 8-bit ATMega324. As a result, no more then 500 to 800 cycles per second are possible (In a PLC, all inputs are read and all output are set in one cycle). The analog inputs have a "cut-off frequency of 275 Hz", so our guess would be the analog inputs are limited to 100-150 Hz. A demanding servo application cannot be built with these limations. The Retain memory memory is only guaranteed for 10,000 write operations and the datasheet discourages the use of it (the FRAM on EsPiFF, by comparison, guarantees ten billion write cycles!). Finally the Pixtend is closed source and Pis are not available because of the chip shortage.

The Industruino is simple, easy to program, has four 18-bit analog inputs, two analog outputs (12-bit), eight digital IOs (each can be input or output), and an external RTC. Sounds good so far, but:

While the Pixtend has excess processing power, the Industruino has too little. When you run a Modbus server, the MCU is mostly busy with network traffic.

While we see the 500 to 800 cycles on the Pixtend as slow, it’s even worse with the Industruino: the ADC on the Industruino is an MCP3424 I2C, which offers 3.75 samples-per-second (SPS) (18-bits), 15 SPS (16-bits), 60 SPS (14-bits), and 240 SPS (12 bits). SPS means "Samples Per Second". There will be applications, what are possible within these limits. But hey, that can be done better.

Just for reference, let’s also take a look at the brand new Arduino Opta. It does not have analog outputs, nor even digital outputs, so its usefulness is very limited. The concept of the Opta with a dual core controller is good, to separate IO processing from network processing. Having relays integrated into the PLC is uncommon, and for a good reason: users can simply install as many relays they need on a din rail and choose the exact relay they need for their particular application. Then, you can control the relay using its digital output.

The relays in the Opta are only SPST (single pole, single throw, two contacts each), but many applications need a three-contact version to flip between NC and NO. If you look at the DIN rail relay selection on Mouser, you can see how many configurations are possible. Interestingly, Arduino has moved to closed source and pay-to-use software with their PLC products: "runtime activation for each device will require a license key". Bye bye, open source Arduinos.

We have two HATs for EsPiFF, one analog and one digital. Together with EsPiFF, they form the EsPiFF-PLC. Currently, the hardware has just arrived, so the software will need some time before arriving at the EsPiFF GitHub repo.

EsPiFF-PLC
Digital IO HAT
Analog IO HAT

These two HATs are specially made for EsPiFF: Even though they could mechanically be mounted on a Raspberry Pi Nano, only the RP2040 PIOs have enough PWM channels and pulse-width measurement resources to operate the analog HAT.

The HATs are stacked on the 40-pin header and are all controlled by the RP2040 from EsPiFF. There is a detailed description about the HATs on the EsPiFF github, so we won’t go into detail here. Here’s just a few of the key facts:

As a PLC-IO processor, the RP2040 has multiple times the processing power, RAM, and Flash, compared to the ATSAMD21G on the Industruino or the ATMega324 on the Pixtend. 16 MB Flash compared to 256 kB (Industruino) or 32 kB (Pixtend) result in 64/512 times bigger applications. Given the 16 MB additional SPI-RAM soldered on EsPiFF, the RP2040 on EsPiFF has 512 times the RAM of an Industruino and 8,192 times the RAM of the ATMega324 on the Pixtend.

Having the network stuff handled by its own processor unit frees the PLC processor from this time consuming work. This is provided on the EsPiFF-PLC by the ESP32, as well as on the Pixtend. But only the EsPiFF is built for reliability with an external supervisior, external watchdog, and a proper RTOS.

Speed: we see, even with its enormous processing power of a Rasperry Pi, the Pixtend can at most reach a cycle time of up to 800 per second. The Industruino is limited by its ADC to 240 cycles per second at low resolution ADC or 3.75 cycles-per-second at high resolution. By contrast, here are the EsPiFF numbers:

For the Pixtend, we know its limit of 800 cycles (the manual suggests only 10 Hz!), while for the Industruino we know its limit is 1380 Hz. However, in real world applications, the Industruino will not reach this limit because, as long as it’s answering network packages, the single core cannot operate the IOs at the same time. The unpredictable network processing load will also lead to unpredictable real-time behavior. For the Arduino Octa, no data or experience are available.

Finally, let’s look at a typical PLC application: reading a 4-20 mA transducer, running a PID control algorithm, and setting a new analog value on the 4-20mA output. We implemented this exact scenario for a hydraulic pressure test bench a few years ago. A hydraulic pressure transducer transmitted a 4-20 mA signal indicating the hydraulic pressure in the hose under test to the analog input. Then, the pressure actuator was commanded with an 4-20mA analog output while a PID control algorithm set the current test pressure. The Arduino Octa has no analog or digital outputs, so its out of the game here. Lets see how many such control loops EsPiFF-PLC and its two competitors can handle per second:

We can see the EsPiFF-PLC is more than 14 times faster in analog processing then the Industruino; the Pixtend is out of this game because it does not offer an analog 4-20mA output.

In a pure digital loop (read digital in, compute, set digital out), EsPiFF is still more then four times faster then the Industruino and more then seven times faster then the Pixtend. {espiff-u02-i06 | link}

{espiff-u02-i05 | link} We hope this update demonstrates the power of EsPiFF.


Sign up to receive future updates for EsPiFF.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects