Go Down

Topic: Open source PLC based on Arduino (Read 7812 times) previous topic - next topic

I'm an arduino fan for many years. It's really an excellent project that changed the way people look to electronics. But, anyway, I will not waste my words saying something everyone here already know. Arduino rocks!   XD

Some years ago, I worked on a facility and had my first contact with these peculiar controller called "PLC". PLCs are robust digital controllers made for the industrial environment. They can be programmed using a graphical language called Ladder (it is very similar to electric diagrams) and is used in most industries all around the world. The big problem is that there is no open source PLC to date (at least none that would be compatible and do the same thing an actual PLC does), and PLCs are extremely expensive!  :~
So, in 2012 I started building my own open source PLC. I created a google code page to share my research and made a few friends along the way. It was all based on arduino. Actually, my first version was just an arduino with some shields that I developed myself, to offer some protection to inputs and outputs. The project now has grown into a complex system with 4 boards, but is still based on the Arduino platform. I call it OpenPLC. Every board has an ATMega microcontroller and runs the arduino boot loader. The CPU is an ATMega2560, with USB , ethernet and RS-485 communication. The slave boards runs on 328P's and have 485 communication with the CPU.
If you want to know more about the project, check this website: http://www.openplcproject.com. If you want to collaborate, give suggestions, or say anything related to the project, please reply to this post, PM-me or email me.


I hope you enjoy it!

Thiago Alves

PeteOC

What protocol are you using for communications to SCADA etc?
Follow my projects - http://www.begerk.co.uk

The OpenPLC uses its own protocol (called OPLC Protocol) over 485 to communicate with expansion cards. To communicate with other systems (SCADA) it uses MODBUS over TCP/IP. I tested it using some free SCADA software that support MODBUS TCP and it worked fine!  :D
Not all MODBUS functions were implemented, but the most important ones are (like read coils, write registers, write coils, read inputs).

I'm planning to create a another version of the OpenPLC. It will be called OpenPLC Mini. The idea is to create an arduino shield combining features of the input card and output card in only one board, that would attach to an arduino UNO or Mega. It also needs to be compatible with all software developed for the OpenPLC. It means that it will behave exactly as the original OpenPLC, but without ethernet and expansion capability. I believe that a small board will decrease costs and help the platform to spread better. I believe that a simple single board like this can be sold for about $50,00. It means that with about $50 you can transform your standard arduino into a robust PLC compatible with Ladder diagrams. What do you guys think about it?

In preparation for the OpenPLC Mini, I developed a beta version of the OpenPLC Ladder Editor that can generate code for a standard arduino from a ladder diagram. Its fully compatible with standard OpenPLC and is available for download now!

If you want to try it out on your own arduino, read my blog post about it and download it from the link posted there
http://www.openplcproject.com/#!OpenPLC-is-having-a-new-brother-the-OpenPLC-Mini/c1r22/64E8D308-1B83-41CA-B5F6-68B20E6CF47A

Since I dont't have all types of arduinos, I need people helping me testing the code on their own hardware. It has been reported to work on arduino UNO and Mega, but I want to know if it works on Mega 1280, Duemilanove, and its variants.

I found your website last week, and I've been VERY excited ever since.  I debug Siemens PLC/CNC systems for an automation company, and have wanted to venture into arduino programming for a long time, but the textual programming immediately turns me off every time I look at a sketch.  If this is an affordable, real PLC, I would be eager to buy the hardware/software package from you.

Will it have any of my favorite Siemens features, such as:
online viewing, where I can see which bits in a rung are high and low in real time?
Online editing?
Function blocks?
Function calls?
Structured data blocks?
Search tools that check all functions for an address?

It will have all functionality you mentioned, plus zero cost!  ;) I'm planning to integrate the OpenPLC hardware with Beremiz, a complete open source IDE for automation. Beremiz is a very interesting project.

But right now, the OpenPLC can only do the basics: digital input and output and ladder diagram (with all standard blocks)

mart256

#7
Jul 27, 2014, 08:31 pm Last Edit: Jul 27, 2014, 08:35 pm by mart256 Reason: 1
This is an amazing project. Congratz. It would be cool if you can match the industry requirement for this device to survive on the industry enviroment.

championswimmer

#8
Sep 13, 2014, 03:38 pm Last Edit: Sep 13, 2014, 04:40 pm by championswimmer Reason: 1
I am a software guy, and have some LADDER experience. First thing I did was rush to see if your source is on Github and if I can help in building the IDE.

Saddened to see two things

1. Source not on github (Why?)
2. Windows-only targetted audience. (again why? If it's an open source project, you'll get huge support from the Linux crowd)

Instead of the C# based project, we could fork Processing, and create the Ladder Editor from that.

Arduino and Fritzing are exammples of Processing's versatility. From PCB graphic design to Atmega binary compiling and uploading, a lot can be done. I am sure handling Ladder wouldn't be hard.

