Stensig
Hi

I'm making a project with a solar heating system where I would like to use a RPI with OpenPLC for programming the control system.
The RPI is fitted with a RPI touch panel for the purpose of making a HMI.
As far as I understand the best and easiest way to make a HMI together with OpenPLC is to use ScadaBR.
However I struggle to understand how these systems work together.
Should the virtualbox and ScadaBR be installed on the RPI? Or should it be installed on a windows machine? 
As far as I can read on various forums the RPI does not have the power to run a virtual machine stable.

One of my main concerns is to make a control system that is functional offline, I do not want my solar heating system to shut down just because the internet connection is lost. 
Is this possible with the ScadaBR which, as far as I can read, is a browser based application? 

Best Regards
Stensig
Quote 0 0
thiagoralves
ScadaBR is a java-based application. The frontend of it (or in other words, the HMI) is viewed on a browser. Both parts of it (the java backend and the HMI frontend) can run on a rpi. However, the java backend can be a little tricky to install as it requires specific versions of tomcat and java to run properly. For this reason I created the virtual machine approach which is an easy method to install it. The virtual machine is a pre-configured computer that has the right version of java, tomcat, and all required packages to run ScadaBR properly. All you have to do is open the virtual machine and you are all set. Given the limited resources available on a rpi, ideally you should run ScadaBR java backend somewhere else on a proper computer, and then just use the rpi browser to access it, so that your HMI can be displayed on your embedded HMI screen. If you still want to run everything on your rpi, then you will have to figure out ways to install java, tomcat 7 and all the other required packages.

edit:
With a quick google search, I found this cake recipe that promises to install ScadaBR on a recent version of raspbian. The original post is in Portuguese (http://forum.scadabr.com.br/t/script-instalacao-raspberry-pi-3/1637). I'm posting here a translation:

Open terminal and go to your home folder (/home/pi) and then type:

wget http://www.powerprime.com.br/download/scadabr/ScadaBR.war 
wget http://www.powerprime.com.br/download/scadabr/WEB-INF.zip

It should download two files from the web. Make sure that they were downloaded with the 'ls' command. Now create a script (type 'nano scadabr_installer.sh') and paste the following contents into the script file:

# Update system
apt-get update && apt-get upgrade -y
# Install tomcat8 and mariaDB
apt install librxtx-java tomcat8 tomcat8-user tomcat8-common tomcat8-admin tomcat8-docs tomcat8-examples mariadb-client mariadb-common mariadb-server -y
# Create the database and define user and password
mysql --user="root" --password="scada"  --execute="create database scadabr;CREATE USER 'scadabr' IDENTIFIED BY 'scadabr';GRANT ALL PRIVILEGES ON scadabr.* TO scadabr;"
# Go to webapps folder on tomcat 8
cd /var/lib/tomcat8/webapps/
# Copy ScadaBR to tomcat folder
cp /home/pi/ScadaBR.war /var/lib/tomcat8/webapps/
# ScadaBR is being decompressed. Wait a few seconds
sleep 30
# Stop tomcat
service tomcat8 stop
# Copy Scadabr patch
cp /home/pi/WEB-INF.zip /var/lib/tomcat8/webapps/ScadaBR/
unzip /var/lib/tomcat8/webapps/ScadaBR/WEB-INF.zip
# Create required folders
mkdir -p /usr/share/tomcat8/common
mkdir -p /usr/share/tomcat8/common/classes
mkdir -p /usr/share/tomcat8/server/classes
mkdir -p /var/lib/tomcat8/shared/classes
mkdir -p /var/lib/tomcat8/server
mkdir -p /var/lib/tomcat8/shared
mkdir -p /var/lib/tomcat8/shared/classes
mkdir -p /var/lib/tomcat8/common
mkdir -p /var/lib/tomcat8/common/classes
mkdir -p /var/lib/tomcat8/server/
mkdir -p /var/lib/tomcat8/server/classes
# Change ScadaBR owner to tomcat8
chown tomcat8:tomcat8 /var/lib/tomcat8/ -R
# Insert user tomcat8 on dialout group (Allows the use of the serial port)  
sudo gpasswd -a tomcat8 dialout
# Start tomcat8
service tomcat8 start


Give executing permissions to the script you just created and run it:

chmod +x scadabr_installer.sh
./scadabr_installer.sh


I've not tested it. Use it at your own risk and report back if it worked.
Quote 1 0
Stensig
Hi Thiago

Thank you for the reply.
If the java backend is installed directly on the Raspberry Pi, will it then be able to run both the control system (Open PLC runtime) and the HMI (scadaBR frontend) in offline mode? 
Quote 0 0
thiagoralves
It should. However, if I'm not mistaken tomcat uses port 8080 by default, which means that both tomcat (ScadaBR) and OpenPLC runtime will try to use the same port and fail. You can try to change tomcat default port or change OpenPLC runtime port. To change OpenPLC port, just edit the file /webserver/ webserver.py on line 1848:

app.run(debug=False, host='0.0.0.0', threaded=True, port=8080)

and then change the port=8080 to something else, like port=8081. Then, obviously, to access OpenPLC runtime you must access http://[your-pi-address-here]:8081
Quote 0 0
Stensig
Thank you for the answer. 
I'll give it a try:-)
Quote 0 0
gustavo.ledandeck
Thiago, eu sou um estudante da UFABC e estou fazendo minha IC fazendo exatamente o que o Stensig comentou, usar o scadabr e o openplc no rpi 3b+. Eu testei este script e n conseguia entrar pela serial usando localhost:8080/ScadaBR/   mesmo tendo feito a alteracao da porta do openplc pra 8081, o que ja me ajudou. 
enfim, este guia 
http://forum.scadabr.com.br/t/guia-de-instalacao-do-scadabr-para-uma-nova-instalacao-do-servidor-ubuntu-64bit-sem-cabeca-versao-16-04-3-usando-o-mariadb-mysql-como-base-de-dados-tambem-funciona-em-raspberry-pi-3/1545/3

me ajudou e fez de fato rodar por serial, porém ele roda a versão 0.9 do ScadaBR, aparentemente existem problemas com a versão ataul em usar serial port.
Eu venho me aprofundando no projeto de fazer um clp de baixo custo usando o rpi 3b+ sendo um ingressante que está completando agora o primeiro ano de graduação kkkk, mas mesmo assim vejo que o seu projeto é algo admirável, visto que, além de open source, é brasileiro e multiplataforma. Gostaria de um dia conversar sobre com você e quem sabe poder fazer parte do desenvolvimento do hardware próprio do openplc project mais pra frente.

OBS: eu não possuo inglês adequado (e também me falta conhecimento técnico para afirmar o por quê do erro) para explicar o guia do link que postei, se poder traduzir para os demais que estejam fazendo a mesma coisa eu agradeço. 
Quote 0 0
MannyK
Hi,

I followed the steps but when I executed the script, I got the following error message
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
./scadabr_installer.sh: line 6: mysql: command not found
./scadabr_installer.sh: line 8: cd: /var/lib/tomcat8/webapps/: No such file or directory
cp: cannot create regular file '/var/lib/tomcat8/webapps/': No such file or directory
Failed to stop tomcat8.service: Access denied
See system logs and 'systemctl status tomcat8.service' for details.
cp: cannot create regular file '/var/lib/tomcat8/webapps/ScadaBR/': No such file or directory
unzip:  cannot find or open /var/lib/tomcat8/webapps/ScadaBR/WEB-INF.zip, /var/lib/tomcat8/webapps/ScadaBR/WEB-INF.zip.zip or /var/lib/tomcat8/webapps/ScadaBR/WEB-INF.zip.ZIP.
mkdir: cannot create directory ‘/usr/share/tomcat8’: Permission denied
mkdir: cannot create directory ‘/usr/share/tomcat8’: Permission denied
mkdir: cannot create directory ‘/usr/share/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
mkdir: cannot create directory ‘/var/lib/tomcat8’: Permission denied
chown: invalid user: ‘tomcat8:tomcat8’
gpasswd: user 'tomcat8' does not exist
Failed to start tomcat8.service: Access denied
See system logs and 'systemctl status tomcat8.service' for details.


Any help is appreciated! Thanks.
Quote 0 0
thiagoralves
You must run the script as root or under sudo 
Quote 0 0
MannyK
I got the script to run and I think I installed it successfully. I also changed the port of the openplc to 8081. When I go to [ip address]:8080, I get a screen saying I setup Tomcat successfully. How do I see the scadabr page? Sorry I'm very new at this.

Thank you!
Quote 0 0
jonHar
Hi, http://[your-pi-address-here]:8080/ScadaBR/
Quote 0 0
MannyK
Hi,

I get this when I type that in.

HTTP Status 404 – Not Found


Type Status Report

Message /ScadaBr/

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/8.5.38 (Debian)

Quote 0 0
thiagoralves
It is /ScadaBR and not /ScadaBr 
Quote 0 0
MannyK
I get the same thing when I enter ScadaBR.

HTTP Status 404 – Not Found


Type Status Report

Message /ScadaBR/

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/8.5.38 (Debian)

Quote 0 0
thiagoralves
Then the script failed to install ScadaBR. Make sure that /var/lib/tomcat8/webapps/ScadaBR/ folder exists
Quote 0 0
MannyK
Hi,

That folder exists. Not sure where to go from here. Any ideas?
Quote 0 0