Articles Hierarchy

Articles Home » RPI » RPI operates ARDUINO PID control

RPI operates ARDUINO PID control


WHAT IS A FACEPLATE
now we need a python graphical tool to operate a arduino PID controller,
to show PV, SP, OUTPUT, MODE
and send operation, RSP, MOUT, MODE to a command file
what is read and send to arduino by above service.

it was long long time ago, when the first Process Control System where build,
there was a visualization by so called FACEPLATE ( groups ),
a small graphic element with BAR graph for PV , SP, OUTPUT of a control loop and number representation.
For operation later that bar graphs changed to sliders.
Some years later there where pages with diagrams, static for piping, vessel,
dynamic colored for equipment like motors...
and small groups with colored numbers for control / indicator loops
and when you click on it in same / or new detail view / window that operation faceplate come up.
in a detailed loop window have that faceplate ( for operation )
a window with loop details like settings / tuning
optionally a current trend ( with a faster sampling rate as the historic trend ) for loop tuning.

from benvalle.com i see a good example of a
DELTA V process control system operator station ( starts with x00.000$? )

the basis for this kind of process picture is usually the Piping and Instrument Diagram ( also called PID )
just with some color dynamic and link to operation faceplate.

i want to try to rebuild that HMI starting with a FACEPLATE
with PYTHON on Raspberry PI / so you later can operate YOUR HOME AUTOMATION SYSTEM from the TV.

first i try to use ( like for PMS3 in RPI ) MatPlotLib
sudo apt-get install python-matplotlib
i loaded this slider example and RPI needs 17sec to start it! ( and the google service not running )
this bad timing i now understand, its a first run problem of python / matplotlib
and the slider operation with mouse ( via VNC! ) difficult.
( so i not use it now for the faceplate / slider , but i will come back to it for the trending later)

check on Tkinter
sudo apt-get install python-tk ( allread installed in this version)
and slider example start after 3sec.

after 2 hour play Tkinter and get angry about positioning:

but after using FRAMEs, real values and decimales...
the sliders work for fast / raw adjustment, for small steps (0.1 units) must click
the mouse on the BARGRAPH, above or below the slider.
but a add number input field would be nice!

this looks good and gives alread values back, but is not yet connected to the PID project, files...
so you also can test it first with the python WIN7 IDLE 2.7 version.
here the example code


now the FILE I/O,
we need the read the data from arduino, what is stored to a one line file in ram disk,
to show it in the faceplate.

and, after operation, we need to write the new setpoints ( for RSP, MOUT, MODE )
to a other file in ram disk, what is send to arduino by the service.
and reset to a " " for the service to remember that there is nothing more to do.

PV and SP and RSP need to be converted to PCT.

see record 526 at google, mode change to 2, output to 75,
now why is the setpoint wrong? because in MAN and AUTO the PID controller use its
AUTO setpoint ( open hardwareinput ) and not the RSP value.
( this test worked good, from powerup, but i made it without the power 5VDC
from arduino to servo. with servo i see 2 times problems / but i think
the power connector from the ext 9V is not good.

and with pressing reset on arduino leonardo, RPI sees a different port??

as the service is run by root ( at boot time ) and the operation will be started ( by you ) under user pi there might be some file access problems, but looks good.

now, we are not finished, even indication and operation look good, what is missing is a ( timed ) update of the indication ( bargraphs ) when the stream data file changes.
and my python and python Tkinter understanding is so poor, i need to dig for examples.

this Tkinter timer test, here on RPI ( via VNC ) works on the second compared with desktop.
first i try to indicate the time and for comparison the file info record time
so even the values not change i see that arduino - RPI data stream ok.
the faceplate has 5 sliders,
PV, SP, OUT are set with the value from file and then disabled == indicators only
for update must enable, set, disable.
RSP and MOUT slider are for the operation only.
but with the mode i have a problem, now i set it every sec with the value from file,
and can not operate it any more. there are workarounds, but because that mode indication is anyway a break in this faceplate philosophy, i choose to make a new separate indicator for MODE.

small add changes:
set arduino timer to 2sec / like PID cycle
when running at RPI
manualmenuoperation should be false, and [E] and [ ] is disabled,
when operate arduino by USB terminal window pls enable manualmenuoperation.

to start the faceplateoperation from desktop i made a button




UPS, the google excel is in PCT not degC!!
change in arduinostream
pls download this rev