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.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


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

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 21st, 2020, 10:09 AM   #16
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,060
Quote:
Originally Posted by Serhioromano View Post
I perfectly understand. Fortunately, I know ST pretty much well.
My 320 pages book to learn ST, right now in the publishing process.
There is a lot of difference between knowing ST and writing a lexer, parser and code generator.

Quote:
е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.
Do you know how python handles bits, BYTEs, WORDs, structures, unions etc? I suggest you look up structures and unions for python.

Are you going to embed python?

If you are going to generate byte code I would chose something more flexible like generating byte codes for Mono. The Mono part is already done. Actually, that is a good idea for me.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old January 21st, 2020, 11:00 AM   #17
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by Peter Nachtwey View Post
There is a lot of difference between knowing ST and writing a lexer, parser and code generator.
I know, but at least I know ST right? In any case, it is one problem less

Quote:
Originally Posted by Peter Nachtwey View Post
Do you know how python handles bits, BYTEs, WORDs, structures, unions, etc? I suggest you look up structures and unions for python.

Are you going to embed python?

If you are going to generate byte code I would choose something more flexible like generating byte codes for Mono. The Mono part is already done. Actually, that is a good idea for me.
It is not necessary to follow types. I can convert all `ANY_NUM`, `ANY_INT` and `ANY_REAL` types into a single integer in Python. Since I do not create machine code I do not work with bits so I do not care actually. It is not necessary to access exact memory locations by address.

Look ST is only an expression of what developer what CPU to do. It does not matter if bytes really in the exact order in the memory. If the user uses %MW0 and then %MW1 for user those are byte after byte, but in reality, I can simulate this but store it with automatic location when declare var in Python but in fact, return correct result when developer access %MD0.

And also I will not embed anything. My PLC will run on Linux actually it is a PC. I think that I could create programs for PLC on Python from start, but I want everyone who knows IEC 61131-3 could utilize it quickly.

And it is not Зернещт but maybe another language. I am looking into Mono. 10 minutes did not give me anything. I'll study it later today and see what it is.
  Reply With Quote
Old January 21st, 2020, 12:06 PM   #18
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Germany
Posts: 1,122
mono project is the open source implementation of (so far only parts of) Microsoft dotnet Framework.
  Reply With Quote
Old January 21st, 2020, 12:12 PM   #19
bjh
Member
United States

bjh is offline
 
Join Date: Jul 2010
Location: Madison, WI
Posts: 253
Quote:
Originally Posted by Serhioromano View Post
Look ST is only an expression of what developer what CPU to do. It does not matter if bytes really in the exact order in the memory. If the user uses %MW0 and then %MW1 for user those are byte after byte, but in reality, I can simulate this but store it with automatic location when declare var in Python but in fact, return correct result when developer access %MD0.

Are you looking to make a transpiler? Something that takes source code in ST and converts it to usable Python?
  Reply With Quote
Old January 22nd, 2020, 12:15 AM   #20
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Germany
Posts: 1,122
Hmmm, one reason not to use python is perhaps
https://github.com/thiagoralves/OpenPLC_Editor/issues/9

Differences between python 2 and 3 include:
"In Python 3, 5 / 2 == 2.5 and not 2; all division between int values result in a float."

What changes will they then make in python 4?

I guess it is hardly a problem, you just need a good test script... But if that too is written in python...
  Reply With Quote
Old January 22nd, 2020, 03:05 AM   #21
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by bjh View Post
Are you looking to make a transpiler? Something that takes source code in ST and converts it to usable Python?
Exactly. That is the term. I am investigating if this could be a solution.
  Reply With Quote
Old January 22nd, 2020, 03:06 AM   #22
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Quote:
Originally Posted by AustralIan View Post
Hmmm, one reason not to use python is perhaps
https://github.com/thiagoralves/OpenPLC_Editor/issues/9

Differences between python 2 and 3 include:
"In Python 3, 5 / 2 == 2.5 and not 2; all division between int values result in a float."

What changes will they then make in python 4?

I guess it is hardly a problem, you just need a good test script... But if that too is written in python...
I'll have total control over Python versions installed if I choose it. That does not concern be a bit.
  Reply With Quote
