PLC.JS – the first truly freely programmable controller

We are a small team of automation engineers, and we have a dream: for engineering professions in the field of process control systems to become prestigious and respected in our country.

The method that we consider the most effective in solving this problem is lowering the threshold for IT specialists to enter process control systems and “retaining” them in the industry by popularizing GNU/Linux IIoT devices.

This is the only way, in our opinion, that the industry can become attractive to young IT workers and reach a new level.

Oddly enough, with the development of IoT, quite a few interesting startups and industrial devices (Industrial IoT) have already appeared. Some have developed their own solutions based on SOMs (System-on-a-Module), some even made boards from scratch and successfully put their own devices into production. This can't help but rejoice!

But, unfortunately, industrial IoT manufacturers experience the same problems:

  1. Redundancy for medium and small automation tasks and, as a consequence, the high cost of devices. Support for HDMI 2.1, Ethernet 2.5G, NVMe is, of course, great, but for small automation tasks you need affordable devices for 10-20 thousand rubles.

  2. Lack of support for full-fledged “GNU/Linux with root access” out of the box. We’re not even talking about assemblies that protect microsd from damage and wear. We need acceptable images with guaranteed performance, on which current software platforms for solving applied problems can be easily installed. Instead, non-standard, trial embedded assemblies of dubious quality are usually offered.

  3. The third and, perhaps, main problem is that IIoT device developers continue to “think in the IEC 61131-3 paradigm.” They make good hardware, but they promote the software part along with their “unique” engineering software. Usually this is another graphical dashboard configurator in the IEC style. At best, it turns out something like “NODE-RED”, which for IT people is ultimately not much different from development in IEC environments.

We have been looking for IIoT for our tasks for a long time, devoid of at least the first two drawbacks, we even turned to several well-known manufacturers for support, but unfortunately it was either expensive or there were problems with the software. This is how the idea of ​​creating the “PLC.JS” project was born, the main essence of which is:

  1. For medium and small automation tasks, use ready-made, inexpensive single boards such as Orange, Raspberry, Banana, RockPi, with which the market is simply flooded;

  2. Do not try to repeat engineering software according to IEC patterns, but use modern environments and tools.

First steps

We have drawn up a small checklist of what we want to get in terms of hardware in the end:

  • Select pilot single-plate plan.

  • Provide input power 24 V DC, in fact 6-30 V – without this there is nowhere in the process control system.

  • Add hardware RTC on the DS3231SN chip via I2C – accurate time is needed even for the simplest tasks, such as automating ventilation or lighting in a store.

  • Add an RS485 interface on the ST485BDR/MAX13488 chip (the board is configurable for both chips), UART is used for data transfer.

  • Provide a short shutdown delay with indication on the GPIO leg after a power failure to save retain data to a flash drive. Because if the board has poor power supply, even the correct system settings, RAM disks and readonly mode will not help. During operation, the ionistor must be charged and is in a charged state. After a power failure, the ionistor is discharged through a diode to the L6920DCTR converter. The input power presence signal comes to the GPIO, which can be used as a trigger to safely save data and shut down.

  • Place the board in a standard DM4G case – the device should easily fit into any automation system, be it a home electrical panel or a sectional floor stand.

  • Place the OrangePi module so that the Ethernet, SD-card and USB-type C connectors are accessible. Shove in the inconvenient, so to speak.

  • There should be no inputs/outputs on board the device, otherwise we fall into a trap – we become attached to the box and then it is difficult to replace it with analogues when upgrading. There is a huge amount of ready-made and time-tested IO peripherals on the market for every taste and color.

  • Add LEDs to indicate something, as well as the presence of 5 V power – for beauty and for the future.

  • Cost ~15 thousand rubles.

Implementation

Obviously, the very essence and design of stock prototyping boards prevent this. Their main disadvantages: the lack of a housing, 5V power supply from USB, and the lack of general industrial communication interfaces.

First we decided on a single-plate plan. There were several options, but we settled on the Orange Pi R1 LTS. This version on RockChip RK3328 is small in size and is not swollen from an overabundance of interfaces. There are two Ethernet ports and a small GPIO header. The price of such a single-plate device is low.

General view of the Orange R1+ LTS board

General view of the Orange R1+ LTS board

Then we developed a single-board power board.

At first, they decided to refuse 220 V power supply, since it was necessary to certify the device operating in 220 V AC networks. But for the future we have already decided that we will use a Chinese converter such as Hi-link HLK-PM01 or similar from MeanWell. For the first version of the controller, it was decided to power the controller from a 24 V DC network, which in 99% of cases is available in control and automation cabinets. In principle, a step-down DC-DC converter from AliExpress will help us. But it needs to be soldered into the board like a human being, and also provide a power connection not via USB Type-C, but through two wires, like an adult, screwing them into the terminal block.

Next, it was necessary to decide on communication interfaces and options. The choice fell on RTC and RS485. There simply aren’t enough GPIO pins for anything more. The real-time chip was chosen DS3231SN, although it is expensive, it has good accuracy (at 2 ppm – 0.1728 sec per day) and has a special input for the battery, which provides independent power to the clock for a fairly long period. Instead of a battery, a miniature Li-Po battery of 30 mAh was installed. The RTC chip communicates with the processor board via the I2C interface.

The RS-485 interface is built on an inexpensive ST485BDR chip from ST. The main criterion is a 5 V supply. Flow control is done through an additional GPIO channel. But the board was designed so that it was possible to install the MAX13488 chip with built-in transmission direction control. Then there will be one GPIO pin left in reserve. Configured by jumpers RJ1-RJ3.

UART - RS485.  Version - MAX13488

UART – RS485. Version – MAX13488

Now about the ionistor. According to our calculations, a capacity of 2.5 F should be enough for 5 seconds, which should be enough to save any Retain data, backups and logs in the event of a power failure. We did not use existing UPS chips (for example, MAX38888 from Analog Devices), since they are expensive and cannot be afforded in the current realities. After the Step-Down converter, the L6920DC DC-DC Step-UP converter was used. It operates in bypass mode when the input is 5V and maintains the output at 5V while the input capacitor is discharged through the 2D4 diode. Resistor R1 is needed to limit the charge current, otherwise the 2D3 diode will “burst” or the MP1584EN converter will go into protection.

Super Capacitor - DC-DC L6920

Super Capacitor – DC-DC L6920

We also added SMD status LEDs to the base board. Previously, the LEDs were placed on a board on the third floor of the case; this seemed to us not the best solution; this board was abandoned. The third modification of the base board is currently being tested.

Photos of several attempts in the case

Photos of several attempts in the case

Photos of baseboard options

Photos of baseboard options

There was an attempt to use a non-standard case model (the model was developed, but not prepared for casting), but this path is very expensive and only for large series of the product. We took a more predictable and less dangerous path – we used ready-made Chinese ABS cases. These are sold on Alika and ChiD.

Tracing the printed circuit board is not complicated; it had to be done as cheaply as possible.

Trace option

Trace option

The choice of the factory where the printed circuit boards will be manufactured fell on Rezonit. Once we ordered on AliExpress through intermediaries – we didn’t like the timing. But we do not dismiss production in China. It makes sense to order a series. Perhaps even with surface mounting, they didn’t ask the price.

We created a 3D model of the case in Inventor according to the drawings in order to try on the boards and see the three-dimensional picture. There were two options for placing the boards in the case. The first is when the Orange board is attached with four screws to the remote panel, which, in turn, is fixed on the second floor of the case.

Board version with adapter

Board version with adapter

We also modeled this remote holder in Inventor and printed it on a 3D printer. Cheap and cheerful. It turned out well, but the Orange was too close to the power board, and it was inconvenient to insert the Ethernet connector. The picture shows (the leftmost building). We decided to redo it. We arrived at the board-to-board connector on the 13-pin header only on the second try. In the first versions it was on wires and connectors with a pitch of 2 mm.

Now Orange is mounted on ~20 mm posts. We print the stands on a 3D printer, but standard store-bought ones with M2.5 internal threads at the ends will also work.

Board without adapter, on stands

Board without adapter, on stands

And the model in Altium looks like this.

MultiBoardModel in Altium

MultiBoardModel in Altium

Full model in Inventor.

Model in Inventor

Model in Inventor

Photo of what happened.

Photo of the board without Orange

Photo of the board without Orange

Photo of the finished assembly (without RS485 terminal)

Photo of the finished assembly (without RS485 terminal)

Photo of the finished assembly, view of the ionistor

Photo of the finished assembly, view of the ionistor

Summary

Thus we got:

  1. An inexpensive serial IIoT device (cost up to 15 thousand rubles), which is suitable for medium and small automation tasks.

  2. The most important thing is that the basic single-board does not have any design or software modifications; it is easy to replace or update the OS from the original vendor.

The second modification “PLC.JS Orange PI CM4 edition” is approaching – essentially everything is the same, only a different, more interesting board was taken as the basis. We are gradually planning to expand the line of devices in the same way for other popular single-board devices.

Project on Orange CM4

Project on Orange CM4

If you are interested in PLC.JS devices, we plan to start the first sales in August 2024, after testing is completed.

All design sources will be posted on the website www.plcjs.ru after testing is completed. We will be glad if our developments motivate IIoT manufacturers to develop more universal and affordable devices!

Perspective

In the following articles we will talk about the implementation of the software part and the use of devices on real automation objects.

We see the minimum task for the software part as follows:

  1. Open Source for basic software. We are still thinking about the hosting platform (most likely it will be GitFlic).

  2. The base software project should not be tied to a specific box. This should be a classic Node.js project that can be easily deployed to any other IoT, not just ours.

  3. Implementation of 100% native development and debugging of applied engineering software in modern IDEs (we focus on VSCode).

  4. Support for the most popular industrial I/O modules from well-known manufacturers (in the form of software classes). The application engineering software developer does not have to waste time interfacing IoT and I/O modules.

  5. Implementation of all the basic primitives of the automated process control system: clock timer, PID controller, motor, valve, etc. (in the form of program classes). This will help newcomers to process control systems quickly master all the basic primitives of the industry.

  6. Implementation of ModbusTCP Server – the software part must support any modern HMI panels and SCADA systems out of the box.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *