You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old January 20th, 2020, 08:37 AM   #1
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Tech What language to choose for my brand PLC?

I am developing a PLC. The IDE for my PLC will be VS Code. I want my PLC to support IEC-61131-3 but only one language with is ST. Actually I already have a VS Code extension published for ST support. My PLC will be based on board like Raspberry PI but that will be Оrange PI.

Of course, I'll have to compile or better say analyze ST code and convert it to another language. Of course, if I would flash CPU and make my PLC based on Atmel chips for Arduino, I would have no other options but convert my ST code to C/C++ and then compile it to BIN file to download to CPU.

But my PLC is Linux based, I can use any language I want. So I am thinking would it be much simpler to convert ST program to Python for example or even Nodejs. Then I'll have no need for code compilation.

What do you think? Do you think Python will be good? What language would run with minimal resources and with industrial-grade stability?
  Reply With Quote
Old January 20th, 2020, 09:25 AM   #2
mk42
Lifetime Supporting Member
United States

mk42 is online now
 
Join Date: Jun 2013
Location: MI
Posts: 2,572
No offense, but I would say that if you're asking that question in here, you're probably in over your head.


As far as I know, you'd need to start with a realtime OS (not just basic linux), and then see what it allows from there.
  Reply With Quote
Old January 20th, 2020, 09:48 AM   #3
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 14,422
How about latching on to this project:
Open source PLC
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old January 20th, 2020, 10:11 AM   #4
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by mk42 View Post
As far as I know, you'd need to start with a realtime OS (not just basic linux), and then see what it allows from there.
Pardon me? Most of the contemporary PLCs like WAGO PFC200 for example and lot of others are based on Linux. I do not see any problem with that. I can SSH PLC, install mosquito there or other applications and then use them.

Quick Google search and I find this

“The PREEMPT_RT patch (aka the -rt patch or RT patch) makes Linux into a real-time system,” said Steven Rostedt, a Linux kernel developer at Red Hat and maintainer of the stable version of the real-time Linux kernel patch.
  Reply With Quote
Old January 20th, 2020, 10:12 AM   #5
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by Jonathancorbin View Post
I can use any language I want. So I am thinking would it be much simpler to convert ST program to Python .thanks
I am not quite sure what your comment means.
  Reply With Quote
Old January 20th, 2020, 10:23 AM   #6
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by JesperMP View Post
How about latching on to this project:
Open source PLC
I like the OpenPLC project. But unfortunately, their runtime is deeply bounded to IDE. And one of my main purposes is to be able to use any text-based IDE like VS Code, Atom, Eclipse, IntelliJ and others.

Also, I have some features that I cannot reveal now, that will not allow using OpenPLC. Besides their ST implementation is quite limited as they tend toward graphical languages like LD. I want to make not only full ST implementation but even implement ST-Ext. Those are extended language features that are not in the IEC-61131-3 standard.
  Reply With Quote
Old January 20th, 2020, 10:38 AM   #7
kk6mrp
Member
United States

kk6mrp is offline
 
Join Date: Oct 2016
Location: California
Posts: 23
If you want industry grade stability you are probably going to want to convert to binary and not convert your language into another one before it eventually gets compiled. That sounds inefficient and error prone if you ask me.

You are going to need experience in writing programming languages and in writing compilers before you can start this project.
  Reply With Quote
Old January 20th, 2020, 10:43 AM   #8
mk42
Lifetime Supporting Member
United States

mk42 is online now
 
Join Date: Jun 2013
Location: MI
Posts: 2,572
Quote:
Originally Posted by Serhioromano View Post
Pardon me? Most of the contemporary PLCs like WAGO PFC200 for example and lot of others are based on Linux. I do not see any problem with that. I can SSH PLC, install mosquito there or other applications and then use them.

Quick Google search and I find this

“The PREEMPT_RT patch (aka the -rt patch or RT patch) makes Linux into a real-time system,” said Steven Rostedt, a Linux kernel developer at Red Hat and maintainer of the stable version of the real-time Linux kernel patch.
I guess what I was trying to say is that this is a forum primarily for USERS of PLCs, not developers/designers. I'm not saying no one will be able to help you, but I think the number of users here knowledgeable in embedded system design and the performance trade offs between different PC languages would be pretty minimal.



If linux has a simple compile flag to make it hard real time that you plan to use, then I guess I retract my objection.
  Reply With Quote
Old January 20th, 2020, 10:59 AM   #9
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 14,422
Will the compiled ST code be able to load during runtime, and without initializing the memory used by the previously compiled ST code ?
If not, then will not be a real "PLC" in my view.

Historically, this was not always possible, but today it is a must-have.
__________________
Jesper
See my profile interests for Q&A
  Reply With Quote
Old January 20th, 2020, 02:46 PM   #10
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Germany
Posts: 1,167
Serhioromano, what a cool sounding project. You mentioned that you have some features you can't share yet.. Is this an open source project, masters thesis or do you have a private team?

Compiling ST into executable code is trivial, at least compared to the other tasks involved in making a PLC. If you have just the one hardware ambition in the Orange Pi (pi4?), you could choose to compile straight from ST to linux executable binaries for your architecture. Sure, Raspbian uses armel, but maybe you want arm64 for performance, and just use a different distribution. It sounds like you are going to be using a preempt patch anyway, so may as well go all in.

If you're not going to compile to binary yourself, you may as well pick your favourite programming language. I think your code will run fast enough in most languages, and designing the PLC features is going to be your tougher hurdle. As already mentioned, these features are a must these days: online changes, online monitoring, communications to IO, communications to visualisation, communications to business systems.

If it is opensource I will be interested in following the repository when you are ready to link it.
  Reply With Quote
Old January 20th, 2020, 02:56 PM   #11
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,215
This will be a long struggle. If you aren't familiar with compiler writing you may get frustrated.

I started an ST compiler a long time ago. I bought the full specification and used winflex and winbison to generate parse tree. My code generator only generated a pseudo assembly language. It got stalled because we switched CPUs so generating machine code would not work on all products. ST has many intrinsic functions, about 500. Most of these function are extremely simple like converting an INT to a DINT. You don't want to call a function for that but sign extending an INT does require emitting a machine code. I should generate Intel 386 code just for the heck of it and be done even though it wouldn't work on our motion controller.

My ST compiler will probably never get done before I retire which is too bad.

Python is not a solution because it is interpreted byte code and slow compared to machine code.

A lot of work is required to generate machine code. Most of the code is easy to generate but some jumps require relative offsets that must be patched ( ORed ) in after the first pass is done.

I would consider using Scintilla as the HMI because then the compiler can be integrated in with the editor. This makes things like high lighting syntax and spelling errors easier.

If you want to implement something quick then try Forth. There are lots of topics about that.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old January 21st, 2020, 03:46 AM   #12
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by mk42 View Post
I guess what I was trying to say is that this is a forum primarily for USERS of PLCs, not developers/designers. I'm not saying no one will be able to help you, but I think the number of users here knowledgeable in embedded system design and the performance trade offs between different PC languages would be pretty minimal.
If linux has a simple compile flag to make it hard real time that you plan to use, then I guess I retract my objection.
I see. But again, how hard it should be. And if you think about real time every OS is real time and just different hardness. Better readt this. еhis is opinion I stand on.

https://www.linuxfoundation.org/blog...ed-developers/

Also 90% of PLC tasks are not time-critical. I mean that critical time task is when it starts killing people if delivered not on time.

Quote:
Originally Posted by JesperMP View Post
Will the compiled ST code be able to load during runtime, and without initializing the memory used by the previously compiled ST code ?
If not, then will not be a real "PLC" in my view.
You are right, it will not be a real PLC. And I do not care much about loading during runtime. As I have mentioned 90% of PLC tasks do not care about this feature. So I leave those features to PLC developers and I create PLC for tsks that are not critical to hot reloads.

Quote:
Originally Posted by AustralIan View Post
Serhioromano, what a cool sounding project. You mentioned that you have some features you can't share yet.. Is this an open source project, masters thesis or do you have a private team?

Compiling ST into executable code is trivial, at least compared to the other tasks involved in making a PLC. If you have just the one hardware ambition in the Orange Pi (pi4?), you could choose to compile straight from ST to linux executable binaries for your architecture. Sure, Raspbian uses armel, but maybe you want arm64 for performance, and just use a different distribution. It sounds like you are going to be using a preempt patch anyway, so may as well go all in.

If you're not going to compile to binary yourself, you may as well pick your favourite programming language. I think your code will run fast enough in most languages, and designing the PLC features is going to be your tougher hurdle. As already mentioned, these features are a must these days: online changes, online monitoring, communications to IO, communications to visualisation, communications to business systems.

If it is opensource I will be interested in following the repository when you are ready to link it.
That is why I want to convert to Phyton or something like this. I'll make it CPU(hardware) agnostic. It there is a Linux, it should work. I do not plan that PLC will have onboard I\O just CPU and all I\O will be connected. This means that I do not need even PLC configuration, you can write a program and upload to any PLC (I plan to produce or theoretically any Linux plc with Modbus TCP\RTU interfaces) because I\O will be connected through ST code, not through configuration, it means it will be universal.

Right now I have only one open repo. This is an extension for VS Code that allows code with ST. It is not yet fully featured just the start, but it is the most complete, most downloaded ST Extension for VS Code to date.

https://github.com/Serhioromano/vscode-st

So, my IDE will be public repos. And converter too, but I have not started it yet, as you can see I try to grasp clear picture where to go.

You can follow me on GitHub and you will be notified when I create a new repo.

Quote:
Originally Posted by Peter Nachtwey View Post
This will be a long struggle. If you aren't familiar with compiler writing you may get frustrated.

I started an ST compiler a long time ago. I bought the full specification and used winflex and winbison to generate parse tree. My code generator only generated a pseudo assembly language. It got stalled because we switched CPUs so generating machine code would not work on all products. ST has many intrinsic functions, about 500. Most of these function are extremely simple like converting an INT to a DINT. You don't want to call a function for that but sign extending an INT does require emitting a machine code. I should generate Intel 386 code just for the heck of it and be done even though it wouldn't work on our motion controller.

My ST compiler will probably never get done before I retire which is too bad.

Python is not a solution because it is interpreted byte code and slow compared to machine code.

A lot of work is required to generate machine code. Most of the code is easy to generate but some jumps require relative offsets that must be patched ( ORed ) in after the first pass is done.

I would consider using Scintilla as the HMI because then the compiler can be integrated in with the editor. This makes things like high lighting syntax and spelling errors easier.

If you want to implement something quick then try Forth. There are lots of topics about that.
I perfectly understand. Fortunately, I know ST pretty much well. My 320 pages book to learn ST, right now in the publishing process. еhat is why I want to convert it to something like Phyton. Then Phyton will make all errors of compilation and I do not need to do that. Slower? Yes but my PLC will run on big CPU machines like XEON, i7 and such. So I can sacrifice little bit of performance.
  Reply With Quote
Old January 21st, 2020, 04:29 AM   #13
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,392
Quote:
Originally Posted by Serhioromano View Post
Tabs? Oh dear.
  Reply With Quote
Old January 21st, 2020, 06:53 AM   #14
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by drbitboy View Post
Tabs? Oh, dear.
What tabs? Oh, dear means excited or disappointed?
  Reply With Quote
Old January 21st, 2020, 06:59 AM   #15
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Germany
Posts: 1,167
Tabs: drbitboy is a PC programmer, who is team spaces. I suspect you use tabs to indent your code somewhere, rather than spaces.


This WILL be the last post about tabs vs spaces in this thread.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Change language in HMI in CCW project ThomasSmith LIVE PLC Questions And Answers 1 November 6th, 2016 02:49 AM
Selectable language Switching Mr.Adam LIVE PLC Questions And Answers 3 March 31st, 2015 03:57 PM
Reading selected language on PanelView by CompactLogix PLC amberman LIVE PLC Questions And Answers 2 December 4th, 2014 09:31 AM
Language Work The Plc Kid LIVE PLC Questions And Answers 5 July 4th, 2012 12:35 PM
Intouch 9.5 Runtime Language Switch Questions andrzejplo LIVE PLC Questions And Answers 2 March 31st, 2006 03:18 AM


All times are GMT -4. The time now is 02:01 PM.


.