Articles Hierarchy

Articles Home » RPI » RPI for control?

RPI for control?

as i mentioned, i worked many years about industrial control,
instrumentation, control as PLC and Process Control Systems.
i order, program, startup many systems ( for chemical factories )
what includes also loop check and training...

also i am retired now already some years,
play with the combination
PC - Arduino or
RPI - Arduino..
RPI as web server
ESP as web server and controller
but NOT much about RPI - GPIO ( but see here and here )

actually all that concept questions are coming up right now again
and even in some BLOG i argued already about that,
i want give it a other shot here:

why need a distributed control system?

also i would like to go one step further:
talk about situations where you not follow me,
like want use a RPI and its GPIO for control,
but again should think about the software concept.

so what was the question?

? if you have a system running on Arduino
and want change that to now using a RPI instead
because you want add a setpoint ( option selection ) operation level.
i say: bad idea!

-a- you need to do all the control code again on RPI
and in a different programming language

-b- you can never shutdown / reboot / new setup the RPI
( what is required more often as with a Arduino )
without disturbing the control

-c- any control on RPI would be something like the known
softPLC ( windows S5?S7? ) what for good reasons lives in the shadow.
a control job needs to be done in a controller ( PLC .. Arduino )
and not under a OS like windows or linux.

-d- how often you need
the control? -24h-
the visualization -1h-
the operation -5m-

-e- what is a DCS
a DCS, Distributed Control System or Process Control System
adds visualization, alarming, operation, current and hist trending, reporting, batch control
to a Controller, but usually still different from a dedicated PLC
what is faster for digital ( input events )
but less strong for bigger amounts of analog I/O and PID control.

the DCS controllers are networked to the operator station
but would do their job even on power fail or disconnect of the visualization / operation level,
today normal (windows/linux) PC's
?possibly on a redundant ethernet network?

now to simulate that in small i use
RPI for operation...
usb link to Arduino for control
to upgrade just need to add a protocol
+ RPI processing / python can do firmata
+ arduino possibly just run firmata or added to existing code
your own protocol
i like readable text ( CSV, JSON ) for easy troubleshoot by arduino IDE monitor

-- with the USB link must think about the power:
while RPI connected Arduino can use USB 5V for operation.
but if RPI shut down Arduino also has no power.
so a add power supply for arduino (Vin 7..12VDC) is good, a kind of UPS even better.

now lets say you ignore the advantages of a separation of control and operation in hardware,
because you want have all in the RPI and use the RPI GPIO,

and yes, if you search there is many "UPS for RPI" info

you might try to use processing or python
and using a GUI lib make a nice desktop app.
but again, you should not drive/control the hardware I/O
- - because again you could not stop / restart / edit that program
without loosing control. ( so yes, for a pure visualization it would not matter too much)

so what to do here?
i do that many times already like for the operation of the Arduino..
there is a service program ( possibly python ) what does the USB communication/ or GPIO handling,
it starts at boot, taking and creating files PV_from process, SP_to_process
in the background.

and the OPERATOR program ( also python or processing ... )
the user starts ( if requred ) as a pure desktop app,
what then reads the PV files and writes SP files on operation.

a optional trending app ( again better a service program at boot )
can run independently and read the PV_files and writes to a database

while the OPERATOR program shows the actual PV data from file on screen and
has a optional trend interface to the database to show charts.

if you have a concept like this you can easily add a webserver page for a remote visualization

writing files on a RPI to a SD card ( like every second ) would soon finish your system.
so when i use files in the above way to separate a online offline type applications
use the RAM disk of RPI
ls /run/shm/ about > 60MB
only the reduced/accumulated historic trending data ( like minute average / min / max )
go to SD card sql database file.