NOP0 / rustmatic

PLC programming in Rust!
Apache License 2.0
35 stars 2 forks source link

WIP: Start the IEC compiler #23

Closed Michael-F-Bryan closed 4 years ago

Michael-F-Bryan commented 4 years ago

We need a way to turn a set of Structured Text files into a web of programs, function blocks, and resources which can be executed on the runtime.

I'm not 100% sure how I want to implement this. It may be useful to determine how people normally expect an IEC program to behave, then trace our steps backwards to come up with a way of modelling everything.

I'm also not sure how we want to handle execution. Ideally it'd use something like WASM, so as long as your runtime provides the correct bindings (we'll probably have a common header file that's usable by consumers) a lot of the hard work around compilation and making things fast will already be done for us.

NOP0 commented 4 years ago

I'm not 100% sure how I want to implement this. It may be useful to determine how people normally expect an IEC program to behave, then trace our steps backwards to come up with a way of modelling everything.

Hopefully I can help you at least getting started here. What do you prefer; links to resources, code, diagrams, AMA? 🙂

Edit: Some of this I could even put in the book. Like simple introduction to 61131-3.

Michael-F-Bryan commented 4 years ago

What do you prefer; links to resources, code, diagrams, AMA?

All of the above! 😁 I think trying to frame the software programming model in terms of Rust types/abstractions or as pages in our book may also be helpful.

I guess one of the hard parts for me is I don't have access to a PLC or the proprietary IDEs used to program them, and it's hard to try to implement something when you can't play around with it. Do you know if there are any free-to-use or open source programming environments with some sort of simulator built in?

NOP0 commented 4 years ago

I guess one of the hard parts for me is I don't have access to a PLC or the proprietary IDEs used to program them, and it's hard to try to implement something when you can't play around with it. Do you know if there are any free-to-use or open source programming environments with some sort of simulator built in?

You can check out Codesys if you don't mind registering your e-mail. You can even run your Raspberry PI as a PLC. (2 hour limit in demo mode). This is IEC compliant and industrial grade.

An Open Source solution I know of is Beremiz . But it's not that much happening in the Open Source & PLC intersection.

I'll try to do a write-up of stuff I think is relevant for the compiler later. 👍

NOP0 commented 4 years ago

Here's some more.

It's nice to know that 61131-3 has several editions. 61131-3 edition 2: Traditional, "limited" PLC programming 61131-3 edition 3: Added methods, interfaces, namespaces, inheritance, references etc.

A system can implement a variable amount of the standard. But I guess edition 2 is like a minimum, this is traditional PLC programming.

link

Blog about "advanced" PLC-programming https://stefanhenneken.wordpress.com/category/iec-61131-3-english/

plcopen intro

Michael-F-Bryan commented 4 years ago

I'm thinking of merging this initial PR. It's woefully incomplete, but merging bits and pieces as we go might be better than waiting until it's completely finished.

As long as master still compiles and the tests aren't broken, I think I'm okay with things being half-done. @NOP0, thoughts?

NOP0 commented 4 years ago

I agree. Then we have the structure in place in master also. :+1: