vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Sat Aug 20, 2011 5:39 pm

Hello everybody,
After a lot of consideration and a push from Lob0426, I decided to start this new thread. This is a project about programming Pi to act as a PLC or a x-axis positioning controller.
So far these controllers are mostly proprietary and in a no way software is open source. So every company makes money because from the moment you attached to them you married them for life.
from the finished product many will benefit:
- Engineers in automation industry
- Hobbyists building home automation, burglar alarms, etc
- Students having hands on automation in a truly open controller.
- many ideas to come if you stay with us
First thinks first. Pi P.L.C must have at least these 4 goals:
1 - Be capable of running Programming language defined by the IEC-61131-3 standard.
2 - be able to communicate real time via Ethernet port to other remote Pi PLCs in a master/slave scenario.
3 - Be able to attach many I/O locally (reed relay, FET transistor out, triac, encoder input) . One idea to use cheep interface boards connected to I2C bus. The encoder input is necessary for positioning system and robotics.
4 - The system must run on a version of real time lynux if we want to capture events on a millisecond or less. Of course a Debian distro is OK if you do not want to be real time.
I have already some ideas because three are people already made a lot and very good open software like http://www.beremiz.org project (since 2009 I can see no movement to their site but we will try to contact with the developers).
For that we will need some people to write some drivers and to port the application into a real time Linux. It is a lot of work but the final result will give us a lot of satisfaction.
More to come..

Svartalf
Posts: 596
Joined: Fri Jul 29, 2011 6:50 pm

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

Wed Aug 24, 2011 11:07 pm

Heh... The distribution won't be real-time...the Kernel, however, may be a different story. You can have "real-time" Red Hat or Debian (or a twisted, mutant mash-up of both...that's what Montavista's Carrier Grade Linux is... ;) ). Stock will be near real-time enough probably for most situations with the low-latency stuff turned on- but the additional patches will push it into a deterministic area with the hardware we have.

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Thu Aug 25, 2011 10:26 pm

Yes it could be nice for some non critical application. Even "real-time" Debian will do it. A home automation system for instance can run soft PLC version.
For critical machine controller you may not need an operating system at all. The development tool In case of CODESYS (www.3s-software.com/) will produce a C code of you PLC application and directly run it by the ARM CPU. Pure native machine code at the end that has only your application. Like you written in assembler. Similar is http://www.beremiz.org but the development tool runs on linux and windows, it is open source and it is free. This may need some development ut it is there and it is working. They even have an HMI creation tool. As far as I know there is a commercial company that uses it in one of their PLC controller.

Svartalf
Posts: 596
Joined: Fri Jul 29, 2011 6:50 pm

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

Thu Aug 25, 2011 10:48 pm

Biggest problem with that thinking is that the stuff's not easily or readily protected from attack. Seriously.

Secured DNP3 isn't really secured and the only things I've seen come close are pricey and only secure point to point serial links. More to the point, you honestly don't need "real time"- only worst-case deterministic behavior. A real-time OS won't do any better for you and is only a comfort thing to the "old-school" developers when you can't define what the deterministic behavior is supposed to be and what your worst-case timings are supposed to be. Seriously.

This is not to say you're not barking up the right tree for part of this, but I think this project's a bit bigger than just what you're talking to- which is a good thing, really. ;)

tomm
Posts: 1
Joined: Mon Aug 29, 2011 7:31 pm

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

Mon Aug 29, 2011 8:45 pm

Hi All
This is something I have been working on for a while now. I am a hardware design engineer and would love to design some IO boards for the Raspberry PI. Where can I find detailed boards dimension and gpio specs?

Svartalf
Posts: 596
Joined: Fri Jul 29, 2011 6:50 pm

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

Mon Aug 29, 2011 8:49 pm

Quote from tomm on August 29, 2011, 21:45
Hi All
This is something I have been working on for a while now. I am a hardware design engineer and would love to design some IO boards for the Raspberry PI. Where can I find detailed boards dimension and gpio specs?

We probably won't have them until just shy of when they start shipping the first generation of devices...

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Tue Aug 30, 2011 7:25 am