Old January 22nd, 2020, 05:12 AM   #23
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 356
Quote:
Originally Posted by AustralIan View Post
Hmmm, one reason not to use python is perhaps
https://github.com/thiagoralves/OpenPLC_Editor/issues/9

Differences between python 2 and 3 include:
"In Python 3, 5 / 2 == 2.5 and not 2; all division between int values result in a float.". ...
Code:
$ echo "python -c 'import sys;print((sys.version,5//2,))'" | ssh ...

('3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) \n[GCC 7.3.0]', 2)


$ echo "python -c 'import sys;print((sys.version,5//2,))'" | bash

('2.7.16 (default, Mar 20 2019, 12:15:19) \n[GCC 7.4.0]', 2)
  Reply With Quote
Old January 22nd, 2020, 02:46 PM   #24
AustralIan
Member
Germany

AustralIan is offline
 
Join Date: Jan 2013
Location: Germany
Posts: 1,122
Dear Herr Doktor Bitboy, what are you trying to say? I speak only train station.

In anyway it is a silly comment by me. Of course you test things before making changes, like a major rev of your compiler.

That said, reading the comments by the maintainer thiagoralves, it seems as though they may be interested in collaborating with our own OP.
  Reply With Quote
Old January 22nd, 2020, 11:00 PM   #25
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
What you all think about nodejs?

I know it is completely different. It is asynchronous (none-blocking), unlike ST, Python, C/C++. But when I look at possibilities for PLC it looks promising, isn't it?
  Reply With Quote
Old January 23rd, 2020, 02:10 AM   #26
Ronnie Sullivan
Member
United Kingdom

Ronnie Sullivan is offline
 
Join Date: May 2010
Location: London
Posts: 562
Hands up those who haven't understood a word.
__________________
I promise to get it right 3rd time every time.
  Reply With Quote
Old January 23rd, 2020, 03:46 AM   #27
tragically1969
Member
United Kingdom

tragically1969 is offline
 
Join Date: Jun 2007
Location: uk
Posts: 1,438
Quote:
Originally Posted by Ronnie Sullivan View Post
Hands up those who haven't understood a word.


I think he's come to the wrong forum...
  Reply With Quote
Old January 23rd, 2020, 07:45 AM   #28
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 356
Wink

Quote:
Originally Posted by Serhioromano View Post
What you all think about nodejs?

I know it is completely different. It is asynchronous (none-blocking), unlike ST, Python, C/C++. But when I look at possibilities for PLC it looks promising, isn't it?
Yes. Node is pretty quick, and there is a package, called Async.io or something like that, that takes any pain out of doing things in series vs. parallel. And when you write the web server for the PLC, the backend and frontend can be supported by the the same people.

Not the wrong forum: there are a few of us that have thought about it, then realized it would be akin to an obsession, and are probably jealous of the enthusiasm.

9, 11! (hah, I snuck in two tabs;-)
  Reply With Quote
Old January 23rd, 2020, 09:48 AM   #29
Serhioromano
Member
Kazakhstan

Serhioromano is offline
 
Join Date: Sep 2015
Location: Kazakhstan
Posts: 54
Something like this

Code:
class PLC_PRG {
    run() {
        var st = new Date().getTime();

        var foo = [];
        for (var i = 1; i <= 100000; i++) {
            foo.push(i + 5 * 10);
        }

        console.log(new Date().getTime() - st + "ms");
    }
}

var main = new PLC_PRG();
setInterval(main.run, 1000);
This shows only 3ms average time. Pretty much consistent. And possible to create times with resolution to (N)ms.

The good thing about it, that communication function will be triggered asynchronously. It will not interrupt but will resolve.
  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 01:49 AM
Selectable language Switching Mr.Adam LIVE PLC Questions And Answers 3 March 31st, 2015 02:57 PM
Reading selected language on PanelView by CompactLogix PLC amberman LIVE PLC Questions And Answers 2 December 4th, 2014 08:31 AM
Language Work The Plc Kid LIVE PLC Questions And Answers 5 July 4th, 2012 11:35 AM
Intouch 9.5 Runtime Language Switch Questions andrzejplo LIVE PLC Questions And Answers 2 March 31st, 2006 02:18 AM


All times are GMT -5. The time now is 08:30 PM.


.