dirk
Hi, we develop the RevolutionPi which is an industrial RaspberryPi based on the Compute Module (CM). A community member has asked how he could integrate the OpenPLC SPS.  Here is the original discussion and my answer. So if you have ideas how we could help to put the OpenPLC into operation on the RevPi it would be great.
Reply 0 0
mhd_alm

Now grab the blank.txt file attached to this post, rename it to blank.cpp and copy it to /home/pi/OpenPLC_v3/webserver/core/hardware_layers folder on your Revolution Pi device. Go to OpenPLC webserver, login, go to Hardware, select the Blank Linux driver and click on "Save Changes". This will load the new Revolution Pi driver into the system. Now just click on Start PLC and you will see on the dashboard all your I/O points and their respective location.



Hey @thiagoralves,
I'm trying to follow your instructions... installed OpenPLC on Revolution Pi Core3+ (using linux append, not rpi)

./install.sh linux

when I "Save change" in hardware tab, program does not compile. it freezes on "Generating C files..." (screenshot attached). I am no sure if it's related to topic of this thread though. any idea what I'm doing wrong? Thanks!


Reply 0 0
thiagoralves
Just wait. It can take a couple minutes. If it is taking more than 5 minutes then it might be a problem. How much storage does your RevPi has? Try with a fresh image of the base system, to make sure nothing else is affecting the install 
Reply 0 0
mhd_alm
Just wait. It can take a couple minutes. If it is taking more than 5 minutes then it might be a problem. How much storage does your RevPi has? Try with a fresh image of the base system, to make sure nothing else is affecting the install 


@thiagoralves I waited and waited and nothing happened. Tried with fresh image twice and both attempts were consistently unsuccessful. My RevPi has 8GB memory and after installing OpenPLC I'm at 42% used.

Here's what I noticed during this test: installed OpenPLC on my Raspberry Pi 4 with the exact instructions and it worked (with some IO errors after compile, which is expected). But on Rev Pi no matter what hardware layer I choose, it gets stuck at "Generating C Files". Once again... I need to mention it's a Core 3+ module with "Stretch", not "Jessie". Could this be an issue? Tried to test my hypothesis by booting Rev Pi with Jessie, but wasn't able to. I suspect 3+ model is not compatible with Jessie at all. I'm sure this is not in your department... maybe @dirk can speak to this? 

Edit - need to add: I literally have no other package or software installed... just update/upgraded Stretch, and proftpd.
Reply 0 0
thiagoralves
This is very weird. OpenPLC should work all the way back to Wheezy (I remember those days...). Of course the more updated the best, so it is actually better to run it on Stretch than Jessie. @dirk sent me a test unit a while ago, and that's all RevPi hardware I have. I don't know which base OS it came with as I couldn't spend much time on it. All I did was write the driver and make sure it was working. On my test unit it always worked flawlessly. I wonder if there is anything at your browser that is preventing the refresh update on the compilation window. My point is that, if your device is hanging to compile a project, it shouldn't be able to finish installing OpenPLC at all, because the last step in the OpenPLC installation is to compile a sample project. That's the exact same process that happens when you select a hardware layer driver, or when you upload a new project. Try just refreshing the browser while you're waiting on that screen, or perhaps just opening another browser window and checking the status. You can also ssh into the device and check htop to see if you can find anything consuming an unusual amount of CPU. 
Reply 0 0
mhd_alm
This is very weird. OpenPLC should work all the way back to Wheezy (I remember those days...). Of course the more updated the best, so it is actually better to run it on Stretch than Jessie. @dirk sent me a test unit a while ago, and that's all RevPi hardware I have. I don't know which base OS it came with as I couldn't spend much time on it. All I did was write the driver and make sure it was working. On my test unit it always worked flawlessly. I wonder if there is anything at your browser that is preventing the refresh update on the compilation window. My point is that, if your device is hanging to compile a project, it shouldn't be able to finish installing OpenPLC at all, because the last step in the OpenPLC installation is to compile a sample project. That's the exact same process that happens when you select a hardware layer driver, or when you upload a new project. Try just refreshing the browser while you're waiting on that screen, or perhaps just opening another browser window and checking the status. You can also ssh into the device and check htop to see if you can find anything consuming an unusual amount of CPU. 
 

This was great help Thiago! I saw these in install log:

