Reply – Re: C# Application of OpenPLCProject
Your Name
or Cancel
In Reply To
Re: C# Application of OpenPLCProject
— by thiagoralves thiagoralves
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 the downloads section, the OpenPLC Ladder Editor source link points to my github page.