Yes this is true about the boards. We may try to tell some ideas to the designing team since this will help a lot not only to PLC project but in general technical students, hobbyists and why not some processional engineers.
Having in mind what other PLC manufactures are doing, they have a serial high speed buss (probably I2C) and the use it to connect many I/O locally (digital & analog in/out, encoder input etc).
A speed problem may arise when we need in special cases very fast analog conversion (but I think within the limits of these serial buses at 1MHZ we can succeed pretty good conversion and I/O polling times. Most PLC firms are within these limits. One exception is German firm Bechkoff (Running CODESYS) with the real time Ethernet (EtherCAT) they have and they can achieve extremely high speed conversions about 3 microseconds!!
I thing the I/O interface boards they are planning to design will be pretty cool. With these boards a whole new embedded world will open. So this try will cover my 3rd goal from my list.
I already have a communication with beremiz team, they found the project interesting and I hope to join us to start the PLC project from the point they are now. That will be very good for everybody. When finished it will be the first PLC having all this power in a controller it will be open and very cheap to build.
Thanks for your participation in the RAS-Pi PLC project. That gives me hope that building a powerful, open and cheep PLC is not a dream. PLC community is very "close" one at the moment but we will bring PLC to the masses! (technical students, electricians, hobbyists etc) . It is not as easy as computers but the interest will be huge at the end. Embedded controllers will be everywhere. So let make it happened.
This is an open invitation to anyone can contribute to the RAS-Pi PLC project. We must prepare a lot of thinks before boards go out. I have plans for the Greek technical education too. The same will apply to every country.

Lakes
Posts: 267
Joined: Wed Aug 24, 2011 2:17 pm

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

Tue Aug 30, 2011 6:30 pm

A Raspi as a kind of Super Ardunio?

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Tue Aug 30, 2011 7:37 pm

well... let's go with yes ;) The idea with the Ardunio is to take a microchip and put it on a board with some basic communication capabilities (ethernet, usb, serial, etc) and then use the microchip to control whatever you want. Meanwhile you have the r-pi which is a computer with your standard communications but 16 GPIOs to boot! Possessing more RAM and a true OS, gives the r-pi a distinctive bonus. That said, the flip side is the r-pi is somewhat more costly in the long run. Still if you don't want to have to fool around with building your own boards and you're going to spend the cash to buy either an Ardunio or an R-pi, then there's some useful reasons to choose an r-pi (assuming of course the GPIOs stick around)
Dear forum: Play nice ;-)

User avatar
Lob0426
Posts: 2198
Joined: Fri Aug 05, 2011 4:30 pm
Location: Susanville CA.
Contact: Website

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

Tue Aug 30, 2011 8:48 pm

Every post where there has been a mention of the GPIO's has stated that there will be GPIOS on 1.27mm pin headers. We just don't know what in total they will contain yet. I think the only headers that are going away are the ones on either side of the HDMI connector on the Alpha board.
512MB version 2.0 as WordPress Server
Motorola Lapdock with Pi2B
Modded Rev 1.0 with pin headers at USB

http://rich1.dyndns.tv/
(RS)Allied ships old stock to reward its Customers for long wait!

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

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

Tue Aug 30, 2011 9:00 pm

That is very true, but until I see a finalized board, I'm not holding my breath on too much of anything being set in stone (side note, I really hope they keep those pins somehow as they allow connectivity to some pretty cool things) ;)
Dear forum: Play nice ;-)

User avatar
Lob0426
Posts: 2198
Joined: Fri Aug 05, 2011 4:30 pm
Location: Susanville CA.
Contact: Website

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

Tue Aug 30, 2011 9:15 pm

The serial port pads hopefully stay there too! I got plans for those.
512MB version 2.0 as WordPress Server
Motorola Lapdock with Pi2B
Modded Rev 1.0 with pin headers at USB

http://rich1.dyndns.tv/
(RS)Allied ships old stock to reward its Customers for long wait!

crackerjap
Posts: 1
Joined: Tue Aug 30, 2011 6:12 pm

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

Tue Aug 30, 2011 9:36 pm

hmmm some new from of automation that is so small would go perfect for my brew machine... already have one with a plc, but would rather have a self contained controller that is easy to reprogram on the fly and is cheap... can't wait to see the final release

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Wed Aug 31, 2011 5:03 am

It looks that if there is no provision on the board to have access in I/O that will be the end of any idea of making that particular board a controller. The board must be capable of having all I/O or at least including serial ports into a header nicely putted on board in a way tha a piggy board (like Arduino shields) or in any other way to be able Raspberry foundation or other third parties to build interface boards digital or analog (Our world is analog do not forget). If they do not come with that kind of solution, it will be no way to control thinks with this beautiful board.
Ok you can use Ethernet or USB to connect I/O expansion boards with some libraries written in C++ but...
And yes Arduino strong point is that you can control nearly everything on the outside world in away that is really fun. Not to mention the Chipkit board where Microchip did a 4 times powerful Arduino compatible board putting a PIC32 processor and Ethernet as well. Very cool for controlling thinks.
On the other hand still R-Pi project has a powerful CPU, everything to make a full scale computer to run the graphics Human Machine Interface that everyone will love to use in the PLC world.
So gentlemen we have to ask the design team if the have plans to make this little board to interface with the real world. There is a huge demand for that kind of applications out there
But having in mind that R-Pi first orientation is hobbyist and technical education I can not see how they will succeed on that without a professional EXPANSION to the real world.

Blars
Posts: 88
Joined: Sun Aug 28, 2011 3:22 am
Contact: Website

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

Wed Aug 31, 2011 6:25 am

They have said elsewhere that there will be about 16 GPIO, two I2C, I2S, and SPI on headers. Exactly what and the pinouts have not yet been decieded, it will wait for the final board layout. There is a seral port on 4 solder pads in the alpha, I hope it goes on a header instead.

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Wed Aug 31, 2011 8:59 am

If they really exists must be in a place where easylly with a flat cable or any otherway easy way (acting as a bus) to interface with other I/O boards. With I2C it can connected to a bus topology with other local or remore I2C I/O boards-modules *that is why I2C may be it is better to have a separate conector). A piggy back interface board may be is a cheep altarnative in making extreamly cheap controllers like the watering or some kitchen controllers. But this is a discution in onother section. Of cource the designers I think they must take notice of our concerns here for convering it into a controller and help us with the design.
Next time I will try to be more specific about What we need from the software part of view, to make it a powerful PLC.
For that we will need people with C++ knoledge becouse we may need to do some portning with drivers and so.
I have in mind PLCOPEN model of doing bussiness. It is FREE, it is OPEN it is ALIVE and as far as concern it is EUROPEAN movement (?)

Svartalf
Posts: 596
Joined: Fri Jul 29, 2011 6:50 pm

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

Wed Aug 31, 2011 1:07 pm

Quote from vorrias on August 31, 2011, 09:59
I have in mind PLCOPEN model of doing bussiness. It is FREE, it is OPEN it is ALIVE and as far as concern it is EUROPEAN movement (?)

It's not just a European movement... ;)

diggy
Posts: 20
Joined: Fri Aug 19, 2011 9:52 pm
Contact: Website

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

Fri Sep 02, 2011 12:04 am