[FINALIZING]
Activating Blank driver
Setting Platform
Optimizing ST program...
Generating C files...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c
Moving Files...
Compiling for Linux
Generating object files...
Generating glueVars...
Compiling main program...
Compilation finished successfully!


It was indeed my browser. Tried from another machine and worked like a charm! Thanks!
Reply 0 0
thiagoralves
@mhd_alm is the RevPi driver working for you reliably? If so, I'll push it to the main repository and make it available for all users.
Reply 0 0
mhd_alm
@mhd_alm is the RevPi driver working for you reliably? If so, I'll push it to the main repository and make it available for all users.
 

Hey @thiagoralves, unfortunately I haven't got a chance to run an acceptable "test" so can't really speak to this. I'll send updates here when have more answers.
Reply 0 0
Eriknem

Hello,

is there any progress yet? We would like to use Revolution Pi and OpenPLC to teach industrial communication (from PLC to cloud) at our university. We are going to use open-source technologies.

Reply 0 0
thiagoralves
Apparently the driver works, I just need more people testing it to be sure. Feel free to test it on the devices you have and report back if you found any issues.
Reply 0 0
ratchet11243
Checking in as I'm looking at implementing a RevPi Connect+ application with OpenPLC. The I/O includes a DIO and an AIO module, so I can hopefully provide some feedback on how your solution works there.

Just some background on me: I'm coming from an IEC 61131 background, with a little higher level programming training. I'm working with a guy with a bit more of a high level programming background, so hopefully he can translate some of the higher level concepts for me.
Reply 0 0
thiagoralves
Perfect @ratchet11243! Let me know how the driver works, and if it is working well for you I will add it to the main GitHub repository
Reply 0 0
Eddy_Ite
One problem I have with the driver, are the Counters from the DIO module. They are DINT's, but when uploading onto the runtime they are shown as WORD and have significantly less size.There is no Analog module connected to the Revpi.
See the Atttachment for the Logs.
RunTimeLog.png  ExportFile.png 
Reply 0 0
ljb_nj
Currently trying out a RevPi Core 3+ w/ the DIO module. After a little bit of a fight with pip and its handling of the pyserial and pymodbus packages, I got OpenPLC working fine. What I'm wondering is, why does OpenPLC not start itself up on a reboot? I can manually start the script start_openplc.sh and all is well. It just does not start itself during start-up of the cpu. I tried putting a line in rc.local to try to run it but something is causing the script to either error out or fail. Any thoughts?

Outside of that, the driver provided earlier on does seem to work alright, at least with the DIO module. I'm starting out very simple (Input X = Output X) just to first verify IO addressing is good. My end goal is to prove the reliability to both determine if hardware wise, the RevPi devices meet our needs, and to see if OpenPLC can meet the software side.
Reply 0 0
thiagoralves
OpenPLC should start automatically on boot. Check the service logs to see if there is anything preventing it from running on your setup. I bet the problem is related to pip packages not installed on root. If that's the case, try switching to root with "sudo su" and then install the packages it is complaining about on the service logs. To check OpenPLC service logs type
sudo systemctl status openplc
Reply 0 0
ljb_nj
Thiago, I got the following in the log:

openplc.service - OpenPLC Service
   Loaded: loaded (/lib/systemd/system/openplc.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-11-13 22:26:05 CET; 14min ago
  Process: 1191 ExecStart=/home/pi/OpenPLC_v3/start_openplc.sh (code=exited, status=1/FAILURE)
 Main PID: 1191 (code=exited, status=1/FAILURE)
Nov 13 22:26:04 RevPi40957 systemd[1]: openplc.service: Failed with result 'exit-code'.
Nov 13 22:26:05 RevPi40957 systemd[1]: openplc.service: Service hold-off time over, scheduling restart.
Nov 13 22:26:05 RevPi40957 systemd[1]: Stopped OpenPLC Service.
Nov 13 22:26:05 RevPi40957 systemd[1]: openplc.service: Start request repeated too quickly.
Nov 13 22:26:05 RevPi40957 systemd[1]: Failed to start OpenPLC Service.
Nov 13 22:26:05 RevPi40957 systemd[1]: openplc.service: Unit entered failed state.
Nov 13 22:26:05 RevPi40957 systemd[1]: openplc.service: Failed with result 'exit-code'.


Update: Taking the hint, looks like pyserial was wacky still, which looks like pymodbus depends on. Forced reinstall of pyserial 3.2.1, which allowed pymodbus to install w/o any errors. Thank you!
Reply 0 0
Reply