Dette prosjektet er resultatet av en bacheloroppgave ved Norges teknisk-naturvitenskapelige universitet, NTNU i Trondheim, våren 2020.
Prosjektet er et samarbeid mellom Wago Norge og Johan Haukalid, Markus Raudberget, Jone Vassbø og Peder Ward.
Prosjektet omhandler utarbeidelse av et styre- og overvåkningsystem for distribusjon av drikkevann. For detaljer rundt prosjektet henvises det til hovedrapporten. Rapporten er på norsk, men all tilhørende kode er på engelsk.
This project is a result of a bachelor thesis at Norwegian University of Science and Technology, Trondheim, spring 2020.
The project is a collaboration between Wago Norway and Johan Haukalid, Markus Raudberget, Jone Vassbø og Peder Ward.
In the project there is developed a control and monitoring system for distribution of drinking water. The report is in Norwegian, but all code is in English. The system contains three PLCs and one HMI, with control logic developed in Wago's software, e!Cockpit. For functionality regarding simulation, leak detection, data storage and dynamic mapping between OPC UA and MQTT, there are developed applications in Python. For a quick overview, see the figures below.
Communication between HMI and PLC:
Communication between PLC and applications running on cloud-server:
Technologies etc: Python, MQTT, MySQL, Docker, Docker-compose, OPC UA, e!Cockpit.
Docker, Visual Studio Code (With remote development extension) and Git Bash
- Docker is used to run dependencies and development environment.
- Visual Studio Code is used to write code etc.
- Remote development extension is used to connect VS code to Docker development environment.
- Git bash is used to run build and deployment scripts.
- Open root folder in container with VS code.
- Use vs code Test menu (recommended)
- Or from root:
python -m unittest discover test -p '*_test.py'
docker build -f Dockerfile-tests -t pythontestapp .
docker run -d --name app pythontestapp sleep infinity
docker ps -a
docker exec app python -m unittest discover test -p '*_test.py' -s test -v
docker rm -f app
- Use vs code run and debug menu, choose from the dropdown
Build to PLC (source)
- To avoid long pull-time, re-use image tag
- Docker hub account
- Docker settings -> Daemon -> Enable Experimental features
- Add builder:
docker buildx create --name builder-for-plc
- Configure to use it:
docker buildx use builder-for-plc
docker buildx build -f dockerfile-name --platform linux/amd64,linux/arm64,linux/arm/v7 -t username/imagename:tag --push .
E.g:
docker buildx build -f Dockerfile-plc2-pressure --platform linux/amd64,linux/arm64,linux/arm/v7 -t jonev/ba-wago:v6 --push .
- For the different applications, this build and push command is simplified with running the file:
./push.bat
or for each plc:./plcX.bat
- All images are build for
amd64
,arm64
andarm/v7
architectures.
- "No space left on device", run
docker system prune
and delete also images withdocker image prune -a
- Download .ipk file
- Follow this guide.
- Add a
docker-compose.yaml
file to the PLC, containing the image - Connect to the PLC with SSH
- Pull image with:
docker-compose pull
- Run image with output to terminal connected:
docker-compose up
- Or run detached
docker-compose up -d
- Or restart
docker-compose restart
- Or restart only one container
docker-compose restart "service name"
Putty, or Termius (supports saving passwords and transfer files)
- Log inn and drag files between the two computers