Count me in for that.
I am in the food business (I have a small food industry) and more than 90% of the machines in the production line are custom made by my designs (and my father's help). Currently the only machine that uses a PLC is the blast freezer (A € 3000 SIEMENS S7 combo) and the other are on a whole bunch of relays, knobs, buttons and switches controling motor, latches, etc.

It would be a dream to put them all on a Rpi PLC that I can control maybe even from my office.
I have a whole bunch of similar ideas if I get this one thru.

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Mon Sep 05, 2011 6:43 am

Good news diggy. So we have another with a real factory floor that needs a solution.
My job of living is programing Hitachi PLC. I do not recommend it not even to my enemy.
SIEMENS is another story but still is a company with many proprietary software and hardware.
You are Greek as I can see. My skype is service.galanos.com.gr. To talk some time
Stick with us and try to contribute with any way you thing to that. As I said PLCOPEN is our solution and porting that to RAS-Pi with some realistic ways. I collecting all the necessary material as a white paper ("What must be done to convert RAS-PI into a PLC") about the project. I will be glad if other people help to make this white paper a tool to start and finish the project. In the process we may need real experts in C++ programing, people that are capable of writing some drivers for the RAS-Pi. At this moment we must ask the designers what are the exact plans for the interface boards . Without a clear answer to that it is impossible to talk for RAS-PLC project.

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Mon Sep 05, 2011 6:48 am

@Svartalf sorry about saying that PLCOPEN being a European project (That was the reason for the ?). It is good to know that it is international. That make things even better.

diggy
Posts: 20
Joined: Fri Aug 19, 2011 9:52 pm
Contact: Website

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

Mon Sep 05, 2011 1:09 pm

As I see it, IF Rpi final board makes it with all the IO as the alpha board (GPIO pins, SPI, I2C, I2S etc) we are going to have a pretty nifty device to work with.

For starters we should clear things out. Regarding the software, we need:
A PLC "studio" with a programming language to produce valid IEC-61131-3 code
A PLC runtime enviroment to run the plc code produced
An HMI to control the PLC
Drivers to control the IO pins/buses
Most likely three out of four of the above could be done in Rpi.
Best case scenario we would assemble a light-weight linux distro that has both a development enviroment to code, a runtime library to run the PLC code and an HM interface to control the PLC using the drivers for IO.

If having all that running at the same time is not possible, we could have a dual boot SD card: One distro containing the dev enviroment ONLY for programming and producing the code and Another to run the PLC code and the HMI.
Of course there could be a way to replace PLC code on a live PLC (in stop mode) via ethernet.
All in all we should really take a look for a kernel with realtime extentions.

Any news about beremiz?

charly130.mk2
Posts: 10
Joined: Tue Sep 06, 2011 7:05 am

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

Tue Sep 06, 2011 8:14 am

Additionally, since it has a USB port, it could be used in conjunction with a UBW (http://www.schmalzhaus.com/UBW), which is controlled like a serial device. This also means that for those of you with interesting ideas, you can start developing the control logic for your ideas before the final boards are out. Additionally, you are providing a 'buffer' between your control hardware (relays etc) and the brains of your system. Admittedly it does add slightly to the cost of creating a solution, but you can make one of those for less than 10 euros (or buy one).

vorrias
Posts: 65
Joined: Mon Aug 15, 2011 3:31 pm
Location: Greece
Contact: Skype

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

Wed Sep 07, 2011 8:21 am

Yes @diggy your state is very good1 - A PLC "studio" with a programming language to produce valid IEC-61131-3 code
2 - A PLC runtime environment to run the PLC code produced
3 - An HMI to control the PLC
4 - Drivers to control the IO pins/buses
#1, #3, covered by beremiz project
For #2 I am not sure I asked Edouard from beremiz.org and waiting an answer.
#4 is some drivers we have to write after the project is finalized. Meanwile I found extremely interested the idea charly130.-mk2 put on the table (http://www.schmalzhaus.com/UBW). We can see this one to begin with.
No more news from beremiz. I hope Edouard will help us to finalize and run beremiz into R-Pi.
Meanwhile I encourage everyone interested to run beremiz. There is a new version stated June 2011 (Linux version too!). This means the project is alive!
I had the previews version run a year ago but I did not make any deep reading because that was a beta version and waiting for the final one witch is this June 2011 version.
Please keep in touch to finalize all the details. I tried to persuade Edouard to help us but he is very busy at the moment with his automation company but I will keep trying. At the end his company will benefit from the project because every student having R-Pi can put hands on it. What a publicity!...Because this guy and some others worked very hard for this fantastic project based in OPENPLC (www.openplc.org) standards. CODESYS environment is based in OPENPLC standards as well.

diggy
Posts: 20
Joined: Fri Aug 19, 2011 9:52 pm
Contact: Website

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

Wed Sep 07, 2011 8:49 am

@Vorrias
For drivers I believe that right after Rpi launches, there will be drivers available for all the IO from some of the guys interested in other projects that have C skills. We could just reuse them.

UBW seems nice but from the site I don't see linux driver support to talk to the IO. Furthermore going through the USB hub would add latency that could kill all Mission critical tasks that require a faster bus (servo control etc). Let's not forget that all IO pins that Rpi is going to have will be coming out right from the ARM processor (if I'm not mistaken). Also using UBW would require another firmware to load to UBW.
I believe our best shot (to begin with) is to have a driver for the I2C bus.

Furthermore, if we manage to pull all this together we might not be talking of just a Rpi PLC but more like a Rpi PAC with SCADA, which in a networked architecture would kick some serious butt!!!
Just think of a Rpi (used as an HMI) and several other networked (as PLCs or RTUs) to control a whole production plant! (this is where a master/slave connection between Rpis would come in handy)

I maybe over my head with this one, but just try to picture it.

charly130.mk2
Posts: 10
Joined: Tue Sep 06, 2011 7:05 am

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

Wed Sep 07, 2011 10:02 am

@diggy

UBW doesn't need drivers for linux, as linux automatically sees it as a USB->Serial port. So all you need to do is open a term emulator, point it to the port, and start giving it commands. However, you are quite right that for mission critical applications this MAY be slow. As for the firmware, all you need is a PIC programmer to load the bootloader (from the site) and the main firmware (which can be downloaded through the bootloader). This is as much as I can tell you so far, as I am in the process of building mine (haven't finished yet)...

Return to “Other projects”