Turn Raspberry Pi into a P.L.C (Programable Logic Controller) Advanced


181 posts   Page 5 of 8   1, 2, 3, 4, 5, 6, 7, 8
by gonzalezquinteros » Mon Sep 10, 2012 4:47 am
industrial systems has widely used Modbus protocol because this is supported by most of the manufacturers (non propietary).
I think, the important thing is to focus on the capability to control (proportional, integrative, derivative) and to design software modules on RPI.
Modbus over Ethernet allows much higher speeds than the latency of the field variables, or the response capabilitiesof the Remote I/O boards.
I think the above scheme can work very well:

(((RPI))) <---------> (DI) <-------> (DO) <-------> (Ai) <---- ----> (Ao)

Note: Digital Inputs - Digital Outputs - Analog Inputs - Analog Outputs and boards of third party manufacturers

The advantage is that these boards (Moxa, Exemys, etc) have implemented the appropriate electronic protections and permit a fast integration with sensors and actuators
They can also serve as human machine interfaces for income states by human operators

Regards and excuse my english
Posts: 1
Joined: Mon Sep 10, 2012 4:07 am
by Dave9111 » Sun Sep 23, 2012 6:07 pm
Interesting topic as I integrate PLCs for a living.

The safety PLC concept is overblown. Unless a PLC is rated as a safety PLC you never rely on it in a safety situation. The use of an external Estop/safety system is a requirement and has been for years.

Regarding the Raspberry Pi as a controller, why not?

I use LinuxCNC quite a bit on integration projects and it has a ladder logic processor built in that can be had as a standalone processor that will run on Windoze and Linux so there is no reason why it can't run on the Raspberry Pi. It isn't IEC compatible, but it should work for basic tasks. IEC compatibility would be really useful for larger projects but is an overkill for smaller projects.

https://sites.google.com/site/classicladder/

I don't know if I would want to enter 100+ rungs of logic into it, but you could. It would be fine for smaller projects. Some integration into MySql could also allow the results to be displayed on a webserver, making for a really cheap MMI - local or remote.

I just received two RPIs after waiting for months. I already an RPI setup as a LAMP server, so far so good. Now I need to tie the GPIO into mysql/webserver and see about possibly adding in Classic Ladder. For $35 this is a no lose situation. I have a couple of control projects that these will be useful for.
Posts: 1
Joined: Sun Sep 23, 2012 5:32 pm
by jani22 » Thu Oct 25, 2012 10:09 am
I just found thic topic. I'm thinking about Raspberry Pi as a master controller for some time.

My expertise are microcontrollers and their usage in automation. I usually use distributed control system with multiple microcontrollers connected into CANopen network. CANopen stack is opensource.


Microcontrollers can be configured as:
- Standard CANopen IO device (CiA DS401) capabele of digital, analog, pwm, encoder, SSI, etc. interfaces.

- CANopen drive device (CiA DS402). Internaly it controls the position. Parameters like ramps, velocity, PID coefficients are configurable. From network it receives commands like controlWord and targetPosition. It sends statusWord and actualPosition. There are many CANopen capable drives available on the market, it is also possible to make own based on microcontroller.

- Custom controller, which reads/writes local or remote signals and works according to program.

- User interface (simple keypad+alphanum display or something better.)

- etc.....



The CANopen stack is published on soruceforge:
https://sourceforge.net/projects/canopennode/

I have an idea to use PIC32 microcontroller, which has allready implemented the CANopen master. It could be easy to make spi interface to RPi. RPi should be then capable to monitor the CAN bus, send SDO master commands (access to parameters on all devices), send custom CAN messages.
(Something similar is allready implemented on SC243, but RPi could be better, cheaper and more opensource.)

RPi can then be used mainly as user interface with additional PLC capability, which don't need to be always real-time. Because remote devices can handle real time tasks (and safety too).
RPi could also be used for more advanced calculation, for exaple for path calculator. Path buffer can then be transmitted to multiple CANopen drive devices according to standardized 'Interpolated position mode'.
Posts: 1
Joined: Thu Oct 25, 2012 8:44 am
by yaccard » Thu Dec 20, 2012 1:27 pm
Hello
There also commercial solution to create soft PLC
Straton for Linux http://www.copalp.com/fr/produits/runti ... index.html resold by Copalp (According to Mr Sébastien Roberto de Copalp, the Straton solution is operational with the couple linux Debian /ARM 11, you can download a version of test of the software workshop Straton which turns under Windows, this demonstration is limited to 30 inputs/outputs and the run time does not turn more 15 minute, then it is necessary to start again. It is a good initiation with the software of programming to standard IEC61131-3 dedicated to the programmable automats. the download is accessible on copalp. http://www.copalp.com/ com User name: november Password: 2012
Thus I point out this limited demonstration turns on Windows but the application (the final run time) can turn on Linux Debian/Arm11 realising finances.
For my part I work on a global project of building automation (private house or big buildings)
This project is visible on http://speranto.fr (with any soft PLC).
I have eleven years of experience professional in this field but I never found the product which is appropriate to me perfectly
Everyone is invited to take part.
Posts: 7
Joined: Thu Dec 20, 2012 12:53 pm
by eandrese » Sat Dec 29, 2012 8:14 pm
I work for SSAB and we have developed a soft PLC that is open sourced. You can find it at http://www.proview.se I am not involved in the project at all, but i know it runs on Debian so maybe it can be cross compiled? It is likely worth looking into as I think it is exactly what your looking for.
Posts: 1
Joined: Sat Dec 29, 2012 8:11 pm
by 0x17 » Wed Jan 30, 2013 3:50 pm
Hi,

did somebody get the software matiec compiled, I'd like to use Beremiz with the Raspberry Pi, but on Raspbian-armhf I don't get the "stage1_2" part compiled.

Error (German: Fehler) :
Code: Select all
pi@raspberrypi ~/Beremiz/matiec/stage1_2 $ make
make  all-am
make[1]: Entering directory `/home/pi/Beremiz/matiec/stage1_2'
/bin/bash ../config/ylwrap iec_flex.ll .c iec_flex.cc -- : -o.c
make[1]: *** [iec_flex.cc] Fehler 1
make[1]: Leaving directory `/home/pi/Beremiz/matiec/stage1_2'
make: *** [all] Fehler 2
pi@raspberrypi ~/Beremiz/matiec/stage1_2 $


The problem is, that the File "iec_flex.cc" doesn't exists.
It seems the application ylwrap creates it, but when I execute the same command it
don't shows a message.

Hope somebody of you solved this problem.

[url]Beremiz.org[/url]
Posts: 6
Joined: Thu Jan 24, 2013 2:49 pm
by omegacore » Fri Feb 01, 2013 8:01 pm
I just found this thread.

I am a controls engineer working at a DoE lab. We work on a daily basis with EPICS to handle most of our SCADA needs. I think we could really make some inroads here if we started working on an open-free PLC platform.

I was just wondering what the status of this project currently is, and if there are any plans for IO development, specifically for a fieldbus like EtherCAT? I think it would be a huge step forward if we could implement a soft PLC like has been talked about in this thread, combined with support for an industrial fieldbus.
Posts: 3
Joined: Fri Feb 01, 2013 7:57 pm
by mayoman » Thu Feb 14, 2013 10:00 pm
This looks like it effectively died about November 2011, though you might want to view the following thread:
viewtopic.php?uid=49526&f=41&t=4152&start=0
Given the Pi's architecture I think it would be great as a HMI interface card for an open source PLC system, or as a generic HMI card if the software were structured so that you could easily create (& share) software addons for communication with specific PLC brands. But outside of the hobby arena, I think it would be very limited as a PLC.
Posts: 2
Joined: Tue Jan 01, 2013 2:04 pm
by miiicmueller » Mon Apr 15, 2013 7:54 pm
Hello,
The etherCat module of "etherlabs" works fine on the raspberry pi ! Even without RTAI Kernel !
Of course if you want short bus time, by ex. for motion control, you should port RTAI Kernel on the raspberry pi...
I test it with beckhoff EK1100 EthercatBus coupler and with EL1819 2 x 8 digital input 24VDC.
Posts: 7
Joined: Wed Dec 12, 2012 11:23 am
Location: Switzerland
by Riverdj » Tue Apr 23, 2013 7:57 pm
miiicmueller wrote:Hello,
The etherCat module of "etherlabs" works fine on the raspberry pi ! Even without RTAI Kernel !
Of course if you want short bus time, by ex. for motion control, you should port RTAI Kernel on the raspberry pi...
I test it with beckhoff EK1100 EthercatBus coupler and with EL1819 2 x 8 digital input 24VDC.


Wow! That's great!

How to archieve this for a linux mid-user like me? :roll:
Posts: 2
Joined: Thu Mar 07, 2013 10:56 am
by miiicmueller » Fri Apr 26, 2013 10:41 am
Riverdj wrote:
miiicmueller wrote:Hello,
The etherCat module of "etherlabs" works fine on the raspberry pi ! Even without RTAI Kernel !
Of course if you want short bus time, by ex. for motion control, you should port RTAI Kernel on the raspberry pi...
I test it with beckhoff EK1100 EthercatBus coupler and with EL1819 2 x 8 digital input 24VDC.


Wow! That's great!

How to archieve this for a linux mid-user like me? :roll:


The best way is to : (for learning purpose)
1 ) Visit : http://www.etherlab.org/en/components.php
2) Download ethercatMaster kernel modules
3) Study the section "installation" of the ethercatMaster documentation
4) Practice it on the RPI ;-)

Maybe test it (if your're motivated :-P ) with Xenomai( RTAI would be better for compatibility) real-time kernel, for using other "etherlabs" software component.

Good-luck ;-)
Posts: 7
Joined: Wed Dec 12, 2012 11:23 am
Location: Switzerland
by ranpitime » Sun Apr 28, 2013 5:49 am
miiicmueller wrote:
Riverdj wrote:
miiicmueller wrote:Hello,
The etherCat module of "etherlabs" works fine on the raspberry pi ! Even without RTAI Kernel !
Of course if you want short bus time, by ex. for motion control, you should port RTAI Kernel on the raspberry pi...
I test it with beckhoff EK1100 EthercatBus coupler and with EL1819 2 x 8 digital input 24VDC.


Wow! That's great!

How to archieve this for a linux mid-user like me? :roll:


The best way is to : (for learning purpose)
1 ) Visit : http://www.etherlab.org/en/components.php
2) Download ethercatMaster kernel modules
3) Study the section "installation" of the ethercatMaster documentation
4) Practice it on the RPI ;-)

Maybe test it (if your're motivated :-P ) with Xenomai( RTAI would be better for compatibility) real-time kernel, for using other "etherlabs" software component.

Good-luck ;-)


I'll give that a try (with Xenomai), do you think it is possible to patch the pi's standard Ethernet driver EtherCAT-capable or is that .......no way?
Posts: 20
Joined: Sat Mar 23, 2013 5:21 am
by zaidpirwani » Sun Apr 28, 2013 10:28 am
So here I am, after spending about an hour reading the 5 pages of this thread from the start to now.

About me: a BE student trying to make his FYP usign Raspberry Pi at IIEE-PCSIR, Karachi, Pakistan

FYP: to design an automation system using Raspi, (emphasis on making it electrically compatible with the actuators and sensors normally used with PLCs) - a block diagram of proposed final system attached.
RasPLCBLOCKDIAGRAM-(2).gif
RasPLCBLOCKDIAGRAM-(2).gif (45.53 KiB) Viewed 14503 times


but after reading this thread, it has occurred to me that the SOFTWARE side matters more, as that will be better for a project of this scope [not commercial, so please don't start about the real-time issues, or the safety issues, or the watchdog issues, or the business plan issues, or any other such issues] want a device to control a couple relays/motors etc (possibly max VDC at 24V) and get input from some sensors (proximity etc, again VDC 24V and analog in range of current 4-10 mA, am I right), not to be interfaced with some other PLC, single Raspi controlling everything IO modules designed in such a way to be able to interface with the actuators/sensors already on market.

So this is what I have THOUGHT-about so far, we are supposed to work on hardware after from June-2013, but we have to decide on what we are actually going to be doing in coming months
>> separate IO modules, for digital IO and analog (input only for now) similar to: https://code.google.com/p/open-plc/
>> No master/salve Raspis, i.e. only one single Raspi - keepign things simple for now
>> I2C is great and all, but cannot work as noise, speed and bus length issues
>> proposed communication bus is to be RS485, wanting to make/use something like RaspiComm (http://www.raspiprojekt.de/shop/product/view/18/49.html)
>> all modules will have an AVR or PIC with RS485 interface
>> an RTC with Raspi to keep track of time

I want to know if people still interested in this and did anyone got the beremiz to work on Raspi, I would love to work with Beremiz... though not too good with Linux but will try to learn as we move forward, is it possible to control/monitor IO over RS485 using Beremiz created programs..???

Anyways, I LEARNED a LOT just reading the thread, so THANKS to all the people...
especially: @vorrias, @diggy, @thepanoguy (your material will be good for making the report on why it cannot be used in actual industry) and others....
User avatar
Posts: 25
Joined: Sat Sep 22, 2012 6:18 am
Location: Karachi, Pakistan
by abishur » Sun Apr 28, 2013 6:48 pm
To be fair, real PLCs don't have "Real Time" operations. Any good PLC programmer knows that you don't write your code such that it acts in a precise moment of time. You write it to operate in a specific programatic manner withing a realitive time window... but yeah PLCs have much more realistic time operation than a linux based system can hope to acheive :lol:

Now for the i/o side of things, Gert (one of the mods here) has done an amazing bit of work with the gert board if you don't want to buy one, at the very least it's a very good starting point for you on maximizing the i/o of the R-Pi. It's also relatively easy to add an RTC to the pi if you want to (http://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/overview)

I don't see why I2C wouldn't work for PLC type use. Now if you mean communication between multiple PLC-Pis then yeah, that might create dificulties, but typically speaking you bring all the field wiring into a couple feet of the central CPU on the PLC and that should work just fine for I2C communication :-)
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4298
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by Riverdj » Tue Apr 30, 2013 5:11 pm
Hi miiicmueller and all the forum!

Yeah! I will try to compile it, perhaps next week and report the results ;)

Thank so much
Posts: 2
Joined: Thu Mar 07, 2013 10:56 am
by exstud » Sun May 19, 2013 8:49 am
A PLC has its OS in non volatile ROM, which makes it more robust against crashes/power failures. Try hard resetting your pi over and over again (pref during startup), at some point your fancy linux OS will die.

Now don't get me wrong, as a developer of both platforms I hate those expensive 25k RAM (!) PLCs and all the visual programming nonsense that comes with it, but it's really still the only viable option if you need RELIABILITY.

So, the real question then is what would it take to build a PI with the same level of reliability as a PLC?
Posts: 12
Joined: Mon Dec 10, 2012 12:00 pm
by zaidpirwani » Sun May 19, 2013 9:01 am
exstud wrote:So, the real question then is what would it take to build a PI with the same level of reliability as a PLC?


it is NOT as much about reliability as it is about getting this to work. At least it will be good for simulation/educational purposes if we get Beremiz working on Raspberry Pi and if there is some IO board interfaced with raspberry Pi which is controlled by the Beremiz software. (http://www.raspberrypi.org/phpBB3/viewtopic.php?f=41&t=4152&p=350515)

Again, not even close to real PLCs, nor in competition to them.
User avatar
Posts: 25
Joined: Sat Sep 22, 2012 6:18 am
Location: Karachi, Pakistan
by exstud » Sun May 19, 2013 1:59 pm
At least it will be good for simulation/educational purposes if we get Beremiz working on Raspberry Pi


If that is your ambition for this project, but imo it's just a matter of time before we see affordable powerful hardware like the PI that actually can compete with PLCs on all fronts, and waay beyond.

And when that happens why would one choose an outdated development environment (lad, stl,...) over more fully featured modern programming languages like c# or c++ with all their debugging capabilities? Then what will be the point of a lad simulator :?

I don't know about you but I'm looking forward to that day :)
Posts: 12
Joined: Mon Dec 10, 2012 12:00 pm
by zaidpirwani » Sun May 19, 2013 2:10 pm
exstud wrote:it's just a matter of time before we see affordable powerful hardware like the PI that actually can compete with PLCs on all fronts, and waay beyond.

And when that happens why would one choose an outdated development environment (lad, stl,...) over more fully featured modern programming languages like c# or c++ with all their debugging capabilities? Then what will be the point of a lad simulator :?

I don't know about you but I'm looking forward to that day :)


I too will be much happy when that day comes, I will probably be in actual industries by that time and have completed my studies so yes, I look forward to that day too, but for now, if I am to make a project, I have to limit the scope and get something done, just as a proof of concept, but I am stuck at couple of places as I am not much of a Linux guy... again, I too would love to have C# or C++ capable PLCs with all the debugging facilities etc..
User avatar
Posts: 25
Joined: Sat Sep 22, 2012 6:18 am
Location: Karachi, Pakistan
by jstokes5 » Sun May 19, 2013 2:48 pm
Hi. I teach industrial electronics at TAFE NSW, Australia. If you wst to talk about function and processing for a PLC or control programming, I'm your man.

Like you though, I'm not that familiar with Linux.

Your project sounds fun. Something like I might give my advanced diploma students.
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am
by abishur » Sun May 19, 2013 8:17 pm
exstud wrote:
At least it will be good for simulation/educational purposes if we get Beremiz working on Raspberry Pi


If that is your ambition for this project, but imo it's just a matter of time before we see affordable powerful hardware like the PI that actually can compete with PLCs on all fronts, and waay beyond.

And when that happens why would one choose an outdated development environment (lad, stl,...) over more fully featured modern programming languages like c# or c++ with all their debugging capabilities? Then what will be the point of a lad simulator :?

I don't know about you but I'm looking forward to that day :)


Actually, structured text is very much like a C language and I constantly have clients insisting that everything be written in Ladder because that's what their electricians turned PLC programmers can understand. And by insisting I mean it's put right in the specs that all programming will be done in ladder logic. Additionally, for whatever reason function that are available in one PLC format (I.E. Ladder) are not available in another (Function Block/Structured Text) depending on the programming environment (Unity/RSLogix/etc) such that there is occasionally a need to perform a specific function in a specific programming language.

So sadly Ladder simulators will be necessary for the far reaching foreseeable future. Especially when you take into consideration an aging equipment environment. It's pretty common to go to a job site and have to work on decade+ old technology. If Ladder logic is prevalent today in brand new top of the line equipment then the need to know ladder logic programming is going to be necessary for at least 2 more decades. Of course that 2 decade number continues outward until ladder logic ceases to be a staple in the PLC world which is why I personally think that ladder logic will stick around well past my retirement age almost 40 years from now.

As for powerful hardware that competes with PLCs at low prices... well there's an old addage that you get what you pay for. One could buy a "cheap" industrial PLC with lots of I/O for under $200 USD. But it would probably be a Wago, and those are so security ridden you might as well just put the computer controller on a street corner and let people have at it! There are better alternatives such as ScadaPack, but then you start paying more. So if we're talking about industry level equipment, no I don't think the Pi and things like it are going to start bringing the price of those down any more than PIC chips or the Arduino have affected the price of PLCs. :-)

All that said, I absolutely endorse the goals of this project!
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4298
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by jstokes5 » Mon May 20, 2013 12:25 am
Hi guys.

The new PLC programming standard requires that PLCs offer structured text, ladder, function block and Instruction list programming environments http://en.wikipedia.org/wiki/IEC_61131-3.

It makes a project like you propose interesting in that you can work together to provide a translator between those formats.

You are right. Electricians see ladder as an analogy of old 'relay control circuits'. Engineers and programmers prefer to write in structured text because they all learned C# at University. The CPU prefers Instruction list format (not that WE care) and Scientists and some people in Instrumentation would rather see a function block diagram because of National Instrument's Lab-View of the world. (Excuse the pun.)

I don't see why we couldn't them that translator. 8-)
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am
by jstokes5 » Mon May 20, 2013 12:31 am
Four forms of psuedo-code that in any case gets rendered down to whatever you want to use as your native language.

It means you could also write in the native script if you wanted but that the structured text, like the other formats could be simlified and could utilise pre-defined I/O addresses and counters and timers like PLCs do! The housekeeping for those would be a layer that the client never needs to worry about. That's the beauty of a PLC anyway. Isn't it?
Posts: 14
Joined: Wed Mar 27, 2013 2:30 am
by exstud » Mon May 20, 2013 12:18 pm
Actually, structured text is very much like a C language and I constantly have clients insisting that everything be written in Ladder because that's what their electricians turned PLC programmers can understand


It's actually more like assembler and has a very long way to go to catch up with OO languages like c# and debuggers as found in visual studio or eclipse.

I'd probably agree that many PLC programmers and even more electricians don't know or are unable to understand about the massive productivity gains they could adopt from the ICT world. So yeah it'll still be around for some time to come, and they will keep wasting 90% of their time copy-pasting and decrypting ladder logic. Luckily for those ignorance is bliss.

no I don't think the Pi and things like it are going to start bringing the price of those down any more than PIC chips or the Arduino have affected the price of PLCs


I sincerely hope you're wrong here and we'll have that PLC killer anytime soon.
Posts: 12
Joined: Mon Dec 10, 2012 12:00 pm
by abishur » Mon May 20, 2013 8:59 pm
exstud wrote:
no I don't think the Pi and things like it are going to start bringing the price of those down any more than PIC chips or the Arduino have affected the price of PLCs


I sincerely hope you're wrong here and we'll have that PLC killer anytime soon.


I kinda hope I'm wrong too ;-)
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4298
Joined: Thu Jul 28, 2011 4:10 am
Location: USA