Rust for PLC programming

#1

Hi guys, I have been following use of Rust in embedded for some time now, and I’m impressed over the progress that is being made all the time.

I have been thinking lately over the possibility of using Rust in relation to PLC’s.

As you may know, programming of PLC’s is usually done in IEC61131-3, which is a collection of 5 languages, where Ladder logic and perhaps Structured Text (a textual language which is limited in ability by design (less footguns) and focused on maximum readability) are the most well-known. The focus I guess is foremost on ease of programming and troubleshooting/debugging.

It would be exciting do something in this space, like a ladder/structured text interpreter or something else to run on resource-constrained devices. PLC’s are similar, but another use case in relation to embedded systems. And I think there is some potential here for Rust.

What are your thoughts on Rust in this space, are there already some discussions or projects going on?

Thanks!

2 Likes
#2

I’ve played around with this idea in the past. In particular, I started writing up a basic compiler frontend for structured text and got about midway through the program analysis stage before getting distracted.

The way I’d probably approach this is to write a compiler that runs on a normal PC and then a #[no_std] virtual machine which can run on your microcontroller. Compilation often requires lots of data structures and dynamically-sized collections, which isn’t great on a constrained device which may not even have an allocator.

1 Like
#3

Cool, is your description of the approach the goal of your project? Looked at your project, nice to see ecs used for new problems outside of games.