拙网论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 255|回复: 0

OPENPLC ON RASPBERRY PI

[复制链接]

949

主题

1001

帖子

3736

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3736
发表于 2020-1-14 21:53:32 | 显示全部楼层 |阅读模式


OPENPLC ON RASPBERRY PIhttps://www.openplcproject.com/getting-started-rpi

Make sure that your Raspberry Pi is running a recent version of the Raspbian operating system. To avoid compatibility problems, it is better to download the most recent Raspbian form the Raspberry Pi website and make a fresh install.
The best way to get OpenPLC files into your Raspberry Pi is by using git. Usually, git comes pre-installed on Raspbian. If for some reason you don't have git installed on your system, you can install it by typing:
sudo apt-get install git
To install OpenPLC type these lines on the terminal:
cd OpenPLC_v3
./install.sh rpi
The installation process will take a while (up to 1 hour depending on your system). Meanwhile, grab a [insert your favorite beverage here] and relax! Once OpenPLC is installed, just reboot your device and it will start automatically after boot.
The OpenPLC runtime has a built-in webserver that allows you to configure OpenPLC and also to upload new programs for it to run. This webserver can be accessed by opening a web browser on your computer and typing the IP address of your OpenPLC device at port 8080. For example, if your Raspberry Pi has the IP 192.168.0.103 on your network, you should type this on your browser:



If you don't know the IP address of your board, the Raspberry Pi foundation has a nice guide to help you out.
Once you access OpenPLC webserver, you should see in your browser window a login page like this:



The default username and password is openplc (login) and openplc (password). This means that the first thing you must do after logging in for the first time is change the default username and password! It is very easy to do that. Just go to the Users menu, click on the OpenPLC User and change the information as you like.



Once you save the changes you will be prompted to login again. Just login with your new credentials and you will be good to go!

PIN MAPPING




By default OpenPLC runtime is installed with a blank driver. This means that it won't be able to control your Raspberry Pi pins straight away. To enable the Raspberry Pi driver, go to the "Hardware" section and from the popup menu, select either "Raspberry Pi" or "Raspberry Pi - Old model (2011 model B)" depending on your board. Click on "Save changes" and wait for a little bit while the driver is applied.



Below you will find the OpenPLC I/O mapping for the Raspberry Pi header. The mapping should be the same across all the different board revisions.



There is only one analog (PWM-based) output on the Raspberry Pi, and it is used as the an Analog Out (%QW0.0) on the OpenPLC. Also, take note that the first two inputs (%IX0.0 and %IX0.1) have hardware pullups, which means that if you don't connect anything to them, they will both read as TRUE. This is part of the design of the Raspberry Pi boards, and can't be changed by the OpenPLC software. Therefore, the logic on these first two inputs must be reverse.

MY FIRST PROJECT
The REFERENCE menu on this website has a nice tutorial that teaches you how to create your first project. However, if you're in a hurry, you can download the official Hello World project, which is basically one rung, a button, a timer and a coil, all connected together. The button is attached to %IX0.0 and the coil is attached to %QX0.0. When the button is pressed and released, the coil is energized and remains on for 2 seconds, and then turns off.



Download the project below and open it on OpenPLC Editor. Click on Generate program for OpenPLC Runtime in order to compile the diagram into a ST file. Then upload the ST file to the OpenPLC using the web interface.
PS: For the Raspberry Pi, this program needs to be slightly modified because the first two inputs actually have hardware pullups on the board. You need to either use another input (%IX0.2, %IX0.3, ...), or negate the button contact on the ladder logic for it to work properly.



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|抱朴守拙BBS

GMT+8, 2025-5-26 04:29 , Processed in 0.202089 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表