Also I would love to contribute to this project (mainly from the perspective of developing Arduino <--> OpenPLC interfacing libraries, and on the IDE (Ladder Editor). So where do I start with that ? :)

MarkT

It sounds to me that someone needs to write a better version of the configuration
utility using open tools, then the c# one can be left to die.
[ I won't respond to messages, use the forum please ]

@championswimmer
As an electrical engineer, my knowledge about high level Windows / Linux programming is limited. I'm much stronger with low level programming and hardware design. For this reason, the ladder editor for the OpenPLC is based on LDmicro, a simple Ladder editor/compiler. Since LDmicro is windows-only, the OpenPLC Ladder Editor has to be windows-only too. I wanted to support linux, but since I was running out of time for my graduation, and I had LDmicro working perfectly, my option was just to modify it to make it work with the OpenPLC hardware.

Currently, I use LDmicro simply as a Ladder -> ANSI C compiler. Once the ANSI C code is generated from the ladder diagram, I call the AVR GCC to compile the OpenPLC firmware with the LDmicro generated code included as a header file. It means that the ladder instructions are compiled to machine code with the firmware every time you upload a new ladder program. I found this process to be easier to build and faster to run on an 8-bit hardware.

Some people suggested me to change this process to interpreted instructions, for instance, the ladder editor generates a XML file with the ladder instructions, then it is uploaded to OpenPLC's flash and interpreted at runtime, just like any other standard PLC. But this approach requires a complete change in the OpenPLC's hardware. The actual 8-bit architecture can't achieve that at a reasonable speed.

So I'm going for the Ladder -> ANSI C idea until I create a faster version of the OpenPLC. If you are willing to help, I need your knowledge to build a brand new ladder -> ANSI C compiler, like LDmicro, but, as you suggested, based on processing and multiplatform. I'm open to suggestions, but I think that this will be the easiest approach, at least to start with. If you manage to build that, the integration with the OpenPLC hardware will be seamless.

About the source code, actually it is available at github. If you go to my website (www.openplcproject.com), at the downloads section, the OpenPLC Ladder Editor source link points to my github page: https://github.com/thiagoralves/OpenPLC-Ladder-Editor

@MarkT
You are right. I believe that if we manage to create a new version of the Ladder Editor, the configuration utility must be rewritten and integrated to the Editor, so that both may become a single software for the OpenPLC hardware.

@thiagoralves

I suggest you dump the forum on your web site (nabble) for a better one like SMF (used in this site) and attract all the discussion to openplcproject.com

Add small news at least a month. Make sure your links work (links at the bottom of pages do not work)

Move wiki info from google code to openplcproject.com

Make it look like it is alive. From where I am it looks death.

Regards.

cartiman

I have written ​​an article about Build PLC using Arduino , please visit the link http://program-plc.blogspot.com/2015/01/build-simple-plc-using-arduino.html

Thanks
Cartiman

can someone tell me what's the difference of PLC and arduino uno and what we most add to arduino to be like the plc !!!

cr0sh

can someone tell me what's the difference of PLC and arduino uno and what we most add to arduino to be like the plc !!!
Mainly, it's safety and liability.

An industrial PLC is designed to be as inherently safe as possible - meaning that it's outputs will be in a properly defined state when it is switched on or off, that it won't randomly set output pins due to environmental conditions, that it has means of rejecting noise, and a whole host of other specifications.

If something does go wrong, there is generally a company behind the product which can assume liability, especially in cases of a major industrial accident involving such controls. To that end, an insurance company for such an industrial concern will likely want such assurances about the industrial controls; the Arduino (as-is) has none of this.

You also have the hardware side of things - most industrial controls output and expect 12-24 volts DC - not 5 volt TTL levels (but it runs the gamut); a PLC is designed to talk to such devices, while not being destroyed by noise and transient voltages (back EMF and the like). Furthermore, PLCs in general are designed as "real time" systems, whereas the Arduino isn't such a device (it is probably possible, though, to code the ATMega328 for real-time usage, but not likely using the Arduino libraries). I'm sure there are plenty of other "hardware" differences that I am not mentioning.

Programming for PLCs is generally done in a form of "ladder logic" - though from what I understand, C/C++ and other languages are becoming more common. However, understanding ladder logic, how it works (both as a program/state machine - and as real hardware) - are both paramount to using another language for industrial control - whether its a PLC or an Arduino.

Could an Arduino be used in place of a PLC? Sure - there are ways to do it. But ultimately, you won't likely be able to simply drop-in a cheap Arduino for a PLC, even with the needed modifications and support. This is because of the liability concerns and the business insurance requirements. The only way that it would be possible in that case would be to use an approved and vetted Arduino-based PLC replacement hardware and software system. AFAIK, nothing like that exists, though there have been attempts to create such things (in most cases, I think the hardware and software became available - but the needed validation and approval for insurance concerns is the expensive part, which no one has done).

If you don't need a PLC for an actual business or industrial purpose, then an Arduino would probably work fine for your purposes.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy